[elbe-devel] [PATCH v2 21/22] changelogxml: implement class to write xml file (based on licencexml)
Bastian Germann
bage at linutronix.de
Tue Jul 2 17:42:01 CEST 2019
> abstract the writing of the chanelogxml file into its own class.
> this code is based on licencexml.
>
> add it to
> debian/python-elbe-common.install and debian/python3-elbe-common.install
>
> Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
>
> changelogxml: add it to install files
>
> Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
Something went wrong here. Merge the summary.
With this applied
Reviewed-by: Bastian Germann <bage at linutronix.de>
> ---
> debian/python-elbe-common.install | 1 +
> debian/python3-elbe-common.install | 1 +
> elbepack/changelogxml.py | 33 +++++++++++++++++++++++++++++++++
> 3 files changed, 35 insertions(+)
> create mode 100644 elbepack/changelogxml.py
>
> diff --git a/debian/python-elbe-common.install b/debian/python-elbe-common.install
> index 384364257..9c338eb0c 100644
> --- a/debian/python-elbe-common.install
> +++ b/debian/python-elbe-common.install
> @@ -8,6 +8,7 @@
> ./usr/lib/python2.*/*-packages/elbepack/commands/__init__.py
> ./usr/lib/python2.*/*-packages/elbepack/aptprogress.py
> ./usr/lib/python2.*/*-packages/elbepack/archivedir.py
> +./usr/lib/python2.*/*-packages/elbepack/changelogxml.py
> ./usr/lib/python2.*/*-packages/elbepack/config.py
> ./usr/lib/python2.*/*-packages/elbepack/debinstaller.py
> ./usr/lib/python2.*/*-packages/elbepack/default-preseed.xml
> diff --git a/debian/python3-elbe-common.install b/debian/python3-elbe-common.install
> index 893ae396b..1b0037cfe 100644
> --- a/debian/python3-elbe-common.install
> +++ b/debian/python3-elbe-common.install
> @@ -8,6 +8,7 @@
> ./usr/lib/python3.*/*-packages/elbepack/commands/__init__.py
> ./usr/lib/python3.*/*-packages/elbepack/aptprogress.py
> ./usr/lib/python3.*/*-packages/elbepack/archivedir.py
> +./usr/lib/python3.*/*-packages/elbepack/changelogxml.py
> ./usr/lib/python3.*/*-packages/elbepack/config.py
> ./usr/lib/python3.*/*-packages/elbepack/debinstaller.py
> ./usr/lib/python3.*/*-packages/elbepack/default-preseed.xml
> diff --git a/elbepack/changelogxml.py b/elbepack/changelogxml.py
> new file mode 100644
> index 000000000..a0681f921
> --- /dev/null
> +++ b/elbepack/changelogxml.py
> @@ -0,0 +1,33 @@
> +# ELBE - Debian Based Embedded Rootfilesystem Builder
> +# Copyright (c) 2019 Torben Hohn <torben.hohn at linutronix.de>
> +#
> +# 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(object):
> + 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
> +
> + def write(self, fname):
> + self.outxml.write(fname, encoding="utf-8")
>
More information about the elbe-devel
mailing list