Unverified Commit f296dce9 authored by BaiJiangJie's avatar BaiJiangJie Committed by GitHub

[Update] 修改config 加载逻辑 (#3528)

parent bc5a2401
......@@ -442,10 +442,10 @@ class ConfigManager:
try:
from config import config as c
self.from_object(c)
return self.config
return True
except ImportError:
pass
return None
return False
def load_from_yml(self):
for i in ['config.yml', 'config.yaml']:
......@@ -453,7 +453,7 @@ class ConfigManager:
continue
loaded = self.from_yaml(i)
if loaded:
return self.config
return True
return False
@classmethod
......@@ -462,20 +462,20 @@ class ConfigManager:
cls.config_class = config_class
if not root_path:
root_path = PROJECT_DIR
manager = cls(root_path=root_path)
config = manager.load_from_object()
if config:
return config
config = manager.load_from_yml()
if config:
return config
msg = """
Error: No config file found.
You can run `cp config_example.yml config.yml`, and edit it.
"""
raise ImportError(msg)
manager = cls(root_path=root_path)
if manager.load_from_object():
return manager.config
elif manager.load_from_yml():
return manager.config
else:
msg = """
Error: No config file found.
You can run `cp config_example.yml config.yml`, and edit it.
"""
raise ImportError(msg)
@classmethod
def get_dynamic_config(cls, config):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment