[elbe-devel] [PATCH 2/9] elbepack: preprocess: use keyword arguments

Thomas Weißschuh thomas.weissschuh at linutronix.de
Thu Aug 1 12:40:23 CEST 2024


They are clearer to read.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
 elbepack/commands/pbuilder.py   | 2 +-
 elbepack/commands/preprocess.py | 3 ++-
 elbepack/initvmaction.py        | 4 ++--
 elbepack/xmlpreprocess.py       | 4 ++--
 4 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/elbepack/commands/pbuilder.py b/elbepack/commands/pbuilder.py
index e7f2f9d6777f..024e373970e4 100644
--- a/elbepack/commands/pbuilder.py
+++ b/elbepack/commands/pbuilder.py
@@ -38,7 +38,7 @@ def _create(args):
         ccacheopt = ['--ccache-size', args.ccachesize]
 
     if args.xmlfile:
-        with preprocess_file(args.xmlfile, args.variants) as preproc:
+        with preprocess_file(args.xmlfile, variants=args.variants) as preproc:
             ps = run_elbe(['control', 'create_project'],
                           capture_output=True, encoding='utf-8')
             if ps.returncode != 0:
diff --git a/elbepack/commands/preprocess.py b/elbepack/commands/preprocess.py
index 46bc1140503f..57b6ff928bd4 100644
--- a/elbepack/commands/preprocess.py
+++ b/elbepack/commands/preprocess.py
@@ -37,7 +37,8 @@ def run_command(argv):
         sys.exit(113)
 
     try:
-        xmlpreprocess(args.xmlfile, args.output, args.variants, args.proxy, args.gzip)
+        xmlpreprocess(args.xmlfile, args.output,
+                      variants=args.variants, proxy=args.proxy, gzip=args.gzip)
     except XMLPreprocessError as e:
         print(e, file=sys.stderr)
         sys.exit(114)
diff --git a/elbepack/initvmaction.py b/elbepack/initvmaction.py
index d7a6b4d91c66..52ce583e2508 100644
--- a/elbepack/initvmaction.py
+++ b/elbepack/initvmaction.py
@@ -87,7 +87,7 @@ def _submit_with_repodir_and_dl_result(xmlfile, cdrom, args):
 
 def _submit_and_dl_result(xmlfile, cdrom, args):
 
-    with preprocess_file(xmlfile, args.variants) as xmlfile:
+    with preprocess_file(xmlfile, variants=args.variants) as xmlfile:
 
         ps = run_elbe(['control', 'create_project'],
                       capture_output=True, encoding='utf-8', check=True)
@@ -320,7 +320,7 @@ def _create(args):
             elbepack.__path__[0],
             'init/default-init.xml')
 
-    with preprocess_file(xmlfile, args.variants) as preproc:
+    with preprocess_file(xmlfile, variants=args.variants) as preproc:
         create_initvm(
             cfg['initvm_domain'],
             preproc,
diff --git a/elbepack/xmlpreprocess.py b/elbepack/xmlpreprocess.py
index 0252614ab9b6..510fb7aa21ba 100644
--- a/elbepack/xmlpreprocess.py
+++ b/elbepack/xmlpreprocess.py
@@ -323,7 +323,7 @@ def preprocess_passwd(xml):
                         'backwards compatibility reasons. This is considered insecure nowadays.')
 
 
-def xmlpreprocess(xml_input_file, xml_output_file, variants=None, proxy=None, gzip=9):
+def xmlpreprocess(xml_input_file, xml_output_file, *, variants=None, proxy=None, gzip=9):
     """Preprocesses the input XML data to make sure the `output`
        can be validated against the current schema.
        `xml_input_file` is a path (str) to the input file.
@@ -439,7 +439,7 @@ def xmlpreprocess(xml_input_file, xml_output_file, variants=None, proxy=None, gz
 
 
 @contextlib.contextmanager
-def preprocess_file(xmlfile, variants):
+def preprocess_file(xmlfile, *, variants):
     with tempfile.NamedTemporaryFile(suffix='elbe.xml') as preproc:
         xmlpreprocess(xmlfile, preproc, variants=variants)
         preproc.seek(0)

-- 
2.45.2



More information about the elbe-devel mailing list