Skip to content

Commit d696dec

Browse files
Break analysis into snippets (#17)
1 parent d38e363 commit d696dec

12 files changed

Lines changed: 639 additions & 612 deletions

devstats/publish.py

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,33 @@
11
import os
22
import sys
33
from glob import glob
4+
from pathlib import Path
45

56

67
def publisher(project):
8+
print(f"Generating {project} report...", end="")
9+
basedir = os.path.dirname(__file__)
10+
with open(os.path.join(basedir, "template.md")) as fh:
11+
template = fh.read()
12+
13+
issues = glob(os.path.join(basedir, "reports/issues/*.md"))
14+
for issue in issues:
15+
with open(issue) as fh:
16+
issue_text = fh.read()
17+
issue_name = Path(issue).stem
18+
template = template.replace(f"{{{{ {issue_name} }}}}", issue_text)
19+
20+
prs = glob(os.path.join(basedir, "reports/pull_requests/*.md"))
21+
for pr in prs:
22+
with open(pr) as fh:
23+
pr_text = fh.read()
24+
pr_name = Path(pr).stem
25+
template = template.replace(f"{{{{ {pr_name} }}}}", pr_text)
26+
27+
template = template.replace("{{ project }}", project)
28+
729
os.makedirs("_generated", exist_ok=True)
8-
report_files = glob(os.path.join(os.path.dirname(__file__), "reports/*.md"))
30+
with open(f"_generated/{project}.md", "w") as fh:
31+
fh.write(template)
932

10-
for report in report_files:
11-
print(f"Generating {project} report...", end="")
12-
with open(report) as fh:
13-
template = fh.read()
14-
with open(f"_generated/{project}.md", "w") as fh:
15-
fh.write(template.replace("{{ project }}", project))
16-
print("OK")
33+
print("OK")

0 commit comments

Comments
 (0)