From e05eb19ae9078a68ec7bd7f666468f504a4c93b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?tr=C3=A9meur?= Date: Mon, 18 Nov 2024 20:24:35 +0000 Subject: [PATCH] Enable narrowing log to current month --- generate.py | 4 ++-- loggen.py | 38 ++++++++++++++++++++++++++++++-------- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/generate.py b/generate.py index 4d57a41..8a8db3d 100644 --- a/generate.py +++ b/generate.py @@ -19,9 +19,9 @@ ownedgen.ownedall() print(" done\nBuilding wanted page …",end="") sys.stdout.flush() wantedgen.wantedgen() -print(" done\nBuilding log page …",end="") +print(" done\nBuilding log pages …",end="") sys.stdout.flush() -loggen.loggen() +loggen.logall() print(" done\nBuilding levels page …",end="") sys.stdout.flush() levelsgen.levelsgen() diff --git a/loggen.py b/loggen.py index 2c761e8..aa06953 100644 --- a/loggen.py +++ b/loggen.py @@ -16,16 +16,34 @@ def crayonlog(colour,event): crayonstring = str(crayonno) + " " + crayonrend return crayonstring -def loggen(): - if not os.path.isdir("build/log"): - os.mkdir("build/log") - if os.path.exists("build/log/index.html"): - os.remove("build/log/index.html") - thefile = "build/log/index.html" +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"): + os.mkdir("build/log") + if os.path.exists("build/log/index.html"): + os.remove("build/log/index.html") + thefile = "build/log/index.html" skel.headerwrite(thefile,"log") content = open(thefile,"a") content.write("

log

\n") - thelog = log.log[::-1] + if month: + content.write("

Show all

\n") + else: + content.write("

Show current month only

\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] for event in thelog: if event["event"] != "portfolio": content.write("

" + event["date"].strftime("%Y-%m-%d") + " [" + event["event"] + "]: ") @@ -125,5 +143,9 @@ def loggen(): content.close() skel.footerwrite(thefile) +def logall(): + loggen(False) + loggen(True) + if __name__ == "__main__": - loggen() + logall()