Skip to content

Commit b964f0b

Browse files
mbolivar-nordicMaureenHelm
authored andcommitted
scripts: add dump_bugs_pickle.py
This prints the contents of a zephyr-bugs-$DATE.pickle file in a format similar to the output of list_issues.py. It will be useful to have this in tree so that we can better record the known issues at the time of a particular zephyr release. The pickle file itself should be created using the bug snapshot workflow defined in .github/workflows/bug_snapshot.yaml, which can be triggered manually from this URL: https://github.com/zephyrproject-rtos/zephyr/actions/workflows/bug_snapshot.yaml Signed-off-by: Martí Bolívar <[email protected]>
1 parent 3c9e977 commit b964f0b

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

scripts/dump_bugs_pickle.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env python3
2+
3+
# Copyright (c) 2022 Nordic Semiconductor ASA
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
7+
# stdlib
8+
import argparse
9+
import pickle
10+
from pathlib import Path
11+
from typing import List
12+
13+
# third party
14+
from github.Issue import Issue
15+
16+
def parse_args() -> argparse.Namespace:
17+
parser = argparse.ArgumentParser(
18+
formatter_class=argparse.RawDescriptionHelpFormatter)
19+
20+
parser.add_argument('pickle_file', metavar='PICKLE-FILE', type=Path,
21+
help='pickle file containing list of issues')
22+
23+
return parser.parse_args()
24+
25+
def issue_has_label(issue: Issue, label: str) -> bool:
26+
for lbl in issue.labels:
27+
if lbl.name == label:
28+
return True
29+
return False
30+
31+
def is_open_bug(issue: Issue) -> bool:
32+
return (issue.pull_request is None and
33+
issue.state == 'open' and
34+
issue_has_label(issue, 'bug'))
35+
36+
def get_bugs(args: argparse.Namespace) -> List[Issue]:
37+
'''Get the bugs to use for analysis, given command line arguments.'''
38+
with open(args.pickle_file, 'rb') as f:
39+
return [issue for issue in pickle.load(f) if
40+
is_open_bug(issue)]
41+
42+
def main() -> None:
43+
args = parse_args()
44+
bugs = get_bugs(args)
45+
for bug in sorted(bugs, key=lambda bug: bug.number):
46+
print(f'- :github:`{bug.number}` - {bug.title}')
47+
48+
if __name__ == '__main__':
49+
main()

0 commit comments

Comments
 (0)