aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Zamarin <arthurzam@gentoo.org>2023-12-30 15:37:35 +0200
committerArthur Zamarin <arthurzam@gentoo.org>2023-12-30 15:37:35 +0200
commit45e2a7c1d0ce8e9ef7bba0cae4b4648a5d764540 (patch)
tree484d505ba6b2330e2831644db5a23294ffab93d0 /src/pkgdev
parentbugs: improve error output (diff)
downloadpkgdev-45e2a7c1d0ce8e9ef7bba0cae4b4648a5d764540.tar.gz
pkgdev-45e2a7c1d0ce8e9ef7bba0cae4b4648a5d764540.tar.bz2
pkgdev-45e2a7c1d0ce8e9ef7bba0cae4b4648a5d764540.zip
argparse: better handling of ~/.bugzrc
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
Diffstat (limited to 'src/pkgdev')
-rw-r--r--src/pkgdev/scripts/argparsers.py10
1 files 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())