本文整理汇总了Python中mpf.system.utility_functions.Util.keys_to_lower方法的典型用法代码示例。如果您正苦于以下问题:Python Util.keys_to_lower方法的具体用法?Python Util.keys_to_lower怎么用?Python Util.keys_to_lower使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mpf.system.utility_functions.Util
的用法示例。
在下文中一共展示了Util.keys_to_lower方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load
# 需要导入模块: from mpf.system.utility_functions import Util [as 别名]
# 或者: from mpf.system.utility_functions.Util import keys_to_lower [as 别名]
def load(self, filename, verify_version=True):
"""Loads a YAML file from disk.
Args:
filename: The file to load.
verify_version: Boolean which specifies whether this method should
verify whether this file's config_version is compatible with
this version of MPF. Default is True.
Returns:
A dictionary of the settings from this YAML file.
"""
config = Util.keys_to_lower(self.byteify(json.load(open(filename, 'r'))))
# if verify_version:
# self.check_config_file_version(filename)
#
# try:
# self.log.debug("Loading configuration file: %s", filename)
# config = Util.keys_to_lower(json.loads(open(filename, 'r')))
# except yaml.YAMLError, exc:
# if hasattr(exc, 'problem_mark'):
# mark = exc.problem_mark
# self.log.critical("Error found in config file %s. Line %s, "
# "Position %s", filename, mark.line+1,
# mark.column+1)
# sys.exit()
# except:
# self.log.critical("Couldn't load from file: %s", filename)
# raise
return config
示例2: load
# 需要导入模块: from mpf.system.utility_functions import Util [as 别名]
# 或者: from mpf.system.utility_functions.Util import keys_to_lower [as 别名]
def load(self, filename, verify_version=True, halt_on_error=False):
"""Loads a YAML file from disk.
Args:
filename: The file to load.
verify_version: Boolean which specifies whether this method should
verify whether this file's config_version is compatible with
this version of MPF. Default is True.
halt_on_error: Boolean which controls what happens if the file
can't be loaded. (Not found, invalid format, etc. If True, MPF
will raise an error and exit. If False, an empty config
dictionary will be returned.
Returns:
A dictionary of the settings from this YAML file.
"""
if verify_version and not Config.check_config_file_version(filename):
raise Exception("Config file version mismatch: {}".
format(filename))
try:
self.log.debug("Loading configuration file: %s", filename)
with open(filename, 'r') as f:
config = Util.keys_to_lower(yaml.load(f))
except yaml.YAMLError, exc:
if hasattr(exc, 'problem_mark'):
mark = exc.problem_mark
self.log.critical("Error found in config file %s. Line %s, "
"Position %s", filename, mark.line+1,
mark.column+1)
if halt_on_error:
sys.exit()
else:
config = dict()