From 462182df61c5f595615443353e7fcc2dc52e45b6 Mon Sep 17 00:00:00 2001 From: Justin Campbell Date: Mon, 2 Aug 2021 19:22:59 -0400 Subject: [PATCH] Simplify config overrides and change config ext --- src/webqueue2api/__init__.py | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/webqueue2api/__init__.py b/src/webqueue2api/__init__.py index 8b36081..2461467 100644 --- a/src/webqueue2api/__init__.py +++ b/src/webqueue2api/__init__.py @@ -1,24 +1,22 @@ from webqueue2api.parser import Item, Queue, load_queues -from .config import config import configparser, sys -from pathlib import Path as path -import webqueue2api.parser -import webqueue2api.api - -config_parser_object = configparser.ConfigParser() -config_file_location = path.joinpath(path(sys.executable).parent.parent.parent, "webqueue2api_config") +from pathlib import Path +from .config import config -if path(config_file_location).exists(): - config_parser_object.read(config_file_location) +config_parser = configparser.ConfigParser() +config_file_path = Path.joinpath(Path(sys.executable).parent.parent.parent, "webqueue2api_config.config") -if config_parser_object.has_section("parser"): - if config_parser_object.has_option("parser", "queue_directory"): - webqueue2api.parser.config.queue_directory = config_parser_object["parser"]["queue_directory"] - if config_parser_object.has_option("parser", "queues_to_ignore"): - webqueue2api.parser.config.queues_to_ignore = config_parser_object["parser"]["queues_to_ignore"] +if Path(config_file_path).exists(): + config_parser.read(config_file_path) + + if config_parser.has_section("parser"): + if config_parser.has_option("parser", "queue_directory"): + config.parser.queue_directory = config_parser["parser"]["queue_directory"] + if config_parser.has_option("parser", "queues_to_ignore"): + config.parser.queues_to_ignore = config_parser["parser"]["queues_to_ignore"] -if config_parser_object.has_section("api"): - if config_parser_object.has_option("api", "environment"): - webqueue2api.api.config.environment = config_parser_object["api"]["environment"] - if config_parser_object.has_option("api", "jwt_secret_key"): - webqueue2api.api.config.jwt_secret_key = config_parser_object["api"]["jwt_secret_key"] \ No newline at end of file + if config_parser.has_section("api"): + if config_parser.has_option("api", "environment"): + config.api.environment = config_parser["api"]["environment"] + if config_parser.has_option("api", "jwt_secret_key"): + config.api.jwt_secret_key = config_parser["api"]["jwt_secret_key"] \ No newline at end of file