Rebuild in modular fashion
This commit is contained in:
parent
cfd5b0ca34
commit
3b5cb360d5
28 changed files with 1238 additions and 694 deletions
40
library.py
Normal file
40
library.py
Normal file
|
@ -0,0 +1,40 @@
|
|||
import os
|
||||
import cardstring,gamesort,skeleton
|
||||
|
||||
"""
|
||||
Generates library page
|
||||
"""
|
||||
|
||||
def library(local=False):
|
||||
# delete existing file
|
||||
if not os.path.isdir("build/library"):
|
||||
os.mkdir("build/library")
|
||||
if os.path.exists("build/library/index.html"):
|
||||
os.remove("build/library/index.html")
|
||||
# write header
|
||||
skeleton.headerwrite("build/library/index.html","library",local)
|
||||
output = "build/library/index.html"
|
||||
filewrite = open(output, "a")
|
||||
filewrite.write(" <section id=\"library-top\" class=\"library\">\n <div>\n <div class=\"unibar\">\n <div>\n <span>Total Found</span> " + str(gamesort.total(gamesort.games)) + "\n </div>\n")
|
||||
if gamesort.unplayed(gamesort.games) > 0:
|
||||
filewrite.write(" <div class=\"unplayed\" style=\"flex: " + str(gamesort.unplayed(gamesort.games)) + " 1 0%;\">" + str(gamesort.unplayed(gamesort.games)) + "</div>\n")
|
||||
if gamesort.unfinished(gamesort.games) > 0:
|
||||
filewrite.write(" <div class=\"unfinished\" style=\"flex: " + str(gamesort.unfinished(gamesort.games)) + " 1 0%;\">" + str(gamesort.unfinished(gamesort.games)) + "</div>\n")
|
||||
if gamesort.beaten(gamesort.games) > 0:
|
||||
filewrite.write(" <div class=\"beaten\" style=\"flex: " + str(gamesort.beaten(gamesort.games)) + " 1 0%;\">" + str(gamesort.beaten(gamesort.games)) + "</div>\n")
|
||||
if gamesort.completed(gamesort.games) > 0:
|
||||
filewrite.write(" <div class=\"completed\" style=\"flex: " + str(gamesort.completed(gamesort.games)) + " 1 0%;\">" + str(gamesort.completed(gamesort.games)) + "</div>\n")
|
||||
if gamesort.endless(gamesort.games) > 0:
|
||||
filewrite.write(" <div class=\"endless\" style=\"flex: " + str(gamesort.endless(gamesort.games)) + " 1 0%;\">" + str(gamesort.endless(gamesort.games)) + "</div>\n")
|
||||
filewrite.write(" </div>\n <div class=\"library-list sorted\">\n")
|
||||
|
||||
newgames = sorted(gamesort.games,key=lambda d: d["id"])
|
||||
|
||||
for game in newgames:
|
||||
filewrite.write(cardstring.playcard(game,local))
|
||||
|
||||
filewrite.close()
|
||||
skeleton.footerwrite("build/library/index.html")
|
||||
|
||||
if __name__ == "__main__":
|
||||
library(True)
|
Loading…
Add table
Add a link
Reference in a new issue