Return to repo list

pystatsite

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

commit 807192727db456eb801df7004492eadec6ad223d
parent d21fd2c6329839a8d895612b0a2e82a949d347cf
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Sun, 28 Mar 2021 22:55:21 -0500

functional improvement to interface

Diffstat:
Moptions.json | 1+
Mpystatsite.py | 37++++++++++++++++++++++++++++++-------
2 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/options.json b/options.json @@ -1,3 +1,4 @@ { + "editor" : "/usr/bin/vim", "sync_location": "/var/www/html" } diff --git a/pystatsite.py b/pystatsite.py @@ -5,15 +5,38 @@ from src import compose, sync, add # Values options_file = "options.json" +loaded_options = {} # Loading -with open(options_file) as o: options = json.load(o) +with open(options_file) as o: loaded_options = json.load(o) # Interface -print("==============") -print("| PYSTATSITE |") -print("==============") +def main(options = loaded_options): -print("Please choose an option:") -print("- 1) Create a new web page") -print("- 2) Sync site to location '" + options["sync_location"] + "'") + chosen = False + choice = None + + 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") + + try: + choice = int(input()) + except ValueError: + choice = None + + if choice in (1, 2): + chosen = True + else: + print("Invalid value. Please choose from the provided choices.") + print("Press ENTER to continue...") + input() + +if __name__ == "__main__": + main(loaded_options)