本文整理汇总了Python中mpf.system.config.Config.check_config_file_version方法的典型用法代码示例。如果您正苦于以下问题:Python Config.check_config_file_version方法的具体用法?Python Config.check_config_file_version怎么用?Python Config.check_config_file_version使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mpf.system.config.Config
的用法示例。
在下文中一共展示了Config.check_config_file_version方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load
# 需要导入模块: from mpf.system.config import Config [as 别名]
# 或者: from mpf.system.config.Config import check_config_file_version [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()