From d3d579840a219323ee8849ac1d51ccbaaeeb706e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?tr=C3=A9meur?= Date: Tue, 6 Aug 2024 19:37:17 +0100 Subject: [PATCH] Store all user data in a folder --- .gitignore | 9 +------ characters.py | 8 +++--- commentpage.py | 10 ++++---- events.py | 8 +++--- fandoms.py | 12 ++++----- feed.py | 18 ++++++------- indexgen.py | 8 +++--- makeheader.py | 8 +++--- masterlist.py | 4 +-- originalsmeta/__init__.py | 0 originalsmeta/template.py | 49 ------------------------------------ ships.py | 8 +++--- single.py | 8 +++--- sortfics.sh | 26 +++++++++---------- statsgen.py | 44 ++++++++++++++++---------------- texts/.gitkeep | 0 translationsmeta/__init__.py | 0 translationsmeta/template.py | 11 -------- wordcount.py | 4 +-- 19 files changed, 84 insertions(+), 151 deletions(-) delete mode 100644 originalsmeta/__init__.py delete mode 100644 originalsmeta/template.py delete mode 100644 texts/.gitkeep delete mode 100644 translationsmeta/__init__.py delete mode 100644 translationsmeta/template.py diff --git a/.gitignore b/.gitignore index 9607449..2c9bb2d 100644 --- a/.gitignore +++ b/.gitignore @@ -16,12 +16,5 @@ build/secret/*.epub build/secret/*.gif build/secret/*.png build/emacs.jpg -originalsmeta/* -!originalsmeta/__init__.py -!originalsmeta/template.py -texts/* -!texts/.gitkeep -translationsmeta/* -!translationsmeta/__init__.py -!translationsmeta/template.py +files/ build/stats/*/index.html \ No newline at end of file diff --git a/characters.py b/characters.py index 5be6405..9d45e47 100644 --- a/characters.py +++ b/characters.py @@ -26,8 +26,8 @@ def charlist(local=False): ficcountstring = "0" + str(ficcount) else: ficcountstring = str(ficcount) - if os.path.exists("originalsmeta/" + ficcountstring + ".py"): - ficfile = "originalsmeta." + ficcountstring + if os.path.exists("files/originalsmeta/" + ficcountstring + ".py"): + ficfile = "files.originalsmeta." + ficcountstring fileread = import_module(ficfile) try: if fileread.revealdate > datetime.datetime.now(): @@ -79,8 +79,8 @@ def charlist(local=False): ficcountstring = "0" + str(ficcount) else: ficcountstring = str(ficcount) - if os.path.exists("originalsmeta/" + ficcountstring + ".py"): - countfile = "originalsmeta." + ficcountstring + if os.path.exists("files/originalsmeta/" + ficcountstring + ".py"): + countfile = "files.originalsmeta." + ficcountstring fileread = import_module(countfile) try: if fileread.revealdate > datetime.datetime.now(): diff --git a/commentpage.py b/commentpage.py index 7165481..2359d87 100644 --- a/commentpage.py +++ b/commentpage.py @@ -27,7 +27,7 @@ def commentpage(ficno,directory,local=False): else: fffandom = False except: - origfile = "originalsmeta." + str(fileread.original) + origfile = "files.originalsmeta." + str(fileread.original) origread = import_module(origfile) if any(item in fffandoms for item in origread.fandom): fffandom = True @@ -143,10 +143,10 @@ def allcomments(local=False): ficcountstring = "0" + str(ficcount) else: ficcountstring = str(ficcount) - if os.path.exists("originalsmeta/" + ficcountstring + ".py"): - commentpage(ficcount,"originalsmeta",local) - elif os.path.exists("translationsmeta/" + ficcountstring + ".py"): - commentpage(ficcount,"translationsmeta",local) + if os.path.exists("files/originalsmeta/" + ficcountstring + ".py"): + commentpage(ficcount,"files.originalsmeta",local) + elif os.path.exists("files/translationsmeta/" + ficcountstring + ".py"): + commentpage(ficcount,"files.translationsmeta",local) if __name__ == "__main__": allcomments() diff --git a/events.py b/events.py index 8dd8bda..1c8b821 100644 --- a/events.py +++ b/events.py @@ -21,8 +21,8 @@ def eventlist(local=False): ficcountstring = "0" + str(ficcount) else: ficcountstring = str(ficcount) - if os.path.exists("originalsmeta/" + ficcountstring + ".py"): - ficfile = "originalsmeta." + ficcountstring + if os.path.exists("files/originalsmeta/" + ficcountstring + ".py"): + ficfile = "files.originalsmeta." + ficcountstring fileread = import_module(ficfile) try: if fileread.revealdate > datetime.datetime.now(): @@ -57,8 +57,8 @@ def eventlist(local=False): ficcountstring = "0" + str(ficcount) else: ficcountstring = str(ficcount) - if os.path.exists("originalsmeta/" + ficcountstring + ".py"): - countfile = "originalsmeta." + ficcountstring + if os.path.exists("files/originalsmeta/" + ficcountstring + ".py"): + countfile = "files.originalsmeta." + ficcountstring fileread = import_module(countfile) try: if fileread.revealdate > datetime.datetime.now(): diff --git a/fandoms.py b/fandoms.py index 6077efa..6ba8046 100644 --- a/fandoms.py +++ b/fandoms.py @@ -21,8 +21,8 @@ def fandomlist(local=False): ficcountstring = "0" + str(ficcount) else: ficcountstring = str(ficcount) - if os.path.exists("originalsmeta/" + ficcountstring + ".py"): - ficfile = "originalsmeta." + ficcountstring + if os.path.exists("files/originalsmeta/" + ficcountstring + ".py"): + ficfile = "files.originalsmeta." + ficcountstring fileread = import_module(ficfile) try: if fileread.revealdate > datetime.datetime.now(): @@ -64,8 +64,8 @@ def fandomlist(local=False): ficcountstring = "0" + str(ficcount) else: ficcountstring = str(ficcount) - if os.path.exists("originalsmeta/" + ficcountstring + ".py"): - countfile = "originalsmeta." + ficcountstring + if os.path.exists("files/originalsmeta/" + ficcountstring + ".py"): + countfile = "files.originalsmeta." + ficcountstring fileread = import_module(countfile) try: if fileread.revealdate > datetime.datetime.now(): @@ -88,7 +88,7 @@ def fandomlist(local=False): firstficstring = "0" + str(firstfic) else: firstficstring = str(firstfic) - firstfile = "originalsmeta." + firstficstring + firstfile = "files.originalsmeta." + firstficstring firstread = import_module(firstfile) firstyear = (firstread.datewords[0])["date"].year lastfic = fandomfics[0] @@ -98,7 +98,7 @@ def fandomlist(local=False): lastficstring = "0" + str(lastfic) else: lastficstring = str(lastfic) - lastfile = "originalsmeta." + lastficstring + lastfile = "files.originalsmeta." + lastficstring lastread = import_module(lastfile) lastyear = (lastread.datewords[0])["date"].year if lastyear == firstyear: diff --git a/feed.py b/feed.py index 8f245a0..7b5de27 100644 --- a/feed.py +++ b/feed.py @@ -23,8 +23,8 @@ def feedgen(local=False): ficcountstring = "0" + str(ficcount) else: ficcountstring = str(ficcount) - if os.path.exists("originalsmeta/" + ficcountstring + ".py"): - ficfile = "originalsmeta." + ficcountstring + if os.path.exists("files/originalsmeta/" + ficcountstring + ".py"): + ficfile = "files.originalsmeta." + ficcountstring fileread = import_module(ficfile) try: if fileread.revealdate <= datetime.datetime.now(): @@ -32,8 +32,8 @@ def feedgen(local=False): except: for instalment in fileread.datewords: datelist.append(instalment["date"]) - elif os.path.exists("translationsmeta/" + ficcountstring + ".py"): - ficfile = "translationsmeta." + ficcountstring + elif os.path.exists("files/translationsmeta/" + ficcountstring + ".py"): + ficfile = "files.translationsmeta." + ficcountstring fileread = import_module(ficfile) for instalment in fileread.datewords: datelist.append(instalment["date"]) @@ -53,8 +53,8 @@ def feedgen(local=False): else: ficcountstring = str(ficcount) targetfile = 0 - if os.path.exists("originalsmeta/" + ficcountstring + ".py"): - ficfile = "originalsmeta." + ficcountstring + if os.path.exists("files/originalsmeta/" + ficcountstring + ".py"): + ficfile = "files.originalsmeta." + ficcountstring fileread = import_module(ficfile) try: if fileread.revealdate <= datetime.datetime.now(): @@ -66,8 +66,8 @@ def feedgen(local=False): if instalment["date"] == date: if targetfile == 0: targetfile = ficfile - elif os.path.exists("translationsmeta/" + ficcountstring + ".py"): - transfile = "translationsmeta." + ficcountstring + elif os.path.exists("files/translationsmeta/" + ficcountstring + ".py"): + transfile = "files.translationsmeta." + ficcountstring transread = import_module(transfile) for instalment in transread.datewords: if instalment["date"] == date: @@ -90,7 +90,7 @@ def feedgen(local=False): filewrite.write (" (French)") filewrite.write(": ") try: - origfile = "originalsmeta." + str(thefile.original) + origfile = "files.originalsmeta." + str(thefile.original) origread = import_module(origfile) try: filewrite.write(origread.fandomtext) diff --git a/indexgen.py b/indexgen.py index ba6c3ac..bfbf25c 100644 --- a/indexgen.py +++ b/indexgen.py @@ -14,11 +14,11 @@ def statslist(local=False): ficcountstring = "0" + str(ficcount) else: ficcountstring = str(ficcount) - if os.path.exists("originalsmeta/" + ficcountstring + ".py"): - ficfile = "originalsmeta." + ficcountstring + if os.path.exists("files/originalsmeta/" + ficcountstring + ".py"): + ficfile = "files.originalsmeta." + ficcountstring fileread = import_module(ficfile) - elif os.path.exists("translationsmeta/" + ficcountstring + ".py"): - ficfile = "translationsmeta." + ficcountstring + elif os.path.exists("files/translationsmeta/" + ficcountstring + ".py"): + ficfile = "files.translationsmeta." + ficcountstring fileread = import_module(ficfile) else: fileread = False diff --git a/makeheader.py b/makeheader.py index f163959..87b5693 100644 --- a/makeheader.py +++ b/makeheader.py @@ -17,7 +17,7 @@ def linkgen(ficno,output="output.html",local=False): else: ficnostring = str(ficno) # open the file - ficfile = "originalsmeta." + ficnostring + ficfile = "files.originalsmeta." + ficnostring fileread = import_module(ficfile) # open translation file if there is one try: @@ -28,7 +28,7 @@ def linkgen(ficno,output="output.html",local=False): translationstring = "0" + str(fileread.translation) else: translationstring = str(fileread.translation) - translationfile = "translationsmeta." + translationstring + translationfile = "files.translationsmeta." + translationstring transread = import_module(translationfile) except: pass @@ -259,7 +259,7 @@ def ficgen(ficno,unique=False,output="output.html",local=False): else: ficnostring = str(ficno) # open the file - ficfile = "originalsmeta." + ficnostring + ficfile = "files.originalsmeta." + ficnostring fileread = import_module(ficfile) # open translation file if there is one try: @@ -270,7 +270,7 @@ def ficgen(ficno,unique=False,output="output.html",local=False): translationstring = "0" + str(fileread.translation) else: translationstring = str(fileread.translation) - translationfile = "translationsmeta." + translationstring + translationfile = "files.translationsmeta." + translationstring transread = import_module(translationfile) except: pass diff --git a/masterlist.py b/masterlist.py index 00e56f9..8b065ec 100644 --- a/masterlist.py +++ b/masterlist.py @@ -25,8 +25,8 @@ def listgen(local=False): ficcountstring = "0" + str(ficcount) else: ficcountstring = str(ficcount) - if os.path.exists("originalsmeta/" + ficcountstring + ".py"): - ficfile = "originalsmeta." + ficcountstring + if os.path.exists("files/originalsmeta/" + ficcountstring + ".py"): + ficfile = "files.originalsmeta." + ficcountstring fileread = import_module(ficfile) try: if fileread.revealdate <= datetime.datetime.now(): diff --git a/originalsmeta/__init__.py b/originalsmeta/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/originalsmeta/template.py b/originalsmeta/template.py deleted file mode 100644 index 3f44c8d..0000000 --- a/originalsmeta/template.py +++ /dev/null @@ -1,49 +0,0 @@ -import datetime - -title = "" # just the number is fine -showtitle = False -language = "en" -# translation = -datewords = [{"date":datetime.datetime(YYYY,M,D),"words":}] -# revealdate = datetime.datetime(YYYY,M,D) -# approxdate = "" -status = "complete" # incomplete, abandoned -rating = "" # g, t, m, e -# ratingreason = "" -fandom = [""] -# fandomtext = "" -# charpov = [""] -# charmain = [""] -# charsecondary = [""] -# charmention = [""] -# ship = [""] -genre = [""] -# warnings = "" -time = "" -location = [""] -# locationtext = "" -# summary = "" -# notes = "" -# event = "" # challenge (including fests; anything without a specific prompt), ao3exchange, exchange, prompt -# eventlocation = "" # dwcomm, dwjournal, ljjournal -# eventname = "" -# eventdeets = "" # probably not needed unless it’s robotsoup -# eventfrequency = "" # "annual" or some custom value like "summer 2022 round" – or can leave -# prompt = "" -# recip = "" -# recippseud = "" -# recipsite = "" # ao3, dw, tumblr -locked = False -# ao3slug = -# ao3locked = -html = True -pdf = True -epub = True -# fedislug = "" -# comments = [{"site":"", # ao3, dw, lj, discord -# "registered":, # True or False, not required for discord -# "username":"", # leave out if it’s a dw/lj anon -# "pseud":"", # optional, ao3 only -# "date":datetime.datetime(), -# "link":"", -# "text":""}] diff --git a/ships.py b/ships.py index eb0c5e7..487e1f0 100644 --- a/ships.py +++ b/ships.py @@ -26,8 +26,8 @@ def shiplist(local=False): ficcountstring = "0" + str(ficcount) else: ficcountstring = str(ficcount) - if os.path.exists("originalsmeta/" + ficcountstring + ".py"): - ficfile = "originalsmeta." + ficcountstring + if os.path.exists("files/originalsmeta/" + ficcountstring + ".py"): + ficfile = "files.originalsmeta." + ficcountstring fileread = import_module(ficfile) try: if fileread.revealdate > datetime.datetime.now(): @@ -67,8 +67,8 @@ def shiplist(local=False): ficcountstring = "0" + str(ficcount) else: ficcountstring = str(ficcount) - if os.path.exists("originalsmeta/" + ficcountstring + ".py"): - countfile = "originalsmeta." + ficcountstring + if os.path.exists("files/originalsmeta/" + ficcountstring + ".py"): + countfile = "files.originalsmeta." + ficcountstring fileread = import_module(countfile) try: if fileread.revealdate > datetime.datetime.now(): diff --git a/single.py b/single.py index 70aee38..fc952c8 100644 --- a/single.py +++ b/single.py @@ -83,10 +83,10 @@ def allsingles(local=False): ficcountstring = "0" + str(ficcount) else: ficcountstring = str(ficcount) - if os.path.exists("originalsmeta/" + ficcountstring + ".py"): - singlepage(ficcount,"originalsmeta",local) - elif os.path.exists("translationsmeta/" + ficcountstring + ".py"): - singlepage(ficcount,"translationsmeta",local) + if os.path.exists("files/originalsmeta/" + ficcountstring + ".py"): + singlepage(ficcount,"files.originalsmeta",local) + elif os.path.exists("files/translationsmeta/" + ficcountstring + ".py"): + singlepage(ficcount,"files.translationsmeta",local) if __name__ == "__main__": allsingles() diff --git a/sortfics.sh b/sortfics.sh index cc015cb..e9e5d62 100755 --- a/sortfics.sh +++ b/sortfics.sh @@ -13,27 +13,27 @@ do ficstring="$i" fi fi - if compgen -G "texts/${ficstring}.*" > /dev/null + if compgen -G "files/texts/${ficstring}.*" > /dev/null then - if test -f "originalsmeta/${ficstring}.py" + if test -f "files/originalsmeta/${ficstring}.py" then - if grep -q "^locked = True" "originalsmeta/${ficstring}.py" + if grep -q "^locked = True" "files/originalsmeta/${ficstring}.py" then builddir="secret" else - if grep -q "^locked = False" "originalsmeta/${ficstring}.py" + if grep -q "^locked = False" "files/originalsmeta/${ficstring}.py" then builddir="files" fi fi else - if test -f "translationsmeta/${ficstring}.py" + if test -f "files/translationsmeta/${ficstring}.py" then - if grep -q "^locked = True" "translationsmeta/${ficstring}.py" + if grep -q "^locked = True" "files/translationsmeta/${ficstring}.py" then builddir="secret" else - if grep -q "^locked = False" "translationsmeta/${ficstring}.py" + if grep -q "^locked = False" "files/translationsmeta/${ficstring}.py" then builddir="files" fi @@ -44,17 +44,17 @@ do fi if [ ${builddir} != "null" ] then - if test -f "texts/${ficstring}.html" + if test -f "files/texts/${ficstring}.html" then - mv "texts/${ficstring}.html" "build/${builddir}/" + mv "files/texts/${ficstring}.html" "build/${builddir}/" fi - if test -f "texts/${ficstring}.pdf" + if test -f "files/texts/${ficstring}.pdf" then - mv "texts/${ficstring}.pdf" "build/${builddir}/" + mv "files/texts/${ficstring}.pdf" "build/${builddir}/" fi - if test -f "texts/${ficstring}.epub" + if test -f "files/texts/${ficstring}.epub" then - mv "texts/${ficstring}.epub" "build/${builddir}/" + mv "files/texts/${ficstring}.epub" "build/${builddir}/" fi fi fi diff --git a/statsgen.py b/statsgen.py index db6669d..b07ddeb 100644 --- a/statsgen.py +++ b/statsgen.py @@ -16,17 +16,17 @@ def ficsum(ficcount,year,month=0,showfandom=True,local=False): ficcountstring = "0" + str(ficcount) else: ficcountstring = str(ficcount) - if os.path.exists("originalsmeta/" + ficcountstring + ".py"): - ficfile = "originalsmeta." + ficcountstring + if os.path.exists("files/originalsmeta/" + ficcountstring + ".py"): + ficfile = "files.originalsmeta." + ficcountstring fileread = import_module(ficfile) - elif os.path.exists("translationsmeta/" + ficcountstring + ".py"): - ficfile = "translationsmeta." + ficcountstring + elif os.path.exists("files/translationsmeta/" + ficcountstring + ".py"): + ficfile = "files.translationsmeta." + ficcountstring fileread = import_module(ficfile) else: fileread = False if fileread: try: - theorig = "originalsmeta." + str(fileread.original) + theorig = "files.originalsmeta." + str(fileread.original) origfile = import_module(theorig) except: pass @@ -227,11 +227,11 @@ def yeargen(local=False): ficcountstring = "0" + str(ficcount) else: ficcountstring = str(ficcount) - if os.path.exists("originalsmeta/" + ficcountstring + ".py"): - ficfile = "originalsmeta." + ficcountstring + if os.path.exists("files/originalsmeta/" + ficcountstring + ".py"): + ficfile = "files.originalsmeta." + ficcountstring fileread = import_module(ficfile) - elif os.path.exists("translationsmeta/" + ficcountstring + ".py"): - ficfile = "translationsmeta." + ficcountstring + elif os.path.exists("files/translationsmeta/" + ficcountstring + ".py"): + ficfile = "files.translationsmeta." + ficcountstring fileread = import_module(ficfile) else: fileread = False @@ -270,11 +270,11 @@ def yeargen(local=False): ficcountstring = "0" + str(ficcount) else: ficcountstring = str(ficcount) - if os.path.exists("originalsmeta/" + ficcountstring + ".py"): - ficfile = "originalsmeta." + ficcountstring + if os.path.exists("files/originalsmeta/" + ficcountstring + ".py"): + ficfile = "files.originalsmeta." + ficcountstring fileread = import_module(ficfile) - elif os.path.exists("translationsmeta/" + ficcountstring + ".py"): - ficfile = "translationsmeta." + ficcountstring + elif os.path.exists("files/translationsmeta/" + ficcountstring + ".py"): + ficfile = "files.translationsmeta." + ficcountstring fileread = import_module(ficfile) else: fileread = False @@ -292,11 +292,11 @@ def yeargen(local=False): allfics.append(ficcountstring) allfics = sorted(list(dict.fromkeys(allfics))) for fic in allfics: - if os.path.exists("originalsmeta/" + fic + ".py"): - ficfile = "originalsmeta." + fic + if os.path.exists("files/originalsmeta/" + fic + ".py"): + ficfile = "files.originalsmeta." + fic fileread = import_module(ficfile) - elif os.path.exists("translationsmeta/" + fic + ".py"): - ficfile = "translationsmeta." + fic + elif os.path.exists("files/translationsmeta/" + fic + ".py"): + ficfile = "files.translationsmeta." + fic fileread = import_module(ficfile) else: fileread = False @@ -320,7 +320,7 @@ def yeargen(local=False): except: try: if fileread.original: - theorig = "originalsmeta." + str(fileread.original) + theorig = "files.originalsmeta." + str(fileread.original) origfile = import_module(theorig) try: fandom = origfile.fandom @@ -534,11 +534,11 @@ def yeargen(local=False): # read the file back in to get the right word count, because dicts are dynamic somehow?? thedate = fic["date"] thefic = fic["number"] - if os.path.exists("originalsmeta/" + thefic + ".py"): - ficfile = "originalsmeta." + thefic + if os.path.exists("files/originalsmeta/" + thefic + ".py"): + ficfile = "files.originalsmeta." + thefic fileread = import_module(ficfile) - elif os.path.exists("translationsmeta/" + thefic + ".py"): - ficfile = "translationsmeta." + thefic + elif os.path.exists("files/translationsmeta/" + thefic + ".py"): + ficfile = "files.translationsmeta." + thefic fileread = import_module(ficfile) else: fileread = False diff --git a/texts/.gitkeep b/texts/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/translationsmeta/__init__.py b/translationsmeta/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/translationsmeta/template.py b/translationsmeta/template.py deleted file mode 100644 index c7d175a..0000000 --- a/translationsmeta/template.py +++ /dev/null @@ -1,11 +0,0 @@ -import datetime - -title = "" -showtitle = False -language = "fr" -original = -datewords = [{"date":datetime.datetime(YYYY,M,D),"words":}] -status = "complete" # incomplete, abandoned -summary = "" -ao3slug = -# comments = [] # see originalsmeta/template.py for format diff --git a/wordcount.py b/wordcount.py index 6c47779..8138ae4 100644 --- a/wordcount.py +++ b/wordcount.py @@ -23,8 +23,8 @@ def bywords(local=False): ficcountstring = "0" + str(ficcount) else: ficcountstring = str(ficcount) - if os.path.exists("originalsmeta/" + ficcountstring + ".py"): - ficfile = "originalsmeta." + ficcountstring + if os.path.exists("files/originalsmeta/" + ficcountstring + ".py"): + ficfile = "files.originalsmeta." + ficcountstring fileread = import_module(ficfile) try: if fileread.revealdate > datetime.datetime.now():