From c2288ee9a5779075498815c0b26edf5b692b6cd9 Mon Sep 17 00:00:00 2001 From: Jason Curtis Date: Sat, 4 Jun 2022 13:04:38 -0500 Subject: [PATCH] add checksum properties to packages class --- source/repomd.py | 16 ++++++++++++++++ tests/test_repomd.py | 6 ++++++ 2 files changed, 22 insertions(+) diff --git a/source/repomd.py b/source/repomd.py index 18503fb..6a40f46 100644 --- a/source/repomd.py +++ b/source/repomd.py @@ -130,6 +130,22 @@ def build_time(self): def location(self): return self._element.find('common:location', namespaces=_ns).get('href') + @property + def checksum(self): + return self._element.findtext('common:checksum', namespaces=_ns) + + @property + def _checksum_info(self): + return self._element.find('common:checksum', namespaces=_ns) + + @property + def checksum_type(self): + return self._checksum_info.get('type') + + @property + def checksum_pkgid(self): + return self._checksum_info.get('pkgid') + @property def _version_info(self): return self._element.find('common:version', namespaces=_ns) diff --git a/tests/test_repomd.py b/tests/test_repomd.py index 4dc221d..afc9b8a 100644 --- a/tests/test_repomd.py +++ b/tests/test_repomd.py @@ -100,6 +100,9 @@ def test_package(chicken): assert chicken.build_time == datetime.datetime.fromtimestamp(1525208602) assert chicken.location == 'chicken-2.2.10-1.fc27.noarch.rpm' assert chicken.epoch == '0' + assert chicken.checksum == '3e5d70aca9624e0c738651d1ff811de88c8e8bebfde4b52778fd264631d530fc' + assert chicken.checksum_type == 'sha256' + assert chicken.checksum_pkgid == 'YES' assert chicken.version == '2.2.10' assert chicken.release == '1.fc27' assert chicken.vr == '2.2.10-1.fc27' @@ -123,6 +126,9 @@ def test_package_with_epoch(brisket): assert brisket.build_time == datetime.datetime.fromtimestamp(1525208602) assert brisket.location == 'brisket-5.1.1-1.fc27.noarch.rpm' assert brisket.epoch == '1' + assert brisket.checksum == '9f1ba9973df8f6184214ecfc67e693b96d615ef58321a62142089464f50413b9' + assert brisket.checksum_type == 'sha256' + assert brisket.checksum_pkgid == 'YES' assert brisket.version == '5.1.1' assert brisket.release == '1.fc27' assert brisket.vr == '5.1.1-1.fc27'