From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 256FD158041 for ; Mon, 26 Feb 2024 20:48:58 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 578C1E2A34; Mon, 26 Feb 2024 20:48:57 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 31278E2A34 for ; Mon, 26 Feb 2024 20:48:57 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 18CFD33BE4D for ; Mon, 26 Feb 2024 20:48:56 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 7C2F9B2F for ; Mon, 26 Feb 2024 20:48:54 +0000 (UTC) From: "Arthur Zamarin" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Arthur Zamarin" Message-ID: <1708980522.16a22e29ec16f0013a94ff3f26f10b6a15626b57.arthurzam@gentoo> Subject: [gentoo-commits] proj/pkgcore/pkgdev:main commit in: src/pkgdev/scripts/ X-VCS-Repository: proj/pkgcore/pkgdev X-VCS-Files: src/pkgdev/scripts/pkgdev_bugs.py X-VCS-Directories: src/pkgdev/scripts/ X-VCS-Committer: arthurzam X-VCS-Committer-Name: Arthur Zamarin X-VCS-Revision: 16a22e29ec16f0013a94ff3f26f10b6a15626b57 X-VCS-Branch: main Date: Mon, 26 Feb 2024 20:48:54 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 0390dace-19b7-4556-b467-a1d3033a2077 X-Archives-Hash: 55b20d19fd26ff7bc45d91cba8340293 commit: 16a22e29ec16f0013a94ff3f26f10b6a15626b57 Author: Arthur Zamarin gentoo org> AuthorDate: Mon Feb 26 20:48:42 2024 +0000 Commit: Arthur Zamarin gentoo org> CommitDate: Mon Feb 26 20:48:42 2024 +0000 URL: https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=16a22e29 bugs: don't crash when atom not found in history Signed-off-by: Arthur Zamarin gentoo.org> src/pkgdev/scripts/pkgdev_bugs.py | 24 +++++++++++++++++------- 1 file 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 = "" + + 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 = "" + + 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")