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

pull/3529/head
BaiJiangJie 2019-12-11 11:53:46 +08:00 committed by GitHub
parent bc5a240121
commit f296dce935
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 14 deletions

View File

@ -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,13 +462,13 @@ 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
if manager.load_from_object():
return manager.config
elif manager.load_from_yml():
return manager.config
else:
msg = """
Error: No config file found.