Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added support for Python 2.6

  • Loading branch information...
commit 3fa9f7b48b84f3959fa4d724b98166aaa3100b07 1 parent dc6b646
Didip Kerabat authored
Showing with 16 additions and 1 deletion.
  1. +16 −1 src/crammit/__init__.py
17 src/crammit/__init__.py
View
@@ -53,6 +53,21 @@ def load_config(path):
return yaml.load(open(path))
+class GzipFilePython26(gzip.GzipFile):
+ def __enter__(self):
+ if self.fileobj is None:
+ raise ValueError("I/O operation on closed GzipFile object")
+ return self
+
+ def __exit__(self, *args):
+ self.close()
+
+
+GzipFileClass = gzip.GzipFile
+if sys.version_info < (2, 7):
+ GzipFileClass = GzipFilePython26
+
+
class AssetManager(object):
"""I manage assets bundles."""
def __init__(self, config, basedir=None):
@@ -96,7 +111,7 @@ def _get_bundles_by_type(self, type):
def _compress(self, data):
compresslevel = 9 # max
buffer = StringIO.StringIO()
- with gzip.GzipFile(fileobj=buffer, mode='wb',
+ with GzipFileClass(fileobj=buffer, mode='wb',
compresslevel=compresslevel) as fout:
fout.write(data)
return buffer.getvalue()
Please sign in to comment.
Something went wrong with that request. Please try again.