diff options
author | Daniel Alley <dalley@redhat.com> | 2022-02-02 20:22:46 +0300 |
---|---|---|
committer | amatej <matej.ales@seznam.cz> | 2022-02-03 11:07:16 +0300 |
commit | e581337e9bdffc8a2afd71370afc71b46e115bd8 (patch) | |
tree | 404965e884089c571d4dc715b0ce9314c9714160 | |
parent | 7fa040b534df47f9a2d94c7a52aa8593cd900568 (diff) |
Make parse warnings visible through cr.Repomd(), cr.UpdateInfo()
There is no way to access parser warnings without using the low level
API.
-rw-r--r-- | src/python/createrepo_c/__init__.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/python/createrepo_c/__init__.py b/src/python/createrepo_c/__init__.py index 0fc94f7..5c3fc63 100644 --- a/src/python/createrepo_c/__init__.py +++ b/src/python/createrepo_c/__init__.py @@ -149,8 +149,14 @@ class Repomd(_createrepo_c.Repomd): def __init__(self, path=None): """:arg path: Path to existing repomd.xml or None""" _createrepo_c.Repomd.__init__(self) + self.warnings = [] + + def _warningcb(warning_type, message): + self.warnings.append((warning_type, message)) + return True # continue parsing + if path: - xml_parse_repomd(path, self) + xml_parse_repomd(path, self, warningcb=_warningcb) def __iter__(self): for rec in self.records: @@ -229,9 +235,14 @@ class UpdateInfo(_createrepo_c.UpdateInfo): def __init__(self, path=None): """:arg path: Path to existing updateinfo.xml or None""" _createrepo_c.UpdateInfo.__init__(self) - if path: - xml_parse_updateinfo(path, self) + self.warnings = [] + def _warningcb(warning_type, message): + self.warnings.append((warning_type, message)) + return True # continue parsing + + if path: + xml_parse_updateinfo(path, self, warningcb=_warningcb) # UpdateRecord class |