import datetime, os from importlib import import_module import makeheader import headerfooter def eventlist(local=False): # delete existing file if os.path.exists("build/events/index.html"): os.remove("build/events/index.html") # write header headerfooter.headerwrite("build/events/index.html","Events","Events","
Here’s a list of the fics I’ve written for events (exchanges, prompt memes/fests, challenges, etc.). Fics in this section are organised chronologically by year, from oldest to newest.
",False,local) # get list of events events = [] 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("files/originalsmeta/" + ficcountstring + ".py"): ficfile = "files.originalsmeta." + ficcountstring fileread = import_module(ficfile) try: if fileread.revealdate > datetime.datetime.now(): revealed = False else: revealed = True except: revealed = True if revealed == True: try: events.append({"name":fileread.eventname,"location":fileread.eventlocation,"sortname":fileread.eventname.lower()}) except: try: events.append({"name":fileread.eventname,"location":"","sortname":fileread.eventname.lower()}) except: pass newlist = [] for event in events: if event not in newlist: newlist.append(event) eventlist = sorted(newlist, key=lambda d: d["sortname"]) for event in eventlist: evententries = [] theevent = event["name"] # check all fics in specified fandom 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("files/originalsmeta/" + ficcountstring + ".py"): countfile = "files.originalsmeta." + ficcountstring fileread = import_module(countfile) try: if fileread.revealdate > datetime.datetime.now(): revealed = False else: revealed = True except: revealed = True if revealed == True: try: if fileread.eventname == theevent: evententries.append({"ficno":ficcount,"year":(fileread.datewords[0])["date"].year,"fandom":fileread.fandom,"update":(fileread.datewords[-1])["date"]}) except: pass eventfandoms = [] for entry in evententries: eventfandoms.extend(entry["fandom"]) eventfandoms = sorted(list(dict.fromkeys(eventfandoms))) # write details element output = "build/events/index.html" filewrite = open(output, "a") filewrite.write("