[elbe-devel] [PATCH v3] preprocess: introduce compression level
bage at linutronix.de
bage at linutronix.de
Mon Oct 14 18:24:21 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 598ced45..ea1cac80 100644
--- a/elbepack/xmlpreprocess.py
+++ b/elbepack/xmlpreprocess.py
@@ -84,7 +84,7 @@ def preprocess_initvm_ports(xml):
forward.getparent().remove(forward)
-def xmlpreprocess(fname, output, variants=None):
+def xmlpreprocess(fname, output, variants=None, gzip=0):
# pylint: disable=too-many-locals
# pylint: disable=too-many-branches
@@ -164,7 +164,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