diff options
author | Dylan Baker <baker.dylan.c@gmail.com> | 2015-08-21 13:01:57 -0700 |
---|---|---|
committer | Dylan Baker <baker.dylan.c@gmail.com> | 2015-09-01 17:59:00 -0700 |
commit | 2c0a54c7905ae0e070171dd48943e963757e2f80 (patch) | |
tree | e8d7d543ae867243ef71a170b08cfb32da447431 /framework/backends | |
parent | 3a0b7fc4267a2a34b4954a66f5fd341405dd26a8 (diff) |
framework/backends/abstract: Fix doubling compression suffixes
This patch fixes the write_compressed method to not add an additional
compression suffix to files that already have a compression suffix.
This fixes the tests from the previous patch.
Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
Diffstat (limited to 'framework/backends')
-rw-r--r-- | framework/backends/abstract.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/framework/backends/abstract.py b/framework/backends/abstract.py index c892995e3..4a87857d7 100644 --- a/framework/backends/abstract.py +++ b/framework/backends/abstract.py @@ -49,7 +49,12 @@ def write_compressed(filename): """ mode = compression.get_mode() if mode != 'none': - filename = '{}.{}'.format(filename, mode) + # if the suffix (final .xxx) is a knwon compression suffix + suffix = os.path.splitext(filename)[1] + if suffix in compression.COMPRESSION_SUFFIXES: + filename = '{}.{}'.format(os.path.splitext(filename)[0], mode) + else: + filename = '{}.{}'.format(filename, mode) with compression.COMPRESSORS[mode](filename) as f: yield f |