import configparser from os import path """ Reads the config files and stores the config into settings dictionary. This dictionary can be then used in the application to access config values. """ # parse base config file config = configparser.ConfigParser() config_path = path.dirname(path.abspath(__file__)) config.read(path.join(config_path, "../config_base.cfg")) # check if custom configuration file exists and eventually load it if path.exists((cfg_pth := path.join(config_path, "../config.cfg"))): config.read(cfg_pth) settings = { "mongodb_uri": config.get("DB","MONGODB_URI"), "mongodb_db": config.get("DB","MONGODB_DB"), "mongodb_collection": config.get("DB","MONGODB_COLLECTION"), "base_url": config.get("WEB", "BASE_URL"), "endpoint": config.get("WEB", "ENDPOINT"), "threads": int(config.get("APP", "THREADS")), "http_proxy": config.get("PROXY", "HTTP_PROXY", fallback=None), "https_proxy": config.get("PROXY", "HTTPS_PROXY", fallback=None) }