commit
4bd7b9cac8
@ -19,21 +19,17 @@ def resource_path(relative_path, persistent=False):
|
||||
return total_path
|
||||
|
||||
|
||||
def load_external_config(name):
|
||||
def load_external_config(config_path):
|
||||
"""
|
||||
Load the external config file
|
||||
"""
|
||||
config = None
|
||||
config_path = name
|
||||
config_filename = path.join(path.dirname(sys.executable), config_path)
|
||||
|
||||
if path.exists(config_filename):
|
||||
spec = util.spec_from_file_location(name, config_filename)
|
||||
if path.exists(config_path):
|
||||
spec = util.spec_from_file_location("config", config_path)
|
||||
config = util.module_from_spec(spec)
|
||||
spec.loader.exec_module(config)
|
||||
else:
|
||||
import config
|
||||
|
||||
return config
|
||||
|
||||
|
||||
@ -41,10 +37,11 @@ def get_config():
|
||||
"""
|
||||
Get the config
|
||||
"""
|
||||
config_path = resource_path("user_config.py")
|
||||
user_config_path = resource_path("user_config.py")
|
||||
default_config_path = resource_path("config.py")
|
||||
config = (
|
||||
load_external_config("user_config.py")
|
||||
if path.exists(config_path)
|
||||
else load_external_config("config.py")
|
||||
load_external_config(user_config_path)
|
||||
if path.exists(user_config_path)
|
||||
else load_external_config(default_config_path)
|
||||
)
|
||||
return config
|
||||
|
Loading…
x
Reference in New Issue
Block a user