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


Python Config.load_config_file方法代码示例

本文整理汇总了Python中mpf.system.config.Config.load_config_file方法的典型用法代码示例。如果您正苦于以下问题:Python Config.load_config_file方法的具体用法?Python Config.load_config_file怎么用?Python Config.load_config_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mpf.system.config.Config的用法示例。


在下文中一共展示了Config.load_config_file方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _load_mode

# 需要导入模块: from mpf.system.config import Config [as 别名]
# 或者: from mpf.system.config.Config import load_config_file [as 别名]
    def _load_mode(self, mode_string):
        """Loads a mode, reads in its config, and creates the Mode object.

        Args:
            mode: String name of the mode you're loading. This is the name of
                the mode's folder in your game's machine_files/modes folder.

        """
        self.log.debug('Processing mode: %s', mode_string)

        config = dict()

        # find the folder for this mode:
        mode_path = os.path.join(self.machine.machine_path,
            self.machine.config['media_controller']['paths']['modes'], mode_string)

        if not os.path.exists(mode_path):
            mode_path = os.path.abspath(os.path.join('mpf', self.machine.config['media_controller']['paths']['modes'], mode_string))

        # Is there an MPF default config for this mode? If so, load it first
        mpf_mode_config = os.path.join(
            'mpf',
            self.machine.config['media_controller']['paths']['modes'],
            mode_string,
            'config',
            mode_string + '.yaml')

        if os.path.isfile(mpf_mode_config):
            config = Config.load_config_file(mpf_mode_config)

        # Now figure out if there's a machine-specific config for this mode, and
        # if so, merge it into the config

        mode_config_folder = os.path.join(self.machine.machine_path,
            self.machine.config['media_controller']['paths']['modes'], mode_string, 'config')

        found_file = False
        for path, _, files in os.walk(mode_config_folder):
            for file in files:
                file_root, file_ext = os.path.splitext(file)

                if file_root == mode_string:
                    config = Util.dict_merge(config,
                        Config.load_config_file(os.path.join(path, file)))
                    found_file = True
                    break

            if found_file:
                break

        return Mode(self.machine, config, mode_string, mode_path)
开发者ID:HarryXS,项目名称:mpf,代码行数:53,代码来源:mode_controller.py

示例2: _load_machine_config

# 需要导入模块: from mpf.system.config import Config [as 别名]
# 或者: from mpf.system.config.Config import load_config_file [as 别名]
    def _load_machine_config(self):
        for num, config_file in enumerate(self.options['configfile']):

            if not (config_file.startswith('/') or
                    config_file.startswith('\\')):

                config_file = os.path.join(self.machine_path,
                    self.config['mpf']['paths']['config'], config_file)

            self.log.info("Machine config file #%s: %s", num+1, config_file)

            self.config = Util.dict_merge(self.config,
                Config.load_config_file(config_file))
开发者ID:HarryXS,项目名称:mpf,代码行数:15,代码来源:machine.py

示例3: __init__

# 需要导入模块: from mpf.system.config import Config [as 别名]
# 或者: from mpf.system.config.Config import load_config_file [as 别名]
    def __init__(self, options):
        self.options = options
        self.log = logging.getLogger('machinewizard')
        self.log.info("MPF Wizard v%s", version.__version__)
        self.log.debug("Init Options: {}".format(self.options))
        self.verify_system_info()

        self.done = False
        self.machine_path = None  # Path to this machine's folder root

        FileManager.init()

        self.mpfconfig = dict()
        self.mpfconfig = Config.load_config_file(self.options['mpfconfigfile'])

        self.config_files = dict()
        #self.config = Config.load_config_file(self.options['mpfconfigfile'])
        self._set_machine_path()
        self._load_config_from_files()
        
        self.log.info('machine config loaded')
开发者ID:missionpinball,项目名称:mpf-wizard,代码行数:23,代码来源:machinewizard.py

示例4: _load_mode

# 需要导入模块: from mpf.system.config import Config [as 别名]
# 或者: from mpf.system.config.Config import load_config_file [as 别名]
    def _load_mode(self, mode_string):
        """Loads a mode, reads in its config, and creates the Mode object.

        Args:
            mode: String name of the mode you're loading. This is the name of
                the mode's folder in your game's machine_files/modes folder.

        """
        if self.debug:
            self.log.debug('Processing mode: %s', mode_string)

        config = dict()

        # find the folder for this mode:
        mode_path = os.path.join(self.machine.machine_path,
            self.machine.config['mpf']['paths']['modes'], mode_string)

        if not os.path.exists(mode_path):
            mode_path = os.path.abspath(os.path.join('mpf', self.machine.config['mpf']['paths']['modes'], mode_string))


        # Is there an MPF default config for this mode? If so, load it first
        mpf_mode_config = os.path.join(
            'mpf',
            self.machine.config['mpf']['paths']['modes'],
            mode_string,
            'config',
            mode_string + '.yaml')

        if os.path.isfile(mpf_mode_config):
            config = Config.load_config_file(mpf_mode_config)

        # Now figure out if there's a machine-specific config for this mode, and
        # if so, merge it into the config

        mode_config_folder = os.path.join(self.machine.machine_path,
            self.machine.config['mpf']['paths']['modes'], mode_string, 'config')

        found_file = False
        for path, _, files in os.walk(mode_config_folder):
            for file in files:
                file_root, file_ext = os.path.splitext(file)

                if file_root == mode_string:
                    config = Util.dict_merge(config,
                        Config.load_config_file(os.path.join(path, file)))
                    found_file = True
                    break

            if found_file:
                break

        if 'code' in config['mode']:

            # need to figure out if this mode code is in the machine folder or
            # the default mpf folder

            mode_code_file = os.path.join(self.machine.machine_path,
                self.machine.config['mpf']['paths']['modes'],
                mode_string,
                'code',
                config['mode']['code'].split('.')[0] + '.py')

            if os.path.isfile(mode_code_file):  # code is in the machine folder
                import_str = (self.machine.config['mpf']['paths']['modes'] +
                              '.' + mode_string + '.code.' +
                              config['mode']['code'].split('.')[0])
                i = __import__(import_str, fromlist=[''])

                if self.debug:
                    self.log.debug("Loading Mode class code from %s",
                                   mode_code_file)

                mode_object = getattr(i, config['mode']['code'].split('.')[1])(
                    self.machine, config, mode_string, mode_path)

            else:  # code is in the mpf folder
                import_str = ('mpf.' +
                              self.machine.config['mpf']['paths']['modes'] +
                              '.' + mode_string + '.code.' +
                              config['mode']['code'].split('.')[0])
                i = __import__(import_str, fromlist=[''])

                if self.debug:
                    self.log.debug("Loading Mode class code from %s",
                                   import_str)

                mode_object = getattr(i, config['mode']['code'].split('.')[1])(
                    self.machine, config, mode_string, mode_path)

        else:  # no code specified, so using the default Mode class
            if self.debug:
                self.log.debug("Loading default Mode class code")
            mode_object = Mode(self.machine, config, mode_string, mode_path)

        return mode_object
开发者ID:qcapen,项目名称:mpf,代码行数:98,代码来源:mode_controller.py

示例5: _load_mpf_config

# 需要导入模块: from mpf.system.config import Config [as 别名]
# 或者: from mpf.system.config.Config import load_config_file [as 别名]
 def _load_mpf_config(self):
     self.config = Config.load_config_file(self.options['mpfconfigfile'])
开发者ID:HarryXS,项目名称:mpf,代码行数:4,代码来源:machine.py


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