def parse_user_config_from_code(config, source_code=None):
try:
if source_code is None:
with codecs.open(config["base"]["strategy_file"], encoding="utf-8") as f:
source_code = f.read()
scope = {}
code = compile(source_code, config["base"]["strategy_file"], 'exec')
six.exec_(code, scope)
__config__ = scope.get("__config__", {})
for sub_key, sub_dict in six.iteritems(__config__):
if sub_key not in config["whitelist"]:
continue
deep_update(sub_dict, config[sub_key])
except Exception as e:
system_log.error(_(u"in parse_user_config, exception: {e}").format(e=e))
finally:
return config
评论列表
文章目录