[scripts/util] add 'lines()' helper

This commit is contained in:
Mike Fährmann
2025-08-23 18:29:23 +02:00
parent 1787478d6b
commit 57a4b5b5b1
3 changed files with 28 additions and 19 deletions

View File

@@ -47,13 +47,9 @@ def init_extractor(args):
LOG.info(util.trim(path))
if lines:
with util.open(path) as fp:
lines = fp.readlines()
if func(args, lines):
with util.lazy(path) as fp:
fp.writelines(lines)
else:
LOG.warning("'%s' already present", category)
with util.lines(path) as lines:
if not func(args, lines):
LOG.warning("'%s' already present", category)
else:
try:
with util.open(path, args.open_mode) as fp: