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("
") position = 0 while (eventlist[position])["name"] != theevent: position += 1 eventlocation = (eventlist[position])["location"] if eventlocation == "dwjournal": filewrite.write("\"[personal" + theevent.replace("-","_")+ "") elif eventlocation == "dwcomm": filewrite.write("\"[community" + theevent.replace("-","_") + "") elif eventlocation == "ljjournal": filewrite.write("\"[personal" + theevent.replace("-","_")+ "") else: filewrite.write(theevent) filewrite.write(" (" + str(len(evententries)) + ": " + ", ".join(eventfandoms) + ")\n") filewrite.close() startyear = 2014 thisyear = int(datetime.datetime.now().strftime("%Y")) while startyear < thisyear: startyear += 1 yearlist = [] for entry in evententries: if int(entry["year"]) == startyear: ficdict = {"thefic":entry["ficno"],"thedate":entry["update"]} yearlist.append(ficdict) if len(yearlist) > 0: yearlist = sorted(yearlist,key=lambda d: d["thedate"]) newyear = [] for fic in yearlist: newyear.append(fic["thefic"]) filewrite = open(output, "a") filewrite.write("

" + str(startyear) + "

\n") filewrite.close() for fic in newyear: makeheader.ficgen(fic,False,output,local) filewrite = open(output, "a") filewrite.write("
\n") filewrite.close() # write footer headerfooter.footerwrite("build/events/index.html",False,local) if __name__ == "__main__": eventlist()