[elbe-devel] [PATCH v2] preprocess: introduce compression level

bage at linutronix.de bage at linutronix.de
Tue Aug 27 22:50:24 CEST 2019


From: Bastian Germann <bage at linutronix.de>

elbe preprocess uses preprocess.xml as default file name but applies a
gzip compression unexpectedly. Introduce a parameter to explicitly set
the gzip compression level.

Closes #213.

Signed-off-by: Bastian Germann <bage at linutronix.de>
---
 elbepack/commands/preprocess.py | 5 ++++-
 elbepack/xmlpreprocess.py       | 4 ++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/elbepack/commands/preprocess.py b/elbepack/commands/preprocess.py
index 44e298c4..eeedffec 100644
--- a/elbepack/commands/preprocess.py
+++ b/elbepack/commands/preprocess.py
@@ -23,6 +23,9 @@ def run_command(argv):
     oparser.add_option("-o", "--output", dest="output",
                        default="preprocess.xml",
                        help="preprocessed output file", metavar="<xmlfile>")
+    oparser.add_option("-z", "--gzip", dest="gzip", type="int",
+                       default=0,
+                       help="gzip compression level 1-9 (0: no compression)", metavar="<level>")
     add_pass_through_options(oparser)
     (opt, args) = oparser.parse_args(argv)
 
@@ -40,7 +43,7 @@ def run_command(argv):
         variants = opt.variant.split(',')
 
     try:
-        xmlpreprocess(args[0], opt.output, variants)
+        xmlpreprocess(args[0], opt.output, variants, opt.gzip)
     except XMLPreprocessError as e:
         print(e, file=sys.stderr)
         sys.exit(20)
diff --git a/elbepack/xmlpreprocess.py b/elbepack/xmlpreprocess.py
index 0e986a75..d97009f8 100644
--- a/elbepack/xmlpreprocess.py
+++ b/elbepack/xmlpreprocess.py
@@ -69,7 +69,7 @@ def preprocess_iso_option(xml):
         print("[WARN] %s" % violation)
 
 
-def xmlpreprocess(fname, output, variants=None):
+def xmlpreprocess(fname, output, variants=None, gzip=0):
 
     # pylint: disable=too-many-locals
     # pylint: disable=too-many-branches
@@ -147,7 +147,7 @@ def xmlpreprocess(fname, output, variants=None):
                 output,
                 encoding="UTF-8",
                 pretty_print=True,
-                compression=9)
+                compression=gzip)
             # the rest of the code is exception and error handling
             return
 
-- 
2.20.1




More information about the elbe-devel mailing list