You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
100 lines
3.4 KiB
Python
100 lines
3.4 KiB
Python
import datetime,os
|
|
import log,skel,tcgcore,variables
|
|
|
|
def crayonlog(colour,event):
|
|
crayonno = event["crayons"][colour]
|
|
if variables.british:
|
|
if colour == "gray":
|
|
crayonrend = "grey"
|
|
else:
|
|
crayonrend = colour
|
|
else:
|
|
crayonrend = colour
|
|
if crayonno > 0:
|
|
crayonstring = "+" + str(crayonno) + " " + crayonrend
|
|
else:
|
|
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"
|
|
skel.headerwrite(thefile,"log")
|
|
content = open(thefile,"a")
|
|
content.write("<h1>log</h1>\n")
|
|
thelog = log.log[::-1]
|
|
for event in thelog:
|
|
content.write("<p><code>" + event["date"].strftime("%Y-%m-%d") + "</code> <a href=\"" + event["url"] + "\">[" + event["event"] + "]</a>: ")
|
|
try:
|
|
if event["received"]:
|
|
content.write("Received ")
|
|
receivedlist = sorted(event["received"])
|
|
for card in receivedlist:
|
|
content.write(tcgcore.cardtext(card))
|
|
if receivedlist.index(card) != len(receivedlist) - 1:
|
|
content.write(", ")
|
|
content.write(".")
|
|
except:
|
|
pass
|
|
try:
|
|
if event["crayons"]:
|
|
content.write("Crayons: ")
|
|
try:
|
|
content.write(crayonlog("red",event))
|
|
if list(event["crayons"])[-1] != "red":
|
|
content.write(", ")
|
|
except:
|
|
pass
|
|
try:
|
|
content.write(crayonlog("orange",event))
|
|
if list(event["crayons"])[-1] != "orange":
|
|
content.write(", ")
|
|
except:
|
|
pass
|
|
try:
|
|
content.write(crayonlog("yellow",event))
|
|
if list(event["crayons"])[-1] != "yellow":
|
|
content.write(", ")
|
|
except:
|
|
pass
|
|
try:
|
|
content.write(crayonlog("green",event))
|
|
if list(event["crayons"])[-1] != "green":
|
|
content.write(", ")
|
|
except:
|
|
pass
|
|
try:
|
|
content.write(crayonlog("blue",event))
|
|
if list(event["crayons"])[-1] != "blue":
|
|
content.write(", ")
|
|
except:
|
|
pass
|
|
try:
|
|
content.write(crayonlog("purple",event))
|
|
if list(event["crayons"])[-1] != "purple":
|
|
content.write(", ")
|
|
except:
|
|
pass
|
|
try:
|
|
content.write(crayonlog("brown",event))
|
|
if list(event["crayons"])[-1] != "brown":
|
|
content.write(", ")
|
|
except:
|
|
pass
|
|
try:
|
|
content.write(crayonlog("gray",event))
|
|
except:
|
|
pass
|
|
content.write(".")
|
|
except:
|
|
pass
|
|
content.write("</p>\n")
|
|
content.close()
|
|
skel.footerwrite(thefile)
|
|
|
|
if __name__ == "__main__":
|
|
loggen()
|