Fully working version (?)
This commit is contained in:
parent
4176cb113f
commit
9fe7dad24f
10 changed files with 474 additions and 196 deletions
150
history.py
150
history.py
|
@ -1,5 +1,5 @@
|
|||
import os
|
||||
import gamesort,skeleton
|
||||
import gamesort,skeleton,variables
|
||||
from datetime import datetime,timedelta
|
||||
|
||||
"""
|
||||
|
@ -8,6 +8,8 @@ Generates history page
|
|||
|
||||
def history(local=False):
|
||||
# delete existing file
|
||||
if not os.path.isdir("build/history"):
|
||||
os.mkdir("build/history")
|
||||
if os.path.exists("build/history/index.html"):
|
||||
os.remove("build/history/index.html")
|
||||
# write header
|
||||
|
@ -15,49 +17,10 @@ def history(local=False):
|
|||
output = "build/history/index.html"
|
||||
filewrite = open(output, "a")
|
||||
|
||||
filewrite.write(" <section class=\"history\">\n <div class=\"list\">\n")
|
||||
|
||||
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")
|
||||
|
@ -84,12 +47,111 @@ def history(local=False):
|
|||
eachdate -= timedelta(days=1)
|
||||
checkdate = enddate
|
||||
for event in yearlist:
|
||||
filewrite.write(" <div>\n")
|
||||
if checkdate != event["date"]:
|
||||
print(event["date"].strftime("%Y-%m-%d"))
|
||||
print(event["action"] + ": " + event["name"] + " (" + event["console"] + ")")
|
||||
filewrite.write(" <h2>" + event["date"].strftime("%Y-%m-%d") + "</h2>\n")
|
||||
filewrite.write(" <div>\n <div> " + event["action"] + "\n <div class=\"status-dot ")
|
||||
if event["action"] == "Started":
|
||||
fullpath = str(event["name"] + " (" + event["console"] + ")")
|
||||
if fullpath in variables.endlessgames:
|
||||
filewrite.write("Endless")
|
||||
else:
|
||||
filewrite.write("Started")
|
||||
else:
|
||||
filewrite.write(event["action"])
|
||||
filewrite.write("\"></div>\n </div>\n <div> " + event["name"] + "\n <span>(" + event["console"] + ")</span>\n </div>\n </div>\n </div>\n")
|
||||
checkdate = event["date"]
|
||||
theyear -= 1
|
||||
|
||||
filewrite.write(" </div>\n")
|
||||
|
||||
theyear = int(gamesort.thisyear)
|
||||
filewrite.write(" <div class=\"side box_1\">\n")
|
||||
while theyear > 2016:
|
||||
yeargames = 0
|
||||
yearplaying = 0
|
||||
for game in gamesort.games:
|
||||
if game["initialdate"].year == theyear:
|
||||
try:
|
||||
if game["gameplay"]:
|
||||
if game["id"] not in variables.endlessgames:
|
||||
yeargames += 1
|
||||
except:
|
||||
yeargames += 1
|
||||
for game in gamesort.games:
|
||||
try:
|
||||
if game["beaten"].year == theyear:
|
||||
yeargames -= 1
|
||||
except:
|
||||
try:
|
||||
if game["completed"].year == theyear:
|
||||
yeargames -= 1
|
||||
except:
|
||||
pass
|
||||
|
||||
yearbacklog = []
|
||||
for game in gamesort.games:
|
||||
try:
|
||||
if game["completed"].year == theyear:
|
||||
yearbacklog.append(game)
|
||||
except:
|
||||
try:
|
||||
if game["beaten"].year == theyear:
|
||||
yearbacklog.append(game)
|
||||
except:
|
||||
if game["initialdate"].year == theyear:
|
||||
yearbacklog.append(game)
|
||||
|
||||
yearcompleted = 0
|
||||
yearbeaten = 0
|
||||
yearstarted = 0
|
||||
yearadded = 0
|
||||
yeartotal = len(yearbacklog)
|
||||
if yeartotal > 0:
|
||||
for game in yearbacklog:
|
||||
try:
|
||||
if game["initialdate"].year == theyear:
|
||||
yearadded += 1
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
if game["firstplayed"].year == theyear:
|
||||
yearstarted += 1
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
if game["completed"].year == theyear:
|
||||
yearcompleted += 1
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
if game["beaten"].year == theyear:
|
||||
yearbeaten += 1
|
||||
except:
|
||||
pass
|
||||
|
||||
compare = []
|
||||
compare.append(yearadded)
|
||||
compare.append(yearstarted)
|
||||
compare.append(yearbeaten)
|
||||
compare.append(yearcompleted)
|
||||
maxvalue = max(compare)
|
||||
|
||||
filewrite.write(" <div class=\"year-tally")
|
||||
if theyear == int(gamesort.thisyear):
|
||||
filewrite.write(" active")
|
||||
filewrite.write("\">\n <h2> " + str(theyear) + " Summary\n <span>Backlog ")
|
||||
if yeargames > 0:
|
||||
filewrite.write("▲ " + str(yeargames))
|
||||
elif yeargames == 0:
|
||||
filewrite.write(" 0")
|
||||
elif yeargames < 0:
|
||||
filewrite.write("▼ " + str(yeargames * -1))
|
||||
filewrite.write("</span></h2>\n <div>\n <div>Added</div>\n <div>" + str(yearadded) + "</div>\n <div>\n <div class=\"unplayed\" style=\"width: calc(95% * (" + str(yearadded) + " / " + str(maxvalue) + "));\">\n </div>\n </div>\n </div>\n <div>\n <div>Started</div>\n <div>" + str(yearstarted) + "</div>\n <div>\n <div class=\"unfinished\" style=\"width: calc(95% * (" + str(yearstarted) + " / " + str(maxvalue) + "));\">\n </div>\n </div>\n </div>\n <div>\n <div>Beat</div>\n <div>" + str(yearbeaten) + "</div>\n <div>\n <div class=\"beaten\" style=\"width: calc(95% * (" + str(yearbeaten) + " / " + str(maxvalue) + "));\">\n </div>\n </div>\n </div>\n <div>\n <div>Completed</div>\n <div>" + str(yearcompleted) + "</div>\n <div>\n <div class=\"completed\" style=\"width: calc(95% * (" + str(yearcompleted) + " / " + str(maxvalue) + "));\">\n </div>\n </div>\n </div>\n </div>\n")
|
||||
theyear -= 1
|
||||
|
||||
filewrite.write(" </div>\n </section>\n")
|
||||
|
||||
filewrite.close()
|
||||
skeleton.footerwrite("build/history/index.html")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue