本文整理汇总了Python中mpf.system.config.Config.load_config_yaml方法的典型用法代码示例。如果您正苦于以下问题:Python Config.load_config_yaml方法的具体用法?Python Config.load_config_yaml怎么用?Python Config.load_config_yaml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mpf.system.config.Config
的用法示例。
在下文中一共展示了Config.load_config_yaml方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _load_config
# 需要导入模块: from mpf.system.config import Config [as 别名]
# 或者: from mpf.system.config.Config import load_config_yaml [as 别名]
def _load_config(self):
# creates the main config dictionary from the YAML machine config files.
self.config = dict()
# load the MPF config & machine defaults
self.config = Config.load_config_yaml(config=self.config,
yaml_file=self.options['mpfconfigfile'])
# Find the machine_files location. If it starts with a forward or
# backward slash, then we assume it's from the mpf root. Otherwise we
# assume it's from the subfolder location specified in the
# mpfconfigfile location
if (self.options['machinepath'].startswith('/') or
self.options['machinepath'].startswith('\\')):
machine_path = self.options['machinepath']
else:
machine_path = os.path.join(self.config['mpf']['paths']
['machine_files'],
self.options['machinepath'])
self.machine_path = os.path.abspath(machine_path)
# Add the machine folder to our path so we can import modules from it
sys.path.append(self.machine_path)
self.log.info("Machine folder: %s", machine_path)
# Now find the config file location. Same as machine_file with the
# slash uses to specify an absolute path
if (self.options['configfile'].startswith('/') or
self.options['configfile'].startswith('\\')):
config_file = self.options['configfile']
else:
if not self.options['configfile'].endswith('.yaml'):
self.options['configfile'] += '.yaml'
config_file = os.path.join(machine_path,
self.config['mpf']['paths']['config'],
self.options['configfile'])
self.log.info("Base machine config file: %s", config_file)
# Load the machine-specific config
self.config = Config.load_config_yaml(config=self.config,
yaml_file=config_file)
示例2: _load_mode
# 需要导入模块: from mpf.system.config import Config [as 别名]
# 或者: from mpf.system.config.Config import load_config_yaml [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.info('Processing mode: %s', mode_string)
mode_path = os.path.join(self.machine.machine_path,
self.machine.config['mediacontroller']['paths']['modes'], mode_string)
mode_config_file = os.path.join(self.machine.machine_path,
self.machine.config['mediacontroller']['paths']['modes'],
mode_string, 'config', mode_string + '.yaml')
config = Config.load_config_yaml(yaml_file=mode_config_file)
if 'code' in config['mode']:
import_str = ('modes.' + mode_string + '.code.' +
config['mode']['code'].split('.')[0])
i = __import__(import_str, fromlist=[''])
mode_object = getattr(i, config['mode']['code'].split('.')[1])(
self.machine, config, mode_string, mode_path)
else:
mode_object = Mode(self.machine, config, mode_string, mode_path)
return mode_object
示例3: _load_mode
# 需要导入模块: from mpf.system.config import Config [as 别名]
# 或者: from mpf.system.config.Config import load_config_yaml [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()
# 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_yaml(yaml_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_path = os.path.join(self.machine.machine_path,
self.machine.config['media_controller']['paths']['modes'], mode_string)
mode_config_file = os.path.join(self.machine.machine_path,
self.machine.config['media_controller']['paths']['modes'], mode_string, 'config',
mode_string + '.yaml')
if os.path.isfile(mode_config_file):
config = Config.load_config_yaml(config=config,
yaml_file=mode_config_file)
return Mode(self.machine, config, mode_string, mode_path)
示例4: _load_mode
# 需要导入模块: from mpf.system.config import Config [as 别名]
# 或者: from mpf.system.config.Config import load_config_yaml [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()
# 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_yaml(yaml_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_path = os.path.join(self.machine.machine_path,
self.machine.config['mpf']['paths']['modes'], mode_string)
mode_config_file = os.path.join(self.machine.machine_path,
self.machine.config['mpf']['paths']['modes'], mode_string, 'config',
mode_string + '.yaml')
if os.path.isfile(mode_config_file):
config = Config.load_config_yaml(config=config,
yaml_file=mode_config_file)
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
示例5: __init__
# 需要导入模块: from mpf.system.config import Config [as 别名]
# 或者: from mpf.system.config.Config import load_config_yaml [as 别名]
def __init__(self, options):
self.options = options
self.log = logging.getLogger("MediaController")
self.log.info("Media Controller Version %s", version.__version__)
self.log.info("Backbox Control Protocol Version %s",
version.__bcp_version__)
self.log.info("Config File Version %s",
version.__config_version__)
python_version = sys.version_info
self.log.info("Python version: %s.%s.%s", python_version[0],
python_version[1], python_version[2])
self.log.info("Platform: %s", sys.platform)
self.log.info("Python executable location: %s", sys.executable)
self.log.info("32-bit Python? %s", sys.maxsize < 2**32)
self.config = dict()
self.done = False # todo
self.machine_path = None
self.asset_managers = dict()
self.num_assets_to_load = 0
self.window = None
self.window_manager = None
self.pygame = False
self.pygame_requested = False
self.registered_pygame_handlers = dict()
self.pygame_allowed_events = list()
self.socket_thread = None
self.receive_queue = Queue.Queue()
self.sending_queue = Queue.Queue()
self.crash_queue = Queue.Queue()
self.game_modes = CaseInsensitiveDict()
self.player_list = list()
self.player = None
self.HZ = 0
self.next_tick_time = 0
self.secs_per_tick = 0
Task.Create(self._check_crash_queue)
self.bcp_commands = {'hello': self.bcp_hello,
'goodbye': self.bcp_goodbye,
'reset': self.reset,
'mode_start': self.bcp_mode_start,
'mode_stop': self.bcp_mode_stop,
'error': self.bcp_error,
'ball_start': self.bcp_ball_start,
'ball_end': self.bcp_ball_end,
'game_start': self.bcp_game_start,
'game_end': self.bcp_game_end,
'player_added': self.bcp_player_add,
'player_variable': self.bcp_player_variable,
'player_score': self.bcp_player_score,
'player_turn_start': self.bcp_player_turn_start,
'attract_start': self.bcp_attract_start,
'attract_stop': self.bcp_attract_stop,
'trigger': self.bcp_trigger,
'switch': self.bcp_switch,
'get': self.bcp_get,
'set': self.bcp_set,
'config': self.bcp_config,
'timer': self.bcp_timer
}
# load the MPF config & machine defaults
self.config = (
Config.load_config_yaml(config=self.config,
yaml_file=self.options['mcconfigfile']))
# Find the machine_files location. If it starts with a forward or
# backward slash, then we assume it's from the mpf root. Otherwise we
# assume it's from the subfolder location specified in the
# mpfconfigfile location
if (options['machinepath'].startswith('/') or
options['machinepath'].startswith('\\')):
machine_path = options['machinepath']
else:
machine_path = os.path.join(self.config['mediacontroller']['paths']
['machine_files'],
options['machinepath'])
self.machine_path = os.path.abspath(machine_path)
# Add the machine folder to our path so we can import modules from it
sys.path.append(self.machine_path)
self.log.info("Machine folder: %s", machine_path)
# Now find the config file location. Same as machine_file with the
# slash uses to specify an absolute path
if (options['configfile'].startswith('/') or
options['configfile'].startswith('\\')):
config_file = options['configfile']
else:
if not options['configfile'].endswith('.yaml'):
options['configfile'] += '.yaml'
#.........这里部分代码省略.........