diff --git a/dist/package/openSUSE-release-tools.spec b/dist/package/openSUSE-release-tools.spec index 17db2c8a..b56a737f 100644 --- a/dist/package/openSUSE-release-tools.spec +++ b/dist/package/openSUSE-release-tools.spec @@ -58,7 +58,7 @@ Requires: python3-pycurl Requires: python3-python-dateutil Requires: python3-pyxdg # factory-package-news.py -Requires: python3-pyzstd +Requires: python3-zstandard Requires: python3-requests # typing extensions are needed on SLE & Leap %if 0%{?suse_version} <= 1500 diff --git a/factory-package-news/factory-package-news.py b/factory-package-news/factory-package-news.py index a0acb859..442861d2 100755 --- a/factory-package-news/factory-package-news.py +++ b/factory-package-news/factory-package-news.py @@ -9,7 +9,8 @@ import rpm import pickle import cmdln import re -import pyzstd +# Can be replaced with pyzstd (for pyzstd.open) once available on ariel +import zstandard SRPM_RE = re.compile( r'(?P.+)-(?P[^-]+)-(?P[^-]+)\.(?P(?:no)?src\.rpm)$') @@ -31,11 +32,11 @@ def utf8str(content): # Older versions wrote uncompressed files, support both for now. def open_zstd_or_plain(path: str): f = open(path, 'rb') - if f.read(4) == b'\x28\xb5\x2f\xfd': - f.close() - return pyzstd.open(path, 'rb') - + magic = f.read(4) f.seek(0, os.SEEK_SET) + if magic == b'\x28\xb5\x2f\xfd': + return zstandard.ZstdDecompressor().stream_reader(f, closefd=True) + return f @@ -177,8 +178,9 @@ class ChangeLogger(cmdln.Cmdln): if not opts.snapshot: raise Exception("missing snapshot option") - with pyzstd.open(os.path.join(opts.dir, opts.snapshot), 'wb') as f: - pickle.dump([data_version, self.readChangeLogs(dirs)], f) + with open(os.path.join(opts.dir, opts.snapshot), 'wb') as fraw: + with zstandard.ZstdCompressor().stream_writer(fraw, closefd=False) as f: + pickle.dump([data_version, self.readChangeLogs(dirs)], f) def do_dump(self, subcmd, opts, *dirs): """${cmd_name}: pprint the package changelog information