import datetime, os from importlib import import_module import headerfooter def statslist(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: try: if fileread.revealdate > datetime.datetime.now(): revealed = False else: revealed = True except: revealed = True if revealed == True: for date in fileread.datewords: yearlist.append(date["date"].year) yearlist = sorted(list(dict.fromkeys(yearlist))) linkedyears = [] for year in yearlist: statstring = "" if local == True: statspath = "/home/mdd/Documents/proj/fic-archive/build/stats/" + str(year) + "/index.html" else: statspath = "/fic/stats/" + str(year) if yearlist.index(year) > 0: statstring += " • " statstring += "" + str(year) if year == (datetime.datetime.now()).year: statstring += " (so far)" statstring += "" linkedyears.append(statstring) listofyears = "".join(linkedyears) return listofyears def indexgen(local=False): # delete existing file if os.path.exists("build/index.html"): os.remove("build/index.html") # write header headerfooter.headerwrite("build/index.html","Tré’s fic archive","Tré’s fic archive","",True,local) filewrite = open("build/index.html", "a") filewrite.write("

Here is all my fanfiction! Much of it is also archived at AO3 under the name \"[archiveofourown.orgovely.

\n

The code for this archive is available here. Commenting is switched on for most fics written at least semi-recently – read about that here.

\n

You can also subscribe to the RSS feed to be notified of new fics and updates to existing ones.

\n
\n

Masterlist

\n

Every fic I’ve written since the age of five. You can view these:\n

\n
\n
\n

Final Fantasy

\n

Most of the fics I write are in FF fandoms these days. You can browse them:

\n\n
\n
\n

Events

\n

I’ve been participating in fandom exchanges and other events since late 2020. Most fics I write these days that aren’t in FF fandoms are in this category (although a lot of the FF ones are as well).

\n
\n
\n

Other

\n\n
\n
\n\n
\n") filewrite.close() headerfooter.footerwrite("build/index.html",True,local) if __name__ == "__main__": statslist(True) indexgen(True)