[elbe-devel] [PATCH v1 1/3] check_updates: use strings for concatenated changelogs

Holger Dengler dengler at linutronix.de
Fri Jul 2 18:14:33 CEST 2021


Use strings instead of bytes for the concatenated changelogs and
remove the late decoding.

Signed-off-by: Holger Dengler <dengler at linutronix.de>
---
 elbepack/changelogxml.py | 12 +-----------
 elbepack/pkgutils.py     |  6 ++++--
 2 files changed, 5 insertions(+), 13 deletions(-)

diff --git a/elbepack/changelogxml.py b/elbepack/changelogxml.py
index e0400328..869783cd 100644
--- a/elbepack/changelogxml.py
+++ b/elbepack/changelogxml.py
@@ -3,29 +3,19 @@
 #
 # SPDX-License-Identifier: GPL-3.0-or-later
 
-import re
 from elbepack.treeutils import etree
 
-
-remove_re = re.compile(u'[\x00-\x08\x0B-\x0C\x0E-\x1F\x7F]')
-
 class changelogs_xml:
     def __init__(self):
         self.outxml = etree(None)
         self.pkglist = self.outxml.setroot('pkgchangelogs')
 
     def add_pkg_changelog(self, xp, changelog_text):
-        changelog_text, _ = remove_re.subn('', changelog_text)
-
         xmlpkg = self.pkglist.append('changelog')
         xmlpkg.et.attrib['name'] = xp.name
         xmlpkg.et.attrib['version'] = xp.candidate_version
         xmlpkg.et.attrib['old_version'] = xp.installed_version
-
-        try:
-            xmlpkg.et.text = changelog_text.decode('utf-8')
-        except ValueError:
-            print(changelog_text)
+        xmlpkg.et.text = changelog_text
 
     def write(self, fname):
         self.outxml.write(fname, encoding="utf-8")
diff --git a/elbepack/pkgutils.py b/elbepack/pkgutils.py
index ea8c49aa..598eb6b1 100644
--- a/elbepack/pkgutils.py
+++ b/elbepack/pkgutils.py
@@ -111,12 +111,14 @@ def extract_pkg_changelog(fname, extra_pkg=None):
     ret = ""
 
     if fs.exists(dch_bin):
-        ret += fs.read_file(dch_bin, gz=True)
+        ret += fs.read_file(dch_bin, gz=True).decode(encoding='utf-8',
+                                                     errors='replace')
     else:
         print("no bin")
 
     if fs.exists(dch_src):
-        ret += fs.read_file(dch_src, gz=True)
+        ret += fs.read_file(dch_src, gz=True).decode(encoding='utf-8',
+                                                     errors='replace')
     else:
         print("no source")
 
-- 
2.32.0



More information about the elbe-devel mailing list