()
| 18 | |
| 19 | |
| 20 | def main(): |
| 21 | p = argparse.ArgumentParser(usage=__doc__.lstrip()) |
| 22 | p.add_argument('--project', default='PyWavelets/pywt') |
| 23 | p.add_argument('milestone') |
| 24 | args = p.parse_args() |
| 25 | |
| 26 | getter = CachedGet('gh_cache.json', GithubGet()) |
| 27 | try: |
| 28 | milestones = get_milestones(getter, args.project) |
| 29 | if args.milestone not in milestones: |
| 30 | msg = "Milestone {0} not available. Available milestones: {1}" |
| 31 | msg = msg.format(args.milestone, ", ".join(sorted(milestones))) |
| 32 | p.error(msg) |
| 33 | issues = get_issues(getter, args.project, args.milestone) |
| 34 | issues.sort() |
| 35 | finally: |
| 36 | getter.save() |
| 37 | |
| 38 | prs = [x for x in issues if '/pull/' in x.url] |
| 39 | issues = [x for x in issues if x not in prs] |
| 40 | |
| 41 | def print_list(title, items): |
| 42 | print() |
| 43 | print(title) |
| 44 | print("-"*len(title)) |
| 45 | print() |
| 46 | |
| 47 | for issue in items: |
| 48 | msg = "* `#{0} <{1}>`__: {2}" |
| 49 | # sanitize whitespace, `, and * |
| 50 | title = re.sub("\\s+", " ", issue.title.strip()) |
| 51 | title = title.replace('`', '\\`').replace('*', '\\*') |
| 52 | if len(title) > 60: |
| 53 | remainder = re.sub("\\s.*$", "...", title[60:]) |
| 54 | if len(remainder) > 20: |
| 55 | remainder = title[:80] + "..." |
| 56 | else: |
| 57 | title = title[:60] + remainder |
| 58 | msg = msg.format(issue.id, issue.url, title) |
| 59 | print(msg) |
| 60 | print() |
| 61 | |
| 62 | msg = f"Issues closed for {args.milestone}" |
| 63 | print_list(msg, issues) |
| 64 | |
| 65 | msg = f"Pull requests for {args.milestone}" |
| 66 | print_list(msg, prs) |
| 67 | |
| 68 | return 0 |
| 69 | |
| 70 | |
| 71 | def get_milestones(getter, project): |
no test coverage detected