Minor Python modernization fixes.
This commit is contained in:
parent
1abbfe8ee6
commit
e693e42b9e
3 changed files with 4 additions and 8 deletions
|
|
@ -68,7 +68,7 @@ def collect_patterns(config):
|
|||
+ tuple(
|
||||
parse_pattern(pattern_line.strip())
|
||||
for filename in config.get('patterns_from', ())
|
||||
for pattern_line in open(filename, encoding='utf-8').readlines()
|
||||
for pattern_line in open(filename, encoding='utf-8')
|
||||
if not pattern_line.lstrip().startswith('#')
|
||||
if pattern_line.strip()
|
||||
)
|
||||
|
|
@ -78,7 +78,7 @@ def collect_patterns(config):
|
|||
borgmatic.borg.pattern.Pattern_style.FNMATCH,
|
||||
)
|
||||
for filename in config.get('exclude_from', ())
|
||||
for exclude_line in open(filename, encoding='utf-8').readlines()
|
||||
for exclude_line in open(filename, encoding='utf-8')
|
||||
if not exclude_line.lstrip().startswith('#')
|
||||
if exclude_line.strip()
|
||||
)
|
||||
|
|
|
|||
|
|
@ -168,11 +168,7 @@ def render_configuration(config):
|
|||
rendered,
|
||||
# Dumping certain values (integers, for instance) causes ruamel.yaml to append an
|
||||
# end-of-document "..." marker. Strip it.
|
||||
transform=lambda dumped: (
|
||||
dumped[: -len(RUAMEL_YAML_END_OF_DOCUMENT_MARKER)]
|
||||
if dumped.endswith(RUAMEL_YAML_END_OF_DOCUMENT_MARKER)
|
||||
else dumped
|
||||
),
|
||||
transform=lambda dumped: dumped.removesuffix(RUAMEL_YAML_END_OF_DOCUMENT_MARKER),
|
||||
)
|
||||
|
||||
return rendered.getvalue()
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ MAXIMUM_LINE_LENGTH = 80
|
|||
def test_schema_line_length_stays_under_limit():
|
||||
schema_file = open(borgmatic.config.validate.schema_filename())
|
||||
|
||||
for line in schema_file.readlines():
|
||||
for line in schema_file:
|
||||
assert len(line.rstrip('\n')) <= MAXIMUM_LINE_LENGTH
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue