blob: 732ba7ca89e58a542c3aeb337d1ec8ab9ec18dd7 [file] [log] [blame]
Martí Bolívarb964f0b2022-06-03 12:12:15 -07001#!/usr/bin/env python3
2
3# Copyright (c) 2022 Nordic Semiconductor ASA
4#
5# SPDX-License-Identifier: Apache-2.0
6
7# stdlib
8import argparse
9import pickle
10from pathlib import Path
11from typing import List
12
13# third party
14from github.Issue import Issue
15
16def parse_args() -> argparse.Namespace:
17 parser = argparse.ArgumentParser(
Jamie McCraeec704442023-01-04 16:08:36 +000018 formatter_class=argparse.RawDescriptionHelpFormatter, allow_abbrev=False)
Martí Bolívarb964f0b2022-06-03 12:12:15 -070019
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
25def 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
31def 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
36def 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
42def main() -> None:
43 args = parse_args()
44 bugs = get_bugs(args)
45 for bug in sorted(bugs, key=lambda bug: bug.number):
Fabio Baltierid43e4e92022-09-27 15:52:15 +000046 title = bug.title.strip()
47 print(f'- :github:`{bug.number}` - {title}')
Martí Bolívarb964f0b2022-06-03 12:12:15 -070048
49if __name__ == '__main__':
50 main()