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.
98 lines
3.4 KiB
Python
98 lines
3.4 KiB
Python
import os
|
|
import gamesort,skeleton
|
|
from datetime import datetime,timedelta
|
|
|
|
"""
|
|
Generates history page
|
|
"""
|
|
|
|
def history(local=False):
|
|
# delete existing file
|
|
if os.path.exists("build/history/index.html"):
|
|
os.remove("build/history/index.html")
|
|
# write header
|
|
skeleton.headerwrite("build/history/index.html","history",local)
|
|
output = "build/history/index.html"
|
|
filewrite = open(output, "a")
|
|
|
|
theyear = int(gamesort.thisyear)
|
|
while theyear > 2016:
|
|
added = 0
|
|
started = 0
|
|
beat = 0
|
|
completed = 0
|
|
beatorcompleted = 0
|
|
for game in gamesort.games:
|
|
if game["initialdate"].year == theyear:
|
|
added += 1
|
|
try:
|
|
if game["firstplayed"].year == theyear:
|
|
started += 1
|
|
except:
|
|
pass
|
|
try:
|
|
if game["beaten"].year == theyear:
|
|
beat += 1
|
|
beatorcompleted += 1
|
|
try:
|
|
if game["completed"].year == theyear:
|
|
completed += 1
|
|
except:
|
|
pass
|
|
except:
|
|
try:
|
|
if game["completed"].year == theyear:
|
|
completed += 1
|
|
beatorcompleted += 1
|
|
except:
|
|
pass
|
|
backlog = added - beatorcompleted
|
|
print(str(theyear) + " Summary")
|
|
if backlog > 0:
|
|
print("Backlog ▲ " + str(backlog))
|
|
elif backlog == 0:
|
|
print("Backlog 0")
|
|
elif backlog < 0:
|
|
print("Backlog ▼ " + str(backlog * -1))
|
|
print("Added " + str(added))
|
|
print("Started " + str(started))
|
|
print("Beat " + str(beat))
|
|
print("Completed " + str(completed))
|
|
yearlist = []
|
|
enddate = datetime.strptime((str(theyear) + "-12-31"),"%Y-%m-%d")
|
|
startdate = datetime.strptime((str(theyear) + "-01-01"),"%Y-%m-%d")
|
|
eachdate = enddate
|
|
while eachdate >= startdate:
|
|
for game in gamesort.games:
|
|
if game["initialdate"] == eachdate:
|
|
yearlist.append({"date":eachdate,"name":game["name"],"console":game["console"],"action":"Added"})
|
|
try:
|
|
if game["firstplayed"] == eachdate:
|
|
yearlist.append({"date":eachdate,"name":game["name"],"console":game["console"],"action":"Started"})
|
|
except:
|
|
pass
|
|
try:
|
|
if game["beaten"] == eachdate:
|
|
yearlist.append({"date":eachdate,"name":game["name"],"console":game["console"],"action":"Beat"})
|
|
except:
|
|
pass
|
|
try:
|
|
if game["completed"] == eachdate:
|
|
yearlist.append({"date":eachdate,"name":game["name"],"console":game["console"],"action":"Completed"})
|
|
except:
|
|
pass
|
|
eachdate -= timedelta(days=1)
|
|
checkdate = enddate
|
|
for event in yearlist:
|
|
if checkdate != event["date"]:
|
|
print(event["date"].strftime("%Y-%m-%d"))
|
|
print(event["action"] + ": " + event["name"] + " (" + event["console"] + ")")
|
|
checkdate = event["date"]
|
|
theyear -= 1
|
|
|
|
filewrite.close()
|
|
skeleton.footerwrite("build/history/index.html")
|
|
|
|
if __name__ == "__main__":
|
|
history(True)
|