import datetime, os, shutil from importlib import import_module import headerfooter import makeheader """ Code to generate standalone fic pages """ def singlepage(ficno,directory,local=False): # convert to three-digit number if ficno < 10: ficnostring = "00" + str(ficno) elif ficno < 100: ficnostring = "0" + str(ficno) else: ficnostring = str(ficno) # open the file ficfile = directory + "." + ficnostring fileread = import_module(ficfile) # determine if unlocked try: if fileread.locked: singlestatus = False else: singlestatus = True except: singlestatus = True if singlestatus: singlepath = "build/single/" + ficnostring if not os.path.isdir(singlepath): os.mkdir(singlepath) if os.path.exists(singlepath + "/index.html"): os.remove(singlepath + "/index.html") # write to output file output = singlepath + "/index.html" headerfooter.headerwrite(output,"Fic no. " + ficnostring,"Fic no. " + ficnostring + "","",False,local) try: if fileread.original: makeheader.ficgen(fileread.original,False,output,local) else: makeheader.ficgen(ficno,False,output,local) except: makeheader.ficgen(ficno,False,output,local) filewrite = open(output, "a") filewrite.write("\n