Skip to content

Commit

Permalink
Simplify config overrides and change config ext
Browse files Browse the repository at this point in the history
  • Loading branch information
campb303 committed Aug 2, 2021
1 parent 0a30503 commit 462182d
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions src/webqueue2api/__init__.py
Original file line number Diff line number Diff line change
@@ -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"]
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"]

0 comments on commit 462182d

Please sign in to comment.