Enable narrowing log to current month

master
trémeur 3 days ago
parent b1f90124c6
commit e05eb19ae9

@ -19,9 +19,9 @@ ownedgen.ownedall()
print(" done\nBuilding wanted page …",end="") print(" done\nBuilding wanted page …",end="")
sys.stdout.flush() sys.stdout.flush()
wantedgen.wantedgen() wantedgen.wantedgen()
print(" done\nBuilding log page",end="") print(" done\nBuilding log pages",end="")
sys.stdout.flush() sys.stdout.flush()
loggen.loggen() loggen.logall()
print(" done\nBuilding levels page …",end="") print(" done\nBuilding levels page …",end="")
sys.stdout.flush() sys.stdout.flush()
levelsgen.levelsgen() levelsgen.levelsgen()

@ -16,7 +16,14 @@ def crayonlog(colour,event):
crayonstring = str(crayonno) + " " + crayonrend crayonstring = str(crayonno) + " " + crayonrend
return crayonstring return crayonstring
def loggen(): def loggen(month=False):
if month:
if not os.path.isdir("build/log/month"):
os.mkdir("build/log/month")
if os.path.exists("build/log/month/index.html"):
os.remove("build/log/month/index.html")
thefile = "build/log/month/index.html"
else:
if not os.path.isdir("build/log"): if not os.path.isdir("build/log"):
os.mkdir("build/log") os.mkdir("build/log")
if os.path.exists("build/log/index.html"): if os.path.exists("build/log/index.html"):
@ -25,6 +32,17 @@ def loggen():
skel.headerwrite(thefile,"log") skel.headerwrite(thefile,"log")
content = open(thefile,"a") content = open(thefile,"a")
content.write("<h1>log</h1>\n") content.write("<h1>log</h1>\n")
if month:
content.write("<p><a href=\"/log\">Show all</a></p>\n")
else:
content.write("<p><a href=\"/log/month\">Show current month only</a></p>\n")
if month:
thelog = []
for event in log.log:
if event["date"].month == datetime.datetime.now().month and event["date"].year == datetime.datetime.now().year:
thelog.append(event)
thelog = thelog[::-1]
else:
thelog = log.log[::-1] thelog = log.log[::-1]
for event in thelog: for event in thelog:
if event["event"] != "portfolio": if event["event"] != "portfolio":
@ -125,5 +143,9 @@ def loggen():
content.close() content.close()
skel.footerwrite(thefile) skel.footerwrite(thefile)
def logall():
loggen(False)
loggen(True)
if __name__ == "__main__": if __name__ == "__main__":
loggen() logall()

Loading…
Cancel
Save