Martí Bolívar | b964f0b | 2022-06-03 12:12:15 -0700 | [diff] [blame] | 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( |
Jamie McCrae | ec70444 | 2023-01-04 16:08:36 +0000 | [diff] [blame] | 18 | formatter_class=argparse.RawDescriptionHelpFormatter, allow_abbrev=False) |
Martí Bolívar | b964f0b | 2022-06-03 12:12:15 -0700 | [diff] [blame] | 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): |
Fabio Baltieri | d43e4e9 | 2022-09-27 15:52:15 +0000 | [diff] [blame] | 46 | title = bug.title.strip() |
| 47 | print(f'- :github:`{bug.number}` - {title}') |
Martí Bolívar | b964f0b | 2022-06-03 12:12:15 -0700 | [diff] [blame] | 48 | |
| 49 | if __name__ == '__main__': |
| 50 | main() |