Merge pull request #3040 from openSUSE/revert-3039-zstdnews
Revert "factory-package-news.py: Compress data files with zstd"
This commit is contained in:
commit
02b3886bf3
2
dist/package/openSUSE-release-tools.spec
vendored
2
dist/package/openSUSE-release-tools.spec
vendored
@ -57,8 +57,6 @@ Requires: python3-lxml
|
|||||||
Requires: python3-pycurl
|
Requires: python3-pycurl
|
||||||
Requires: python3-python-dateutil
|
Requires: python3-python-dateutil
|
||||||
Requires: python3-pyxdg
|
Requires: python3-pyxdg
|
||||||
# factory-package-news.py
|
|
||||||
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,8 +9,6 @@ import rpm
|
|||||||
import pickle
|
import pickle
|
||||||
import cmdln
|
import cmdln
|
||||||
import re
|
import re
|
||||||
# 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)$')
|
||||||
@ -29,17 +27,6 @@ def utf8str(content):
|
|||||||
return str(content, 'utf-8') if isinstance(content, bytes) else content
|
return str(content, 'utf-8') if isinstance(content, bytes) else content
|
||||||
|
|
||||||
|
|
||||||
# Older versions wrote uncompressed files, support both for now.
|
|
||||||
def open_zstd_or_plain(path: str):
|
|
||||||
f = 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
|
|
||||||
|
|
||||||
|
|
||||||
class ChangeLogger(cmdln.Cmdln):
|
class ChangeLogger(cmdln.Cmdln):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
cmdln.Cmdln.__init__(self, args, kwargs)
|
cmdln.Cmdln.__init__(self, args, kwargs)
|
||||||
@ -178,9 +165,8 @@ class ChangeLogger(cmdln.Cmdln):
|
|||||||
if not opts.snapshot:
|
if not opts.snapshot:
|
||||||
raise Exception("missing snapshot option")
|
raise Exception("missing snapshot option")
|
||||||
|
|
||||||
with open(os.path.join(opts.dir, opts.snapshot), 'wb') as fraw:
|
f = open(os.path.join(opts.dir, opts.snapshot), 'wb')
|
||||||
with zstandard.ZstdCompressor().stream_writer(fraw, closefd=False) as f:
|
pickle.dump([data_version, self.readChangeLogs(dirs)], 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
|
||||||
@ -196,9 +182,9 @@ class ChangeLogger(cmdln.Cmdln):
|
|||||||
${cmd_usage}
|
${cmd_usage}
|
||||||
${cmd_option_list}
|
${cmd_option_list}
|
||||||
"""
|
"""
|
||||||
with open_zstd_or_plain(filename) as f:
|
f = open(filename, 'rb')
|
||||||
(v, (pkgs, changelogs)) = pickle.load(
|
(v, (pkgs, changelogs)) = pickle.load(
|
||||||
f, encoding='utf-8', errors='backslashreplace')
|
f, encoding='utf-8', errors='backslashreplace')
|
||||||
pprint(pkgs[package])
|
pprint(pkgs[package])
|
||||||
pprint(changelogs[pkgs[package]['sourcerpm']])
|
pprint(changelogs[pkgs[package]['sourcerpm']])
|
||||||
|
|
||||||
@ -223,14 +209,14 @@ class ChangeLogger(cmdln.Cmdln):
|
|||||||
if not os.path.isdir(opts.dir):
|
if not os.path.isdir(opts.dir):
|
||||||
raise Exception("%s must be a directory" % opts.dir)
|
raise Exception("%s must be a directory" % opts.dir)
|
||||||
|
|
||||||
with open_zstd_or_plain(os.path.join(opts.dir, version1)) as f:
|
f = open(os.path.join(opts.dir, version1), 'rb')
|
||||||
(v, (v1pkgs, v1changelogs)) = pickle.load(f,
|
(v, (v1pkgs, v1changelogs)) = pickle.load(f,
|
||||||
encoding='utf-8', errors='backslashreplace')
|
encoding='utf-8', errors='backslashreplace')
|
||||||
if v != data_version:
|
if v != data_version:
|
||||||
raise Exception("not matching version %s in %s" % (v, version1))
|
raise Exception("not matching version %s in %s" % (v, version1))
|
||||||
with open_zstd_or_plain(os.path.join(opts.dir, version2)) as f:
|
f = open(os.path.join(opts.dir, version2), 'rb')
|
||||||
(v, (v2pkgs, v2changelogs)) = pickle.load(f,
|
(v, (v2pkgs, v2changelogs)) = pickle.load(f,
|
||||||
encoding='utf-8', errors='backslashreplace')
|
encoding='utf-8', errors='backslashreplace')
|
||||||
if v != data_version:
|
if v != data_version:
|
||||||
raise Exception("not matching version %s in %s" % (v, version2))
|
raise Exception("not matching version %s in %s" % (v, version2))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user