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 <[email protected]>
---
 framework/backends/abstract.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/framework/backends/abstract.py b/framework/backends/abstract.py
index c892995..97d2d07 100644
--- a/framework/backends/abstract.py
+++ b/framework/backends/abstract.py
@@ -49,7 +49,13 @@ def write_compressed(filename):
     """
     mode = compression.get_mode()
     if mode != 'none':
-        filename = '{}.{}'.format(filename, mode)
+        suffix = os.path.splitext(filename)[1]
+        if suffix[1:] == mode:
+            pass
+        elif 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
-- 
2.5.0

_______________________________________________
Piglit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to