factory-package-news.py: Port from pyzstd to zstandard
ariel has only zstandard 0.13.0, so not even the .open method exists.
This commit is contained in:
parent
8516c1ad8f
commit
b82749ac01
2
dist/package/openSUSE-release-tools.spec
vendored
2
dist/package/openSUSE-release-tools.spec
vendored
@ -58,7 +58,7 @@ Requires: python3-pycurl
|
|||||||
Requires: python3-python-dateutil
|
Requires: python3-python-dateutil
|
||||||
Requires: python3-pyxdg
|
Requires: python3-pyxdg
|
||||||
# factory-package-news.py
|
# factory-package-news.py
|
||||||
Requires: python3-pyzstd
|
Requires: python3-zstandard
|
||||||
Requires: python3-requests
|
Requires: python3-requests
|
||||||
# typing extensions are needed on SLE & Leap
|
# typing extensions are needed on SLE & Leap
|
||||||
%if 0%{?suse_version} <= 1500
|
%if 0%{?suse_version} <= 1500
|
||||||
|
@ -9,7 +9,8 @@ import rpm
|
|||||||
import pickle
|
import pickle
|
||||||
import cmdln
|
import cmdln
|
||||||
import re
|
import re
|
||||||
import pyzstd
|
# Can be replaced with pyzstd (for pyzstd.open) once available on ariel
|
||||||
|
import zstandard
|
||||||
|
|
||||||
SRPM_RE = re.compile(
|
SRPM_RE = re.compile(
|
||||||
r'(?P<name>.+)-(?P<version>[^-]+)-(?P<release>[^-]+)\.(?P<suffix>(?:no)?src\.rpm)$')
|
r'(?P<name>.+)-(?P<version>[^-]+)-(?P<release>[^-]+)\.(?P<suffix>(?:no)?src\.rpm)$')
|
||||||
@ -31,11 +32,11 @@ def utf8str(content):
|
|||||||
# Older versions wrote uncompressed files, support both for now.
|
# Older versions wrote uncompressed files, support both for now.
|
||||||
def open_zstd_or_plain(path: str):
|
def open_zstd_or_plain(path: str):
|
||||||
f = open(path, 'rb')
|
f = open(path, 'rb')
|
||||||
if f.read(4) == b'\x28\xb5\x2f\xfd':
|
magic = f.read(4)
|
||||||
f.close()
|
|
||||||
return pyzstd.open(path, 'rb')
|
|
||||||
|
|
||||||
f.seek(0, os.SEEK_SET)
|
f.seek(0, os.SEEK_SET)
|
||||||
|
if magic == b'\x28\xb5\x2f\xfd':
|
||||||
|
return zstandard.ZstdDecompressor().stream_reader(f, closefd=True)
|
||||||
|
|
||||||
return f
|
return f
|
||||||
|
|
||||||
|
|
||||||
@ -177,8 +178,9 @@ class ChangeLogger(cmdln.Cmdln):
|
|||||||
if not opts.snapshot:
|
if not opts.snapshot:
|
||||||
raise Exception("missing snapshot option")
|
raise Exception("missing snapshot option")
|
||||||
|
|
||||||
with pyzstd.open(os.path.join(opts.dir, opts.snapshot), 'wb') as f:
|
with open(os.path.join(opts.dir, opts.snapshot), 'wb') as fraw:
|
||||||
pickle.dump([data_version, self.readChangeLogs(dirs)], f)
|
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):
|
def do_dump(self, subcmd, opts, *dirs):
|
||||||
"""${cmd_name}: pprint the package changelog information
|
"""${cmd_name}: pprint the package changelog information
|
||||||
|
Loading…
x
Reference in New Issue
Block a user