def merge_dict(dict1,dict2):
'''
合并字典
:return:
'''
if not isinstance(dict1,dict) or not isinstance(dict2,dict):
return dict1
for key,info in dict2.items():
if dict1.has_key(key):
if isinstance(dict1[key], dict):
dict1[key] = self.merge_dict(dict1[key],info)
elif isinstance(dict1[key], list):
dict1[key].extend(info)
else:
dict1[key] = info
else :
dict1[key] = info
return dict1
def run():
'''
获取配置文件
:return:
'''
default_config = self.load("config/yaml/default.yaml").get('default')
if self.game is None or default_config is None:
return default_config
game_config = self.load("config/yaml/{}.yaml".format(self.game))
if game_config.get('default') is not None:
default_config = self.merge_dict(default_config,game_config.get('default'))
if self.platform is None:
return default_config
platform_config = game_config.get(self.platform)
if platform_config is not None:
default_config = self.merge_dict(default_config,platform_config)
return default_config
run()