Skip to content

Commit 0a1c70e

Browse files
committed
bugs: fallback to ~/.bugz_token for api-key
Resolves: #138 Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
1 parent f5b9550 commit 0a1c70e

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/pkgdev/scripts/pkgdev_bugs.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
"""Automatic bugs filer"""
22

3+
import contextlib
34
import json
45
import sys
56
import urllib.request as urllib
67
from collections import defaultdict
78
from functools import partial
89
from itertools import chain
10+
from pathlib import Path
911
from urllib.parse import urlencode
1012

1113
from pkgcheck import const as pkgcheck_const
@@ -508,6 +510,10 @@ def main(options, out: Formatter, err: Formatter):
508510
for node in d.nodes:
509511
node.cleanup_keywords(search_repo)
510512

513+
if options.api_key is None:
514+
with contextlib.suppress(Exception):
515+
options.api_key = (Path.home() / ".bugz_token").read_text().strip() or None
516+
511517
if userquery("Check for open bugs matching current graph?", out, err, default_answer=False):
512518
d.scan_existing_bugs(options.api_key)
513519

0 commit comments

Comments
 (0)