cppyabm  1.0.17
An agent-based library to integrate C++ and Python
make_changelog.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 import re
5 
6 import ghapi.all
7 
8 from rich import print
9 from rich.syntax import Syntax
10 
11 
12 ENTRY = re.compile(
13  r"""
14  Suggested \s changelog \s entry:
15  .*
16  ```rst
17  \s*
18  (.*?)
19  \s*
20  ```
21 """,
22  re.DOTALL | re.VERBOSE,
23 )
24 
25 print()
26 
27 
28 api = ghapi.all.GhApi(owner="pybind", repo="pybind11")
29 
30 issues = api.issues.list_for_repo(labels="needs changelog", state="closed")
31 missing = []
32 
33 for issue in issues:
34  changelog = ENTRY.findall(issue.body)
35  if changelog:
36  (msg,) = changelog
37  if not msg.startswith("* "):
38  msg = "* " + msg
39  if not msg.endswith("."):
40  msg += "."
41 
42  msg += f"\n `#{issue.number} <{issue.html_url}>`_"
43 
44  print(Syntax(msg, "rst", theme="ansi_light"))
45  print()
46 
47  else:
48  missing.append(issue)
49 
50 if missing:
51  print()
52  print("[blue]" + "-" * 30)
53  print()
54 
55  for issue in missing:
56  print(f"[red bold]Missing:[/red bold][red] {issue.title}")
57  print(f"[red] {issue.html_url}\n")
58 
59  print("[bold]Template:\n")
60  msg = "## Suggested changelog entry:\n\n```rst\n\n```"
61  print(Syntax(msg, "md", theme="ansi_light"))
62 
63 print()
print
PYBIND11_NOINLINE void print(tuple args, dict kwargs)
Definition: pybind11.h:2056