commit 152f4c434ca99792325707014be3e195a8d9cc88
parent 7b234b5febe9b32148c60a7ff5b5f582e5882d58
Author: parazyd <parazyd@dyne.org>
Date: Wed, 31 May 2017 23:18:12 +0200
fix gzip writing
Diffstat:
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/lib/package.py b/lib/package.py
@@ -11,7 +11,7 @@ def write_packages(packages, filename, sort=True):
If sort=True, the packages are sorted by name.
"""
os.makedirs(os.path.dirname(filename), exist_ok=True)
- f = open(filename, 'w+')
+ f = gzip_open(filename, 'w')
pkg_items = packages.items()
if sort:
@@ -20,8 +20,9 @@ def write_packages(packages, filename, sort=True):
for pkg_name, pkg_contents in pkg_items:
for key in packages_keys:
if key in pkg_contents:
- f.write('%s: %s\n' % (key, pkg_contents[key]))
- f.write('\n')
+ s = '%s: %s\n' % (key, pkg_contents[key])
+ f.write(s.encode('utf-8'))
+ f.write(b'\n')
f.close()