当前位置: 首页>>代码示例>>Python>>正文


Python Util.keys_to_lower方法代码示例

本文整理汇总了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
开发者ID:HarryXS,项目名称:mpf,代码行数:36,代码来源:json_interface.py

示例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()
开发者ID:HarryXS,项目名称:mpf,代码行数:39,代码来源:yaml_interface.py


注:本文中的mpf.system.utility_functions.Util.keys_to_lower方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。