commit: 0a1c70e0f501f6cdda4cef3cd9940c2f5dac8ada Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org> AuthorDate: Fri May 5 17:49:16 2023 +0000 Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org> CommitDate: Fri May 5 17:49:16 2023 +0000 URL: https://gitweb.gentoo.org/proj/pkgcore/pkgdev.git/commit/?id=0a1c70e0
bugs: fallback to `~/.bugz_token` for api-key Resolves: https://github.com/pkgcore/pkgdev/issues/138 Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org> src/pkgdev/scripts/pkgdev_bugs.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pkgdev/scripts/pkgdev_bugs.py b/src/pkgdev/scripts/pkgdev_bugs.py index 8c79ac6..e2eaf33 100644 --- a/src/pkgdev/scripts/pkgdev_bugs.py +++ b/src/pkgdev/scripts/pkgdev_bugs.py @@ -1,11 +1,13 @@ """Automatic bugs filer""" +import contextlib import json import sys import urllib.request as urllib from collections import defaultdict from functools import partial from itertools import chain +from pathlib import Path from urllib.parse import urlencode from pkgcheck import const as pkgcheck_const @@ -508,6 +510,10 @@ def main(options, out: Formatter, err: Formatter): for node in d.nodes: node.cleanup_keywords(search_repo) + if options.api_key is None: + with contextlib.suppress(Exception): + options.api_key = (Path.home() / ".bugz_token").read_text().strip() or None + if userquery("Check for open bugs matching current graph?", out, err, default_answer=False): d.scan_existing_bugs(options.api_key)
