summaryrefslogtreecommitdiffstats
path: root/src/debputy/dh_migration/migrators_impl.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/debputy/dh_migration/migrators_impl.py')
-rw-r--r--src/debputy/dh_migration/migrators_impl.py31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/debputy/dh_migration/migrators_impl.py b/src/debputy/dh_migration/migrators_impl.py
index 6613c25..7856d27 100644
--- a/src/debputy/dh_migration/migrators_impl.py
+++ b/src/debputy/dh_migration/migrators_impl.py
@@ -1,5 +1,6 @@
import collections
import dataclasses
+import functools
import json
import os
import re
@@ -675,16 +676,15 @@ def migrate_install_file(
current_sources.extend(sources)
continue
key = (dest_dir, dhe_line.conditional_key())
+ ctor = functools.partial(
+ SourcesAndConditional,
+ dest_dir=dest_dir,
+ conditional=dhe_line.conditional(),
+ )
md = _fetch_or_create(
sources_by_destdir,
key,
- # Use named parameters to avoid warnings about the values possible changing
- # in the next iteration. We always resolve the lambda in this iteration, so
- # the bug is non-existent. However, that is harder for a linter to prove.
- lambda *, dest=dest_dir, dhe=dhe_line: SourcesAndConditional(
- dest_dir=dest,
- conditional=dhe.conditional(),
- ),
+ ctor,
)
md.sources.extend(sources)
@@ -908,10 +908,13 @@ def migrate_installinfo_file(
info_files_by_condition: Dict[Tuple[str, ...], InfoFilesDefinition] = {}
for dhe_line in content:
key = dhe_line.conditional_key()
+ ctr = functools.partial(
+ InfoFilesDefinition, conditional=dhe_line.conditional()
+ )
info_def = _fetch_or_create(
info_files_by_condition,
key,
- lambda: InfoFilesDefinition(conditional=dhe_line.conditional()),
+ ctr,
)
info_def.sources.extend(
_normalize_path(w, with_prefix=False) for w in dhe_line.tokens
@@ -1023,12 +1026,15 @@ def migrate_installman_file(
else:
language = None
key = (language, dhe_line.conditional_key())
+ ctor = functools.partial(
+ ManpageDefinition,
+ language=language,
+ conditional=dhe_line.conditional(),
+ )
manpage_def = _fetch_or_create(
complex_definitions,
key,
- lambda: ManpageDefinition(
- language=language, conditional=dhe_line.conditional()
- ),
+ ctor,
)
manpage_def.sources.extend(sources)
else:
@@ -1483,7 +1489,8 @@ def read_dh_addon_sequences(
drules = debian_dir.get("rules")
if drules and drules.is_file:
- parse_drules_for_addons(drules, dr_sequences)
+ with drules.open() as fd:
+ parse_drules_for_addons(fd, dr_sequences)
with ctrl_file.open() as fd:
ctrl = list(Deb822.iter_paragraphs(fd))