Return to repo list

pystatsite

On-or-Offline static site generator in Python
Return to HMagellan.com

commit 038acf69c9d6570613fc0bef1b62507f263a9a5c
parent 807192727db456eb801df7004492eadec6ad223d
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Sun, 28 Mar 2021 23:23:56 -0500

a framework for making choices

Diffstat:
Mpystatsite.py | 25+++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/pystatsite.py b/pystatsite.py @@ -10,33 +10,50 @@ loaded_options = {} # Loading with open(options_file) as o: loaded_options = json.load(o) +# Functions +def new_page(): + os.system("clear") + +def sync_site(): + os.system("clear") + # Interface def main(options = loaded_options): chosen = False choice = None + # NOTE: Is this horrible? + choices = [ + ["Create a new web page", new_page], + ["Sync site to a location", sync_site], + ["Quit", exit] + ] while not chosen: os.system("clear") print("==============") print("| PYSTATSITE |") print("==============\n") - print("Please choose an option:\n") - print("\t1) Create a new web page") - print("\t2) Sync site to location '" + options["sync_location"] + "'\n") + num = 1 + for c in choices: + print('\t' + str(num) + ") " + c[0]) + num += 1 try: choice = int(input()) except ValueError: choice = None - if choice in (1, 2): + if choice != None and choice in range(1, len(choices) + 1): chosen = True else: print("Invalid value. Please choose from the provided choices.") print("Press ENTER to continue...") input() + # NOTE: Maybe horrible... + choices[choice - 1][1]() + if __name__ == "__main__": main(loaded_options)