本文整理汇总了Python中mpf.system.config.Config.string_to_list方法的典型用法代码示例。如果您正苦于以下问题:Python Config.string_to_list方法的具体用法?Python Config.string_to_list怎么用?Python Config.string_to_list使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mpf.system.config.Config
的用法示例。
在下文中一共展示了Config.string_to_list方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: configure_mode_settings
# 需要导入模块: from mpf.system.config import Config [as 别名]
# 或者: from mpf.system.config.Config import string_to_list [as 别名]
def configure_mode_settings(self, config):
"""Processes this mode's configuration settings from a config
dictionary.
"""
if not ('priority' in config and type(config['priority']) is int):
config['priority'] = 0
if 'start_events' in config:
config['start_events'] = Config.string_to_list(
config['start_events'])
else:
config['start_events'] = list()
if 'stop_events' in config:
config['stop_events'] = Config.string_to_list(
config['stop_events'])
else:
config['stop_events'] = list()
# register mode start events
if 'start_events' in config:
for event in config['start_events']:
self.machine.events.add_handler(event, self.start)
self.config['mode'] = config
示例2: set_brightness_compensation
# 需要导入模块: from mpf.system.config import Config [as 别名]
# 或者: from mpf.system.config.Config import string_to_list [as 别名]
def set_brightness_compensation(self, value):
"""Sets the brightness compensation for this LED.
args:
value: Str or list (of 1-to-3 items) of the new brightness
compensation value to set. List items are floats. 1.0 is
standard full brightness. 0.0 is off. 2.0 is 200% brightness
(which only comes into play if the LED is not at full
brightness). If the value is a string, it's converted to a list,
broken by commas.
The brightness compensation list is three items long, one for each RGB
element. If the LED has less than three elements, additional values are
ignored.
If the value list is only one item, that value is used for all three
elements.
If the value list is two items, a value of 1.0 is used for the third
item.
"""
if type(value) is not list:
value = Config.string_to_list(value)
value = [float(x) for x in value]
if len(value) == 1:
value.extend([value[0], value[0]])
elif len(value) == 2:
value.append(1.0)
self.config["brightness_compensation"] = value
示例3: __init__
# 需要导入模块: from mpf.system.config import Config [as 别名]
# 或者: from mpf.system.config.Config import string_to_list [as 别名]
def __init__(self, machine, name, config, priority):
"""SequenceShot is where you need certain switches to be hit in the
right order, possibly within a time limit.
Subclass of `Shot`
Args:
machine: The MachineController object
name: String name of this shot.
config: Dictionary that holds the configuration for this shot.
"""
super(SequenceShot, self).__init__(machine, name, config, priority)
self.delay = DelayManager()
self.progress_index = 0
"""Tracks how far along through this sequence the current shot is."""
# convert our switches config to a list
if 'switches' in self.config:
self.config['switches'] = \
Config.string_to_list(self.config['switches'])
# convert our timout to ms
if 'time' in self.config:
self.config['time'] = Timing.string_to_ms(self.config['time'])
else:
self.config['time'] = 0
self.active_delay = False
self.enable()
示例4: disable
# 需要导入模块: from mpf.system.config import Config [as 别名]
# 或者: from mpf.system.config.Config import string_to_list [as 别名]
def disable(self):
"""Disables the shot."""
super(StandardShot, self).disable()
for switch in Config.string_to_list(self.config['switch']):
self.machine.switch_controller.remove_switch_handler(
switch, self._switch_handler)
示例5: enable
# 需要导入模块: from mpf.system.config import Config [as 别名]
# 或者: from mpf.system.config.Config import string_to_list [as 别名]
def enable(self):
"""Enables the shot."""
super(StandardShot, self).enable()
for switch in Config.string_to_list(self.config['switch']):
self.machine.switch_controller.add_switch_handler(
switch, self._switch_handler, return_info=True)
示例6: __init__
# 需要导入模块: from mpf.system.config import Config [as 别名]
# 或者: from mpf.system.config.Config import string_to_list [as 别名]
def __init__(self, machine, config):
super(FadeCandyOPClient, self).__init__(machine, config)
self.log = logging.getLogger('FadeCandyClient')
self.update_every_tick = True
self.gamma = self.machine.config['ledsettings']['gamma']
self.whitepoint = Config.string_to_list(
self.machine.config['ledsettings']['whitepoint'])
self.whitepoint[0] = float(self.whitepoint[0])
self.whitepoint[1] = float(self.whitepoint[1])
self.whitepoint[2] = float(self.whitepoint[2])
self.linear_slope = (
self.machine.config['ledsettings']['linear_slope'])
self.linear_cutoff = (
self.machine.config['ledsettings']['linear_cutoff'])
self.keyframe_interpolation = (
self.machine.config['ledsettings']['keyframe_interpolation'])
self.dithering = self.machine.config['ledsettings']['dithering']
if not self.dithering:
self.disable_dithering()
if not self.keyframe_interpolation:
self.update_every_tick = False
self.set_global_color_correction()
self.write_firmware_options()
示例7: __init__
# 需要导入模块: from mpf.system.config import Config [as 别名]
# 或者: from mpf.system.config.Config import string_to_list [as 别名]
def __init__(self, machine, name, player, config):
self.machine = machine
self.name = name
self.player = player
self.handler_keys = set()
self.enabled = False
config_spec = '''
enable_events: list|None
disable_events: list|None
reset_events: list|None
restart_events: list|None
restart_on_complete: boolean|False
disable_on_complete: boolean|True
'''
self.config = Config.process_config(config_spec=config_spec,
source=config)
if 'events_when_complete' not in config:
self.config['events_when_complete'] = ([
'logicblock_' + self.name + '_complete'])
else:
self.config['events_when_complete'] = Config.string_to_list(
config['events_when_complete'])
if 'reset_each_ball' in config and config['reset_each_ball']:
if 'ball_starting' not in self.config['reset_events']:
self.config['reset_events'].append('ball_starting')
示例8: __init__
# 需要导入模块: from mpf.system.config import Config [as 别名]
# 或者: from mpf.system.config.Config import string_to_list [as 别名]
def __init__(self, machine, name, player, config):
self.machine = machine
self.name = name
self.player = player
self.handler_keys = set()
self.enabled = False
config_spec = """
enable_events: list|None
disable_events: list|None
reset_events: list|None
restart_on_complete: boolean|False
disable_on_complete: boolean|True
"""
self.config = Config.process_config(config_spec=config_spec, source=config)
if "events_when_complete" not in config:
self.config["events_when_complete"] = ["logicblock_" + self.name + "_complete"]
else:
self.config["events_when_complete"] = Config.string_to_list(config["events_when_complete"])
if "reset_each_ball" in config and config["reset_each_ball"]:
if "ball_starting" not in self.config["reset_events"]:
self.config["reset_events"].append("ball_starting")
示例9: __init__
# 需要导入模块: from mpf.system.config import Config [as 别名]
# 或者: from mpf.system.config.Config import string_to_list [as 别名]
def __init__(self, machine, name, config, collection=None, validate=True):
self.shots = list() # list of strings
for shot in Config.string_to_list(config['shots']):
self.shots.append(machine.shots[shot])
# If this device is setup in a machine-wide config, make sure it has
# a default enable event.
# TODO add a mode parameter to the device constructor and do the logic
# there.
if not machine.modes:
if 'enable_events' not in config:
config['enable_events'] = 'ball_starting'
if 'disable_events' not in config:
config['disable_events'] = 'ball_ended'
if 'reset_events' not in config:
config['reset_events'] = 'ball_ended'
if 'profile' in config:
for shot in self.shots:
shot.update_enable_table(profile=config['profile'],
mode=None)
super(ShotGroup, self).__init__(machine, name, config, collection,
validate=validate)
self.rotation_enabled = True
if self.debug:
self._enable_related_device_debugging()
示例10: _load_plugins
# 需要导入模块: from mpf.system.config import Config [as 别名]
# 或者: from mpf.system.config.Config import string_to_list [as 别名]
def _load_plugins(self):
for plugin in Config.string_to_list(
self.config['mpf']['plugins']):
self.log.info("Loading '%s' plugin", plugin)
i = __import__('mpf.plugins.' + plugin, fromlist=[''])
self.plugins.append(i.plugin_class(self))
示例11: register_mpfmc_trigger_events
# 需要导入模块: from mpf.system.config import Config [as 别名]
# 或者: from mpf.system.config.Config import string_to_list [as 别名]
def register_mpfmc_trigger_events(self, config, **kwargs):
"""Scans an MPF config file and creates trigger events for the config
settings that need them.
Args:
config: An MPF config dictionary (can be the machine-wide or a mode-
specific one).
**kwargs: Not used. Included to catch any additional kwargs that may
be associted with this method being registered as an event
handler.
"""
self.log.debug("Registering Trigger Events")
try:
for event in config['show_player'].keys():
self.create_trigger_event(event)
except KeyError:
pass
try:
for event in config['slide_player'].keys():
self.create_trigger_event(event)
except KeyError:
pass
try:
for event in config['event_player'].keys():
self.create_trigger_event(event)
except KeyError:
pass
try:
for k, v in config['sound_player'].iteritems():
if 'start_events' in v:
for event in Config.string_to_list(v['start_events']):
self.create_trigger_event(event)
if 'stop_events' in v:
for event in Config.string_to_list(v['stop_events']):
self.create_trigger_event(event)
except KeyError:
pass
示例12: _configure
# 需要导入模块: from mpf.system.config import Config [as 别名]
# 或者: from mpf.system.config.Config import string_to_list [as 别名]
def _configure(self):
self.config = self.machine.config['languages']
self.machine.language = self
self.languages = Config.string_to_list(
self.machine.config['languages'])
# Set the default language to the first entry in the list
self.set_language(self.languages[0])
self.default_language = self.languages[0]
self.find_text = re.compile('(\(.*?\))')
示例13: _load
# 需要导入模块: from mpf.system.config import Config [as 别名]
# 或者: from mpf.system.config.Config import string_to_list [as 别名]
def _load(self, callback, show_actions=None):
self.show_actions = list()
self.asset_manager.log.debug("Loading Show %s", self.file_name)
if not show_actions:
show_actions = self.load_show_from_disk()
for step_num in range(len(show_actions)):
step_actions = dict()
step_actions['tocks'] = show_actions[step_num]['tocks']
# look for empty steps. If we find them we'll just add their tock
# time to the previous step.
if len(show_actions[step_num]) == 1: # 1 because it still has tocks
show_actions[-1]['tocks'] += step_actions['tocks']
continue
# Events
# make sure events is a list of strings
if ('events' in show_actions[step_num] and
show_actions[step_num]['events']):
event_list = (Config.string_to_list(
show_actions[step_num]['events']))
step_actions['events'] = event_list
# SlidePlayer
if ('display' in show_actions[step_num] and
show_actions[step_num]['display']):
step_actions['display'] = (
self.machine.display.slidebuilder.preprocess_settings(
show_actions[step_num]['display']))
self.show_actions.append(step_actions)
# count how many total locations are in the show. We need this later
# so we can know when we're at the end of a show
self.total_locations = len(self.show_actions)
self.loaded = True
if callback:
callback()
self._asset_loaded()
示例14: _load_plugins
# 需要导入模块: from mpf.system.config import Config [as 别名]
# 或者: from mpf.system.config.Config import string_to_list [as 别名]
def _load_plugins(self):
self.log.info("Loading plugins...")
# TODO: This should be cleaned up. Create a Plugins superclass and
# classmethods to determine if the plugins should be used.
for plugin in Config.string_to_list(
self.config['mpf']['plugins']):
self.log.debug("Loading '%s' plugin", plugin)
i = __import__('mpf.plugins.' + plugin, fromlist=[''])
self.plugins.append(i.plugin_class(self))
示例15: _event_config_to_dict
# 需要导入模块: from mpf.system.config import Config [as 别名]
# 或者: from mpf.system.config.Config import string_to_list [as 别名]
def _event_config_to_dict(self, config):
# processes the enable, disable, and reset events from the config file
return_dict = dict()
if type(config) is dict:
return config
elif type(config) is str:
config = Config.string_to_list(config)
# 'if' instead of 'elif' to pick up just-converted str
if type(config) is list:
for event in config:
return_dict[event] = 0
return return_dict