aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Zamarin <arthurzam@gentoo.org>2024-02-26 22:48:42 +0200
committerArthur Zamarin <arthurzam@gentoo.org>2024-02-26 22:48:42 +0200
commit16a22e29ec16f0013a94ff3f26f10b6a15626b57 (patch)
treec92d9b26ecce5734f07a8d0a3c68ff086a4504c3
parentstart work on 0.2.10 (diff)
downloadpkgdev-16a22e29ec16f0013a94ff3f26f10b6a15626b57.tar.gz
pkgdev-16a22e29ec16f0013a94ff3f26f10b6a15626b57.tar.bz2
pkgdev-16a22e29ec16f0013a94ff3f26f10b6a15626b57.zip
bugs: don't crash when atom not found in history
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
-rw-r--r--src/pkgdev/scripts/pkgdev_bugs.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/pkgdev/scripts/pkgdev_bugs.py b/src/pkgdev/scripts/pkgdev_bugs.py
index 86f5247..6864ba7 100644
--- a/src/pkgdev/scripts/pkgdev_bugs.py
+++ b/src/pkgdev/scripts/pkgdev_bugs.py
@@ -550,13 +550,23 @@ class DependencyGraph:
):
toml.write(f"blocks = [{node_blocks}]\n")
for pkg, arches in node.pkgs:
- match = next(self.modified_repo.itermatch(pkg.versioned_atom))
- modified = datetime.fromtimestamp(match.time)
- match = next(self.added_repo.itermatch(pkg.versioned_atom))
- added = datetime.fromtimestamp(match.time)
- toml.write(
- f"# added on {added:%Y-%m-%d} (age {(datetime.today() - added).days} days), last modified on {modified:%Y-%m-%d} (age {(datetime.today() - modified).days} days)\n"
- )
+ try:
+ match = next(self.modified_repo.itermatch(pkg.versioned_atom))
+ modified = datetime.fromtimestamp(match.time)
+ age = (datetime.today() - modified).days
+ modified_text = f"{modified:%Y-%m-%d} (age {age} days)"
+ except StopIteration:
+ modified_text = "<unknown>"
+
+ try:
+ match = next(self.added_repo.itermatch(pkg.versioned_atom))
+ added = datetime.fromtimestamp(match.time)
+ age = (datetime.today() - added).days
+ added_text = f"{added:%Y-%m-%d} (age {age} days)"
+ except StopIteration:
+ added_text = "<unknown>"
+
+ toml.write(f"# added on {added_text}, last modified on {modified_text}\n")
keywords = ", ".join(f'"{x}"' for x in sort_keywords(arches))
toml.write(f'"{pkg.versioned_atom}" = [{keywords}]\n')
toml.write("\n\n")