Add --config option for explicitly stating configuration file to use.
aliparlakci/bulk-downloader-for-reddit#122 Address comments in pull review. * Removed vertical space. * Added config file existence check with log message.
This commit is contained in:
27
script.py
27
script.py
@@ -256,14 +256,24 @@ def printLogo():
|
||||
)
|
||||
|
||||
def main():
|
||||
arguments = Arguments.parse()
|
||||
GLOBAL.arguments = arguments
|
||||
|
||||
if not Path(GLOBAL.defaultConfigDirectory).is_dir():
|
||||
os.makedirs(GLOBAL.defaultConfigDirectory)
|
||||
|
||||
if Path("config.json").exists():
|
||||
GLOBAL.configDirectory = Path("config.json")
|
||||
if arguments.config:
|
||||
if arguments.use_local_config:
|
||||
sys.exit()
|
||||
if Path(arguments.config).exists():
|
||||
GLOBAL.configDirectory = Path(arguments.config)
|
||||
else:
|
||||
VanillaPrint("custom config",arguments.config,"not found. Exiting.")
|
||||
sys.exit()
|
||||
else:
|
||||
GLOBAL.configDirectory = GLOBAL.defaultConfigDirectory / "config.json"
|
||||
if not Path(GLOBAL.defaultConfigDirectory).is_dir():
|
||||
os.makedirs(GLOBAL.defaultConfigDirectory)
|
||||
if Path("config.json").exists():
|
||||
GLOBAL.configDirectory = Path("config.json")
|
||||
else:
|
||||
GLOBAL.configDirectory = GLOBAL.defaultConfigDirectory / "config.json"
|
||||
try:
|
||||
GLOBAL.config = Config(GLOBAL.configDirectory).generate()
|
||||
except InvalidJSONFile as exception:
|
||||
@@ -274,9 +284,6 @@ def main():
|
||||
|
||||
sys.argv = sys.argv + GLOBAL.config["options"].split()
|
||||
|
||||
arguments = Arguments.parse()
|
||||
GLOBAL.arguments = arguments
|
||||
|
||||
if arguments.set_filename:
|
||||
Config(GLOBAL.configDirectory).setCustomFileName()
|
||||
sys.exit()
|
||||
@@ -362,4 +369,4 @@ if __name__ == "__main__":
|
||||
print(GLOBAL.log_stream.getvalue())
|
||||
|
||||
if not GLOBAL.arguments.quit: input("\nPress enter to quit\n")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user