|
| 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