Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.doc_sections['config_players'] = dict()
for name, module_ in self.mpfconfig['mpf']['config_players'].items():
self.doc_sections['config_players'
]['{}_player'.format(name)] = module_
self.doc_sections['platforms'] = self.mpfconfig['mpf']['platforms']
for plugin in Util.string_to_list(self.mpfconfig['mpf']['plugins']):
name = plugin.split('.')[-2]
self.doc_sections['machine'][name] = plugin
self.doc_sections['devices'] = dict()
for device in self.mpfconfig['mpf']['device_modules']:
device_cls = Util.string_to_class(device)
name = device_cls.collection
self.doc_sections['devices'][name] = device
self.doc_sections['modes'] = dict()
for name in [x for x in
os.walk(os.path.join(os.pardir, 'mpf', 'modes'))][0][1]:
if name.startswith('__'):
continue
class_name = ''.join([x.capitalize() for x in name.split('_')])
self.doc_sections['modes'][name] = (
'mpf.modes.{0}.code.{0}.{1}'.format(name, class_name))
def _load_scriptlets(self):
if 'scriptlets' in self.config:
self.config['scriptlets'] = self.config['scriptlets'].split(' ')
self.log.debug("Loading scriptlets...")
for scriptlet in self.config['scriptlets']:
self.log.debug("Loading '%s' scriptlet", scriptlet)
scriptlet_obj = Util.string_to_class(self.config['mpf']['paths']['scriptlets'] + "." + scriptlet)(
machine=self,
name=scriptlet.split('.')[1])
self.scriptlets.append(scriptlet_obj)
def _load_scriptlets(self):
if 'scriptlets' in self.config:
self.config['scriptlets'] = self.config['scriptlets'].split(' ')
self.log.debug("Loading scriptlets...")
for scriptlet in self.config['scriptlets']:
self.log.debug("Loading '%s' scriptlet", scriptlet)
scriptlet_obj = Util.string_to_class(self.config['mpf']['paths']['scriptlets'] + "." + scriptlet)(
machine=self,
name=scriptlet.split('.')[1])
self.scriptlets.append(scriptlet_obj)
def _load_scriptlets(self):
if 'mc_scriptlets' in self.machine_config:
self.machine_config['mc_scriptlets'] = (
self.machine_config['mc_scriptlets'].split(' '))
self.log.debug("Loading scriptlets...")
for scriptlet in self.machine_config['mc_scriptlets']:
self.log.debug("Loading '%s' scriptlet", scriptlet)
scriptlet_obj = Util.string_to_class(
self.machine_config['mpf-mc']['paths']['scriptlets'] +
"." + scriptlet)(mc=self,
name=scriptlet.split('.')[1])
self.scriptlets.append(scriptlet_obj)
def _load_core_modules(self):
self.log.debug("Loading core modules...")
for name, module in self.config['mpf']['core_modules'].items():
self.log.debug("Loading '%s' core module", module)
m = Util.string_to_class(module)(self)
setattr(self, name, m)
def _load_plugins(self):
self.log.debug("Loading plugins...")
# TODO: This should be cleaned up. Create a Plugins base class and
# classmethods to determine if the plugins should be used.
for plugin in Util.string_to_list(
self.config['mpf']['plugins']):
self.log.debug("Loading '%s' plugin", plugin)
plugin_obj = Util.string_to_class(plugin)(self)
self.plugins.append(plugin_obj)
def load_devices_config(self, validate=True):
"""Load all devices."""
if validate:
for device_type in self.machine.config['mpf']['device_modules']:
device_cls = Util.string_to_class(device_type)
collection_name, config_name = device_cls.get_config_info()
if config_name not in self.machine.config:
continue
# Get the config section for these devices
collection = getattr(self.machine, collection_name)
config = self.machine.config[config_name]
if not config:
self.machine.config[config_name] = config = {}
if not isinstance(config, dict):
self.raise_config_error("Format of collection {} is invalid.".format(collection_name), 1)
# validate config
for device_name in config: