From 84161b76126537fbdcc3e1c79d52daa8b3179c44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?tr=C3=A9meur?= Date: Mon, 12 Jun 2023 18:58:08 +0100 Subject: [PATCH] Add code for building stats pages --- .gitignore | 3 +- build/fic4.css | 157 +++++++++++ build/stats/.gitkeep | 0 generate.py | 3 + statsgen.py | 658 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 820 insertions(+), 1 deletion(-) create mode 100644 build/fic4.css create mode 100644 build/stats/.gitkeep create mode 100644 statsgen.py diff --git a/.gitignore b/.gitignore index 5145293..3ea2f47 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,5 @@ texts/* !texts/.gitkeep translationsmeta/* !translationsmeta/__init__.py -!translationsmeta/template.py \ No newline at end of file +!translationsmeta/template.py +build/stats/*/index.html \ No newline at end of file diff --git a/build/fic4.css b/build/fic4.css new file mode 100644 index 0000000..f3cdb99 --- /dev/null +++ b/build/fic4.css @@ -0,0 +1,157 @@ +/* ----- COLOURS ----- */ + +body, details > summary::marker { + color: #222; +} + +body { + background-color: white; +} + +a, a:link, a:hover, a:visited, a:active, h1, h2, h3, details > summary { + color: var(--colourone); +} + +li:before { + color: #9e9e9e; +} + +details, blockquote { + border: 2px solid var(--colourone); + box-shadow: 8px 8px 0px var(--colourone); +} + +body { + font-family: 'Lato', sans-serif; + font-size: 13px; word-wrap: break-word; +} + +img { + max-width: 100%; +} + +a, a:link, a:hover, a:visited, a:active { + text-decoration: none; +} + +a:hover { + border-bottom: 1px solid; +} + +/* ---- BOXES ---- */ + +details > summary { + cursor: pointer; + font-weight: bold; +} + +details, blockquote { + padding: 20px; + margin-bottom: 15px !important; +} + +blockquote { + max-width: 100%; + min-width: 10%; + display: inline-block; +} + +blockquote p, details p { + margin: 0; + padding: 0; +} + +blockquote ul { + margin-top: 0; + margin-bottom: 0; +} + +blockquote > * + *, details > * + * { + margin-top: 20px !important; +} + +/* ---- CONTENT ---- */ + +@media only screen and (min-width: 900px) { + + div#site-wrapper { + width: 90%; + margin: 1em auto; + } +} + +@media only screen and (max-width: 900px) { + + div#site-wrapper { + width: 99%; margin: 1em auto; + } +} + +input, select { + background-color: white; + font-family: 'Lato', sans-serif; +} + +textarea { + font-family: 'Inconsolata', monospace; +} + +code, pre, .timestamp { + background: #f0f0f0; + font-family: 'Inconsolata', monospace !important; +} + +pre { + display: inline-block; + padding: 2px; + max-width: 100%; + overflow: auto; +} + + +ul { + list-style: none; +} + +ul li:before { + content: "+ "; + font-weight: bold; +} + +ol { + list-style: none; + counter-reset: li +} + +ol li:before { + content: counter(li)". "; + font-weight: bold; +} + +ol li { + counter-increment: li; +} + +/* ----- GIFSETS ----- */ + +div.figure { + text-align: center; + padding: 0; +} + +div.figure img { + display: inline; + margin: 5px; +} + +div.figure.oneup img { + width: 90%; +} + +div.figure.twoup img { + width: 40%; +} + +div.figure.threeup img { + width: 30%; +} diff --git a/build/stats/.gitkeep b/build/stats/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/generate.py b/generate.py index 672d644..a13b581 100644 --- a/generate.py +++ b/generate.py @@ -8,6 +8,7 @@ import ships import events import indexgen import verifygen +import statsgen try: if sys.argv[1] == "local": @@ -28,6 +29,7 @@ if __name__ == "__main__": events.eventlist(True) indexgen.indexgen(True) verifygen.verifygen(True) + statsgen.yeargen(True) else: masterlist.listgen() commentpage.allcomments() @@ -37,3 +39,4 @@ if __name__ == "__main__": events.eventlist() indexgen.indexgen() verifygen.verifygen() + statsgen.yeargen() diff --git a/statsgen.py b/statsgen.py new file mode 100644 index 0000000..8f57a41 --- /dev/null +++ b/statsgen.py @@ -0,0 +1,658 @@ +import datetime, os, shutil +from importlib import import_module + +""" +Warning: code in this file is /particularly/ bizarre and non-optimised. +""" + +""" +Write the wee blurb for each fic +""" + +def ficsum(ficcount,year,month=0,showfandom=True,local=False): + if ficcount < 10: + ficcountstring = "00" + str(ficcount) + elif ficcount < 100: + ficcountstring = "0" + str(ficcount) + else: + ficcountstring = str(ficcount) + if os.path.exists("originalsmeta/" + ficcountstring + ".py"): + ficfile = "originalsmeta." + ficcountstring + fileread = import_module(ficfile) + elif os.path.exists("translationsmeta/" + ficcountstring + ".py"): + ficfile = "translationsmeta." + ficcountstring + fileread = import_module(ficfile) + else: + fileread = False + if fileread: + try: + theorig = "originalsmeta." + str(fileread.original) + origfile = import_module(theorig) + except: + pass + try: + fandom = "/".join(origfile.fandom) + except: + fandom = "/".join(fileread.fandom) + try: + if "OW" not in origfile.fandom: + try: + thechars = origfile.ship[0] + except: + chars = [] + try: + chars.extend(origfile.charpov) + except: + pass + try: + chars.extend(origfile.charmain) + except: + pass + if chars != []: + thechars = ", ".join(chars) + else: + thechars = "" + else: + thechars = "" + except: + if "OW" not in fileread.fandom: + try: + thechars = fileread.ship[0] + except: + chars = [] + try: + chars.extend(fileread.charpov) + except: + pass + try: + chars.extend(fileread.charmain) + except: + pass + if chars != []: + thechars = ", ".join(chars) + else: + thechars = "" + else: + thechars = "" + if fileread.language == "fr": + language = "French" + else: + language = "" + try: + rating = origfile.rating + except: + rating = fileread.rating + try: + genre = origfile.genre[0] + except: + genre = fileread.genre[0] + try: + if origfile.warnings: + warnings = "?!" + except: + try: + if fileread.warnings: + warnings = "?!" + except: + warnings = "" + words = 0 + for datewords in fileread.datewords: + if month: + if int((datewords["date"]).year) == year: + if int((datewords["date"]).month) == month: + words += datewords["words"] + else: + if int((datewords["date"]).year) == year: + words += datewords["words"] + ficstring = "" + ficstring += "" + if showfandom: + ficstring += fandom + if thechars or language: + ficstring += ", " + if thechars: + ficstring += thechars + if language: + ficstring += ", " + if language: + ficstring += language + ficstring += "" + if rating == "g": + ficstring += "  G " + elif rating == "t": + ficstring += "  T " + elif rating == "m": + ficstring += "  M " + elif rating == "e": + ficstring += "  E " + if genre == "gen": + ficstring += "  ☉ " + elif genre == "slash" or genre == "pre-slash" or genre == "poly slash": + ficstring += "  ♂ " + elif genre == "het" or genre == "pre-het": + ficstring += "  ⚤ " + elif genre == "femslash": + ficstring += "  ♀ " + elif genre == "poly": + ficstring += "     " + if warnings: + ficstring += "  !? " + ficstring += " " + str(words) + "" + return ficstring + +""" +Generate stats page for each year +""" + +def yeargen(local=False): + yearlist = [] + ficcount = 500 + while ficcount > 0: + ficcount -= 1 + if ficcount < 10: + ficcountstring = "00" + str(ficcount) + elif ficcount < 100: + ficcountstring = "0" + str(ficcount) + else: + ficcountstring = str(ficcount) + if os.path.exists("originalsmeta/" + ficcountstring + ".py"): + ficfile = "originalsmeta." + ficcountstring + fileread = import_module(ficfile) + elif os.path.exists("translationsmeta/" + ficcountstring + ".py"): + ficfile = "translationsmeta." + ficcountstring + fileread = import_module(ficfile) + else: + fileread = False + if fileread: + for date in fileread.datewords: + yearlist.append(date["date"].year) + yearlist = sorted(list(dict.fromkeys(yearlist))) + for year in yearlist: + yearpath = "build/stats/" + str(year) + if not os.path.isdir(yearpath): + os.mkdir(yearpath) + if os.path.exists(yearpath + "/index.html"): + os.remove(yearpath + "/index.html") + filewrite = open(yearpath + "/index.html", "a") + filewrite.write("\n\n\n\n\nFic stats " + str(year) + "\n\n\n\n\n\n
\n

Fic stats for " + str(year) + "

\n") + allfics = [] + ficdeets = [] + datesplit = [] + ficcount = 500 + while ficcount > 0: + ficcount -= 1 + if ficcount < 10: + ficcountstring = "00" + str(ficcount) + elif ficcount < 100: + ficcountstring = "0" + str(ficcount) + else: + ficcountstring = str(ficcount) + if os.path.exists("originalsmeta/" + ficcountstring + ".py"): + ficfile = "originalsmeta." + ficcountstring + fileread = import_module(ficfile) + elif os.path.exists("translationsmeta/" + ficcountstring + ".py"): + ficfile = "translationsmeta." + ficcountstring + fileread = import_module(ficfile) + else: + fileread = False + if fileread: + for date in fileread.datewords: + if (date["date"]).year == year: + allfics.append(ficcountstring) + allfics = sorted(list(dict.fromkeys(allfics))) + for fic in allfics: + if os.path.exists("originalsmeta/" + fic + ".py"): + ficfile = "originalsmeta." + fic + fileread = import_module(ficfile) + elif os.path.exists("translationsmeta/" + fic + ".py"): + ficfile = "translationsmeta." + fic + fileread = import_module(ficfile) + else: + fileread = False + if fileread: + try: + fandom = fileread.fandom + event = fileread.event + eventname = fileread.eventname + try: + eventlocation = fileread.eventlocation + except: + eventlocation = False + except: + try: + if fileread.original: + theorig = "originalsmeta." + str(fileread.original) + origfile = import_module(theorig) + try: + fandom = origfile.fandom + event = origfile.event + eventname = origfile.eventname + try: + eventlocation = fileread.eventlocation + except: + eventlocation = False + except: + event = False + eventname = False + eventlocation = False + except: + event = False + eventname = False + eventlocation = False + ficwords = 0 + for dateword in fileread.datewords: + if (dateword["date"]).year == year: + ficwords = (dateword["words"]) + ficdict = {"number":fic,"words":ficwords,"fandom":fandom,"event":event,"eventname":eventname,"eventlocation":eventlocation,"date":dateword["date"]} + ficdeets.append(ficdict) + datesplit.append(ficdict) + combinedeets = [] + for fic in ficdeets: + if combinedeets == []: + ficlogged = True + combinedeets.append(fic) + else: + ficlogged = False + for newfic in combinedeets: + if ficlogged == False: + if fic["number"] == newfic["number"]: + ficlogged = True + newfic["words"] += fic["words"] + if ficlogged == False: + combinedeets.append(fic) + ficdeets = combinedeets + totalwords = 0 + for fic in ficdeets: + totalwords += fic["words"] + if len(allfics) == 1: + filewrite.write("

Total: " + str(len (allfics)) + " fic, " + str(totalwords) + " words

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

Total: " + str(len (allfics)) + " fics, " + str(totalwords) + " words

") + prompts = [] + for fic in ficdeets: + if fic["event"] == "prompt": + prompts.append(fic) + if prompts: + promptwords = 0 + for fic in prompts: + promptwords += fic["words"] + promptdict = {"type":"Prompt fills","fics":len(prompts),"words":promptwords,"list":prompts} + else: + promptdict = False + unprompted = [] + for fic in ficdeets: + if fic["event"] == False: + unprompted.append(fic) + if unprompted: + unpromptedwords = 0 + for fic in unprompted: + unpromptedwords += fic["words"] + unprompteddict = {"type":"Unprompted","fics":len(unprompted),"words":unpromptedwords,"list":unprompted} + else: + unprompteddict = False + challenges = [] + for fic in ficdeets: + if fic["event"] == "challenge": + challenges.append(fic) + if challenges: + challengewords = 0 + for fic in challenges: + challengewords += fic["words"] + challengedict = {"type":"Challenges","fics":len(challenges),"words":challengewords,"list":challenges} + else: + challengedict = False + exchanges = [] + for fic in ficdeets: + if fic["event"] == "exchange" or fic["event"] == "ao3exchange": + exchanges.append(fic) + if exchanges: + exchangewords = 0 + for fic in exchanges: + exchangewords += fic["words"] + exchangedict = {"type":"Exchanges","fics":len(exchanges),"words":exchangewords,"list":exchanges} + else: + exchangedict = False + byevent = [] + if promptdict: + byevent.append(promptdict) + if unprompteddict: + byevent.append(unprompteddict) + if challengedict: + byevent.append(challengedict) + if exchangedict: + byevent.append(exchangedict) + byevent = sorted(byevent,key=lambda d: d["words"],reverse=True) + filewrite.write("

By type

\n\n\n\n\n\n\n\n\n\n") + for event in byevent: + filewrite.write("\n\n\n\n") + filewrite.write("\n
Words per fic type
TypeWords
" + event["type"] + "" + str(event["words"]) + "" + str(event["fics"]) + " fic") + if event["fics"] > 1: + filewrite.write("s") + filewrite.write(", " + str(event["words"]) + " words
\n
Breakdown\n") + for eventtype in byevent: + filewrite.write("

" + eventtype["type"] + "

\n") + eventslist = [] + for fic in eventtype["list"]: + if fic["eventname"]: + eventdeets = {"eventname":fic["eventname"],"eventlocation":fic["eventlocation"],"ficno":fic["number"],"words":fic["words"]} + else: + eventdeets = {"ficno":fic["number"],"words":fic["words"]} + eventslist.append(eventdeets) + neweventslist = [] + if eventtype["type"] == "Unprompted": + neweventslist = eventslist + else: + for fic in eventslist: + if neweventslist == []: + ficlogged = True + neweventslist.append(fic) + else: + ficlogged = False + for newfic in neweventslist: + if ficlogged == False: + if fic["eventname"] == newfic["eventname"]: + ficlogged = True + newfic["words"] = newfic["words"] + fic["words"] + if type(newfic["ficno"]) == str: + newfic["ficno"] = newfic["ficno"].split() + if type(fic["ficno"]) == str: + newfic["ficno"].append(fic["ficno"]) + if ficlogged == False: + neweventslist.append(fic) + if eventtype["type"] != "Unprompted": + for fic in neweventslist: + if type(fic["ficno"]) == str: + fic["ficno"] = fic["ficno"].split() + neweventslist = sorted(neweventslist,key=lambda d: d["words"],reverse=True) + else: + neweventslist = sorted(neweventslist,key=lambda d: d["ficno"]) + if eventtype["type"] == "Unprompted": + filewrite.write("
List\n
    \n") + for fic in neweventslist: + filewrite.write("
  1. " + str(ficsum(int(fic["ficno"]),year,local=local)) + "
  2. ") + filewrite.write("
\n
\n") + else: + filewrite.write("\n\n\n\n\n\n\n\n\n") + for event in neweventslist: + filewrite.write("\n\n\n\n") + filewrite.write("\n
Words per event
EventWords
") + if event["eventlocation"] == "dwcomm": + filewrite.write("\"[community" + (event["eventname"]).replace("-","_") + "") + elif event["eventlocation"] == "dwjournal": + filewrite.write("\"[personal" + (event["eventname"]).replace("-","_")+ "") + elif event["eventlocation"] == "ljjournal": + filewrite.write("\"[personal" + (event["eventname"]).replace("-","_")+ "") + else: + filewrite.write(event["eventname"]) + filewrite.write("" + str(event["words"]) + "" + str(len(event["ficno"])) + " fic") + if len(event["ficno"]) > 1: + filewrite.write("s") + filewrite.write(", " + str(event["words"]) + " words
\n
List\n") + for event in neweventslist: + filewrite.write("

") + if event["eventlocation"] == "dwcomm": + filewrite.write("\"[community" + (event["eventname"]).replace("-","_") + "") + elif event["eventlocation"] == "dwjournal": + filewrite.write("\"[personal" + (event["eventname"]).replace("-","_")+ "") + elif event["eventlocation"] == "ljjournal": + filewrite.write("\"[personal" + (event["eventname"]).replace("-","_")+ "") + else: + filewrite.write(event["eventname"]) + filewrite.write("

\n
    \n") + for fic in event["ficno"]: + filewrite.write("
  1. " + str(ficsum(int(fic),year,local=local)) + "
  2. \n") + filewrite.write("
\n") + filewrite.write("
\n") + fandomlist = [] + for fic in ficdeets: + fandomlist.extend(fic["fandom"]) + fandomlist = sorted(list(dict.fromkeys(fandomlist))) + filewrite.write("
\n

By fandom

\n\n\n\n\n\n\n\n\n\n") + fandomdeets = [] + for fandom in fandomlist: + fandomdict = {"name":fandom,"ficno":[],"words":0} + for fic in ficdeets: + if fandom in fic["fandom"]: + fandomdict["ficno"].append(fic["number"]) + fandomdict["words"] += fic["words"] + fandomdeets.append(fandomdict) + fandomdeets = sorted(fandomdeets,key=lambda d: d["words"],reverse=True) + for fandom in fandomdeets: + filewrite.write("\n\n\n") + filewrite.write("\n
Words per fandom
Fandom Words
" + fandom["name"] + "" + str(fandom["words"]) + "" + str(len(fandom["ficno"])) + " fic") + if len(fandom["ficno"]) > 1: + filewrite.write("s") + filewrite.write(", " + str(fandom["words"]) + " words
\n
List") + for fandom in fandomdeets: + filewrite.write("

" + fandom["name"] + "

\n
    \n") + for fic in fandom["ficno"]: + filewrite.write("
  1. " + str(ficsum(int(fic),year,showfandom=False,local=local)) + "
  2. \n") + filewrite.write("
\n") + filewrite.write("
\n

By month

\n\n\n\n\n\n\n\n\n") + monthcombine = [] + for fic in datesplit: + # read the file back in to get the right word count, because dicts are dynamic somehow?? + thedate = fic["date"] + thefic = fic["number"] + if os.path.exists("originalsmeta/" + thefic + ".py"): + ficfile = "originalsmeta." + thefic + fileread = import_module(ficfile) + elif os.path.exists("translationsmeta/" + thefic + ".py"): + ficfile = "translationsmeta." + thefic + fileread = import_module(ficfile) + else: + fileread = False + if fileread: + for datewords in fileread.datewords: + if datewords["date"] == thedate: + thewords = datewords["words"] + fic["words"] = thewords + ficlogged = False + if monthcombine == []: + if ficlogged == False: + ficlogged = True + monthcombine.append(fic) + else: + ficlogged = False + for newfic in monthcombine: + if ficlogged == False: + if fic["number"] == newfic["number"]: + if (fic["date"]).month == (newfic["date"]).month: + ficlogged = True + newfic["words"] += fic["words"] + if ficlogged == False: + monthcombine.append(fic) + jan = {"fics":[],"words":0} + feb = {"fics":[],"words":0} + mar = {"fics":[],"words":0} + apr = {"fics":[],"words":0} + may = {"fics":[],"words":0} + jun = {"fics":[],"words":0} + jul = {"fics":[],"words":0} + aug = {"fics":[],"words":0} + sep = {"fics":[],"words":0} + octo = {"fics":[],"words":0} + nov = {"fics":[],"words":0} + dec = {"fics":[],"words":0} + for fic in monthcombine: + if (fic["date"]).month == 1: + jan["fics"].append(fic["number"]) + jan["words"] += fic["words"] + elif (fic["date"]).month == 2: + feb["fics"].append(fic["number"]) + feb["words"] += fic["words"] + elif (fic["date"]).month == 3: + mar["fics"].append(fic["number"]) + mar["words"] += fic["words"] + elif (fic["date"]).month == 4: + apr["fics"].append(fic["number"]) + apr["words"] += fic["words"] + elif (fic["date"]).month == 5: + may["fics"].append(fic["number"]) + may["words"] += fic["words"] + elif (fic["date"]).month == 6: + jun["fics"].append(fic["number"]) + jun["words"] += fic["words"] + elif (fic["date"]).month == 7: + jul["fics"].append(fic["number"]) + jul["words"] += fic["words"] + elif (fic["date"]).month == 8: + aug["fics"].append(fic["number"]) + aug["words"] += fic["words"] + elif (fic["date"]).month == 9: + sep["fics"].append(fic["number"]) + sep["words"] += fic["words"] + elif (fic["date"]).month == 10: + octo["fics"].append(fic["number"]) + octo["words"] += fic["words"] + elif (fic["date"]).month == 11: + nov["fics"].append(fic["number"]) + nov["words"] += fic["words"] + elif (fic["date"]).month == 12: + dec["fics"].append(fic["number"]) + dec["words"] += fic["words"] + wordlist = [] + wordlist.append(jan["words"]) + wordlist.append(feb["words"]) + wordlist.append(mar["words"]) + wordlist.append(apr["words"]) + wordlist.append(may["words"]) + wordlist.append(jun["words"]) + wordlist.append(jul["words"]) + wordlist.append(aug["words"]) + wordlist.append(sep["words"]) + wordlist.append(octo["words"]) + wordlist.append(nov["words"]) + wordlist.append(dec["words"]) + mostwords = max(wordlist) + filewrite.write("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
Words per month
MonthWords
Jan" + str(jan["words"]) + "" + str(len(jan["fics"])) + " fic") + if len(jan["fics"]) != 1: + filewrite.write("s") + filewrite.write(", " + str(jan["words"]) + " words
Feb" + str(feb["words"]) + "" + str(len(feb["fics"])) + " fic") + if len(feb["fics"]) != 1: + filewrite.write("s") + filewrite.write(", " + str(feb["words"]) + " words
Mar" + str(mar["words"]) + "" + str(len(mar["fics"])) + " fic") + if len(mar["fics"]) != 1: + filewrite.write("s") + filewrite.write(", " + str(mar["words"]) + " words
Apr" + str(apr["words"]) + "" + str(len(apr["fics"])) + " fic") + if len(apr["fics"]) != 1: + filewrite.write("s") + filewrite.write(", " + str(apr["words"]) + " words
May" + str(may["words"]) + "" + str(len(may["fics"])) + " fic") + if len(may["fics"]) != 1: + filewrite.write("s") + filewrite.write(", " + str(may["words"]) + " words
Jun" + str(jun["words"]) + "" + str(len(jun["fics"])) + " fic") + if len(jun["fics"]) != 1: + filewrite.write("s") + filewrite.write(", " + str(jun["words"]) + " words
Jul" + str(jul["words"]) + "" + str(len(jul["fics"])) + " fic") + if len(jul["fics"]) != 1: + filewrite.write("s") + filewrite.write(", " + str(jul["words"]) + " words
Aug" + str(aug["words"]) + "" + str(len(aug["fics"])) + " fic") + if len(aug["fics"]) != 1: + filewrite.write("s") + filewrite.write(", " + str(aug["words"]) + " words
Sep" + str(sep["words"]) + "" + str(len(sep["fics"])) + " fic") + if len(sep["fics"]) != 1: + filewrite.write("s") + filewrite.write(", " + str(sep["words"]) + " words
Oct" + str(octo["words"]) + "" + str(len(octo["fics"])) + " fic") + if len(octo["fics"]) != 1: + filewrite.write("s") + filewrite.write(", " + str(octo["words"]) + " words
Nov" + str(nov["words"]) + "" + str(len(nov["fics"])) + " fic") + if len(nov["fics"]) != 1: + filewrite.write("s") + filewrite.write(", " + str(nov["words"]) + " words
Dec" + str(dec["words"]) + "" + str(len(dec["fics"])) + " fic") + if len(dec["fics"]) != 1: + filewrite.write("s") + filewrite.write(", " + str(dec["words"]) + " words
\n
List\n") + if len(jan["fics"]) > 0: + filewrite.write("

January

\n
    \n") + for fic in jan["fics"]: + filewrite.write("
  1. " + str(ficsum(int(fic),year,1,local=local)) + "
  2. \n") + filewrite.write("
\n") + if len(feb["fics"]) > 0: + filewrite.write("

February

\n
    \n") + for fic in feb["fics"]: + filewrite.write("
  1. " + str(ficsum(int(fic),year,2,local=local)) + "
  2. \n") + filewrite.write("
\n") + if len(mar["fics"]) > 0: + filewrite.write("

March

\n
    \n") + for fic in mar["fics"]: + filewrite.write("
  1. " + str(ficsum(int(fic),year,3,local=local)) + "
  2. \n") + filewrite.write("
\n") + if len(apr["fics"]) > 0: + filewrite.write("

April

\n
    \n") + for fic in apr["fics"]: + filewrite.write("
  1. " + str(ficsum(int(fic),year,4,local=local)) + "
  2. \n") + filewrite.write("
\n") + if len(may["fics"]) > 0: + filewrite.write("

May

\n
    \n") + for fic in may["fics"]: + filewrite.write("
  1. " + str(ficsum(int(fic),year,5,local=local)) + "
  2. \n") + filewrite.write("
\n") + if len(jun["fics"]) > 0: + filewrite.write("

June

\n
    \n") + for fic in jun["fics"]: + filewrite.write("
  1. " + str(ficsum(int(fic),year,6,local=local)) + "
  2. \n") + filewrite.write("
\n") + if len(jul["fics"]) > 0: + filewrite.write("

July

\n
    \n") + for fic in jul["fics"]: + filewrite.write("
  1. " + str(ficsum(int(fic),year,7,local=local)) + "
  2. \n") + filewrite.write("
\n") + if len(aug["fics"]) > 0: + filewrite.write("

August

\n
    \n") + for fic in aug["fics"]: + filewrite.write("
  1. " + str(ficsum(int(fic),year,8,local=local)) + "
  2. \n") + filewrite.write("
\n") + if len(sep["fics"]) > 0: + filewrite.write("

September

\n
    \n") + for fic in sep["fics"]: + filewrite.write("
  1. " + str(ficsum(int(fic),year,9,local=local)) + "
  2. \n") + filewrite.write("
\n") + if len(octo["fics"]) > 0: + filewrite.write("

October

\n
    \n") + for fic in octo["fics"]: + filewrite.write("
  1. " + str(ficsum(int(fic),year,10,local=local)) + "
  2. \n") + filewrite.write("
\n") + if len(nov["fics"]) > 0: + filewrite.write("

November

\n
    \n") + for fic in nov["fics"]: + filewrite.write("
  1. " + str(ficsum(int(fic),year,11,local=local)) + "
  2. \n") + filewrite.write("
\n") + if len(dec["fics"]) > 0: + filewrite.write("

December

\n
    \n") + for fic in dec["fics"]: + filewrite.write("
  1. " + str(ficsum(int(fic),year,12,local=local)) + "
  2. \n") + filewrite.write("
\n") + filewrite.write("
\n

") + listposition = yearlist.index(year) + if year != 1998: + prevyear = yearlist[listposition - 1] + filewrite.write("« " + str(prevyear) + "") + thisyear = int(datetime.datetime.now().strftime("%Y")) + if year < thisyear: + nextyear = yearlist[listposition + 1] + filewrite.write("" + str(nextyear) + " »") + filewrite.write("

\n
\n\n") + filewrite.close() + +if __name__ == "__main__": + yeargen(True)