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)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 723FA158015 for ; Sat, 30 Dec 2023 13:37:46 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B19622BC021; Sat, 30 Dec 2023 13:37:45 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 903762BC021 for ; Sat, 30 Dec 2023 13:37:45 +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 BE8FD33BE3B for ; Sat, 30 Dec 2023 13:37:44 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 108F199E for ; Sat, 30 Dec 2023 13:37:43 +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: <1703943455.45e2a7c1d0ce8e9ef7bba0cae4b4648a5d764540.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/argparsers.py X-VCS-Directories: src/pkgdev/scripts/ X-VCS-Committer: arthurzam X-VCS-Committer-Name: Arthur Zamarin X-VCS-Revision: 45e2a7c1d0ce8e9ef7bba0cae4b4648a5d764540 X-VCS-Branch: main Date: Sat, 30 Dec 2023 13:37:43 +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: ecce027d-60dd-4c0c-bc27-96ca5e05cbc0 X-Archives-Hash: 274bbaa000c42bb5b8f25bb037d8b345 commit: 45e2a7c1d0ce8e9ef7bba0cae4b4648a5d764540 Author: Arthur Zamarin gentoo org> AuthorDate: Sat Dec 30 13:37:35 2023 +0000 Commit: Arthur Zamarin gentoo org> CommitDate: Sat Dec 30 13:37:35 2023 +0000 URL: https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=45e2a7c1 argparse: better handling of ~/.bugzrc Signed-off-by: Arthur Zamarin gentoo.org> src/pkgdev/scripts/argparsers.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pkgdev/scripts/argparsers.py b/src/pkgdev/scripts/argparsers.py index 5cefeca..9ab58da 100644 --- a/src/pkgdev/scripts/argparsers.py +++ b/src/pkgdev/scripts/argparsers.py @@ -1,6 +1,7 @@ import os import subprocess from configparser import ConfigParser +from contextlib import suppress from pathlib import Path from pkgcore.repository import errors as repo_errors @@ -75,8 +76,13 @@ class BugzillaApiKey: try: config = ConfigParser(default_section="default") config.read(bugz_rc_file) - setattr(namespace, attr, config.get("default", "key")) except Exception as e: raise ValueError(f"failed parsing {bugz_rc_file}: {e}") - elif (bugz_token_file := Path.home() / ".bugz_token").is_file(): + + for category in ("default", "gentoo", "Gentoo"): + with suppress(Exception): + setattr(namespace, attr, config.get(category, "key")) + return + + if (bugz_token_file := Path.home() / ".bugz_token").is_file(): setattr(namespace, attr, bugz_token_file.read_text().strip())