-
Notifications
You must be signed in to change notification settings - Fork 0
/
mkreport.py
50 lines (37 loc) · 1.43 KB
/
mkreport.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import sys
from datetime import datetime, timezone
with open('Directory') as f:
directory = f.read()
with open('WarningsAndErrors') as f:
warnlog = f.read()
now = datetime.now(timezone.utc)
# How many months listed (including this one)
history_len = 2
changelogs = []
# Find previous months and years specified by history_len.
for i in range(history_len):
month = (now.month - i) % 12
years_back = 0
if i >= now.month:
years_back = (i // 12) + 1
if month == 0:
month = 12
cl_filename = "changelogs/" + str(now.year - years_back) + "-" + str(month).zfill(2) + ".txt"
with open(cl_filename) as f:
changelogs.append(f.read())
timestamp = (str(now.month).zfill(2) + "/" + str(now.day).zfill(2) + "/" + str(now.year) + " " + str(now.hour).zfill(2) + ":" + str(now.minute).zfill(2))
preamble = "Welcome! This is the Webmastor's homepage, currently maintained by the inaugural Agoran Webmastor, nix. Below is a 'live' version of the Webmastor's report."
with open('docs/index.md', 'w') as f:
f.write(preamble + "\n" + "\n")
f.write("**Last Updated: " + timestamp + " (UTC)**\n\n")
f.write(directory)
f.write("\n")
f.write(warnlog)
f.write("\n")
f.write("+---------+\n")
f.write("|Changelog|\n")
f.write("+---------+\n\n")
# TODO: Add link to full changelog and autogenerate it
for i in changelogs:
f.write(i)
f.write("\n")