import os from importlib import import_module fffandoms = ["FF1","FF2","FF3","FF4","FF5","FF6","FF7","FF8","FF9","FFX","FF11","FF12","FF13","FF14","FF15"] import makeheader import headerfooter def charlist(local=False): # delete existing file if os.path.exists("build/ff/characters/index.html"): os.remove("build/ff/characters/index.html") # write header headerfooter.headerwrite("build/ff/characters/index.html","FF fics by character","FF fics by character","

Click on each bar to see fics about that character, organised according to the character’s prominence and then from newest to oldest.

\n

Key to categories:

\n",False,local) # iterate through fandoms characters = [] numbers = ["one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen"] for fandom in fffandoms: thecharacters = [] 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) if len(fileread.fandom) == 1: if fandom in fileread.fandom: try: thecharacters.extend(fileread.charpov) except: pass try: thecharacters.extend(fileread.charmain) except: pass try: thecharacters.extend(fileread.charsecondary) except: pass try: thecharacters.extend(fileread.charmention) except: pass thecharacters = sorted(list(dict.fromkeys(thecharacters))) for character in thecharacters: if character != "OCs": chardict = {"name":character,"game":(fffandoms.index(fandom) + 1)} characters.append(chardict) charlist = sorted(characters, key=lambda d: d["name"]) for person in charlist: povcount = [] maincount = [] secondarycount = [] mentioncount = [] character = person["name"] searchfandom = fffandoms[(person["game"]) - 1] cssgame = numbers[(person["game"]) - 1] # 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("originalsmeta/" + ficcountstring + ".py"): countfile = "originalsmeta." + ficcountstring fileread = import_module(countfile) if searchfandom in fileread.fandom: # append to lists try: if character in fileread.charpov: povcount.append(ficcount) except: pass try: if character in fileread.charmain: maincount.append(ficcount) except: pass try: if character in fileread.charsecondary: secondarycount.append(ficcount) except: pass try: if character in fileread.charmention: mentioncount.append(ficcount) except: pass # write details element output = "build/ff/characters/index.html" filewrite = open(output, "a") filewrite.write("
" + character + " ") # write statistics if len(povcount) > 0: filewrite.write("" + str(len(povcount)) + "") if len(maincount) > 0: filewrite.write("" + str(len(maincount)) + "") if len(secondarycount) > 0: filewrite.write("" + str(len(secondarycount)) + "") if len(mentioncount) > 0: filewrite.write("" + str(len(mentioncount)) + "") filewrite.write("\n") filewrite.close() # write fic headers in each category if len(povcount) > 0: filewrite = open(output, "a") filewrite.write("

POV character

\n") filewrite.close() for fic in povcount: makeheader.ficgen(fic,False,output,local) if len(maincount) > 0: filewrite = open(output, "a") filewrite.write("

Main character

\n") filewrite.close() for fic in maincount: makeheader.ficgen(fic,False,output,local) if len(secondarycount) > 0: filewrite = open(output, "a") filewrite.write("

Secondary character

\n") filewrite.close() for fic in secondarycount: makeheader.ficgen(fic,False,output,local) if len(mentioncount) > 0: filewrite = open(output, "a") filewrite.write("

Mentioned

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