From 39e31794db5e59f53d4d54b630f4680f71dbc21e Mon Sep 17 00:00:00 2001 From: ComradeEcho Date: Thu, 3 Dec 2020 22:04:52 -0600 Subject: [PATCH] Don't mkdir defaultConfigDirectory if not needed Check to see if config.json exists in the current working directory before creating a new configuration directory in the home folder. If config.json exists, then defaultConfigDirectory would be empty and unused - so there's no reason to create that directory if it's not going to be used. --- script.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/script.py b/script.py index 38c622c..c87b582 100644 --- a/script.py +++ b/script.py @@ -256,13 +256,12 @@ def printLogo(): ) def main(): - - if not Path(GLOBAL.defaultConfigDirectory).is_dir(): - os.makedirs(GLOBAL.defaultConfigDirectory) - + if Path("config.json").exists(): GLOBAL.configDirectory = Path("config.json") else: + if not Path(GLOBAL.defaultConfigDirectory).is_dir(): + os.makedirs(GLOBAL.defaultConfigDirectory) GLOBAL.configDirectory = GLOBAL.defaultConfigDirectory / "config.json" try: GLOBAL.config = Config(GLOBAL.configDirectory).generate() @@ -362,4 +361,4 @@ if __name__ == "__main__": print(GLOBAL.log_stream.getvalue()) if not GLOBAL.arguments.quit: input("\nPress enter to quit\n") - \ No newline at end of file +