Polish helper script

This commit is contained in:
Zachary Talis 2021-06-27 15:08:08 -04:00
parent ece35b27e6
commit ff7c757ff0
4 changed files with 8 additions and 13 deletions

View file

@ -12,13 +12,8 @@ def generate():
"""Regenerate site""" """Regenerate site"""
runIdName = "tk_run_id" runIdName = "tk_run_id"
categoryIdName = "tk_category_dashname" categoryIdName = "tk_category_dashname"
runs = util_csv.dictReaderMultiRow("../csv/runs.csv", runIdName)
categories = util_csv.dictReaderMultiRow("../csv/categories.csv", categoryIdName)
config = util_csv.dictReaderFirstRow("../csv/config.csv") config = util_csv.dictReaderFirstRow("../csv/config.csv")
print(len(config)) if len(config) != 0:
print(len(categories))
print(len(runs))
if len(config) != 0 and len(categories) != 0 and len(runs) != 0:
subprocess.call(cwd + "/generate.py", shell=True) subprocess.call(cwd + "/generate.py", shell=True)
@ -39,6 +34,7 @@ def optionAddRun():
def optionQuit(): def optionQuit():
"""Quit""" """Quit"""
print()
os._exit(1) os._exit(1)
@ -54,6 +50,7 @@ options = [optionSetup, optionAddCategory, optionAddRun, optionQuit]
# Main loop # Main loop
while True: while True:
key = "tk_game_name" key = "tk_game_name"
config = util_csv.dictReaderFirstRow("../csv/config.csv")
print(f"\n[ paceboard for {config[key]} ]") print(f"\n[ paceboard for {config[key]} ]")
index = 0 index = 0
for option in options: for option in options:

View file

@ -21,5 +21,5 @@ categoryDict = {
util_csv.dictWriter("../csv/categories.csv", categoryDict, "a") util_csv.dictWriter("../csv/categories.csv", categoryDict, "a")
print( print(
f"\n{divider}\n\nAdded category! If you made a mistake, you can manually edit csv/categories.csv (and csv/runs.csv if you've added any runs to the borked category). \n" f"\n{divider}\n\nAdded category! If you made a mistake, you can manually edit csv/categories.csv (and csv/runs.csv if you've added any runs to the borked category)."
) )

View file

@ -59,7 +59,7 @@ while not doneCategoryInput:
categoriesNew = {} categoriesNew = {}
for category in categoriesOld: for category in categoriesOld:
categoriesNew[index] = categoriesOld[category] categoriesNew[index] = categoriesOld[category]
print(f"{index} - {categoriesNew[index][displayName]}") print(f"{index + 1} - {categoriesNew[index][displayName]}")
index += 1 index += 1
try: try:
@ -67,7 +67,7 @@ while not doneCategoryInput:
rawCategoryInput = input("Your pick: ") rawCategoryInput = input("Your pick: ")
except KeyboardInterrupt: except KeyboardInterrupt:
os._exit(1) os._exit(1)
categoryInput = int(rawCategoryInput) categoryInput = int(rawCategoryInput) - 1
if categoryInput <= index: if categoryInput <= index:
try: try:
tk_run_category_dashname = categoriesNew[categoryInput][ tk_run_category_dashname = categoriesNew[categoryInput][
@ -102,5 +102,5 @@ runDict = {
util_csv.dictWriter("../csv/runs.csv", runDict, "a") util_csv.dictWriter("../csv/runs.csv", runDict, "a")
print( print(
f"\n{divider}\n\nAdded run! If you made a mistake, you can manually edit csv/runs.csv\n" f"\n{divider}\n\nAdded run! If you made a mistake, you can manually edit csv/runs.csv"
) )

View file

@ -25,6 +25,4 @@ configDict = {
util_csv.dictWriter("../csv/config.csv", configDict) util_csv.dictWriter("../csv/config.csv", configDict)
print( print(f"\n{divider}\n\nPerfect, that's all for now! <3")
f"\n{divider}\n\nPerfect! You can always overwrite the info above by running this script again.\nHere's an overview of how to use paceboard:\n\n- Add a category using scripts/add-category.py\n- Add a run using scripts/add-run.py\n- Use scripts/generate.py to update the site with the info you've added.\n- All categories, runs, and configuration details are stored in csv/\n- Replace the logo saved as assets/img/logo.png\n- For the adventurous, you can restyle your site's pages by editing files within templates/ and css/\n\nRemember to run scripts/generate.py to initialize your site.\nThat's all for now! <3\n"
)