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


Python Util.string_to_list方法代码示例

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


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

示例1: configure_mode_settings

# 需要导入模块: from mpf.system.utility_functions import Util [as 别名]
# 或者: from mpf.system.utility_functions.Util 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'] = Util.string_to_list(
                config['start_events'])
        else:
            config['start_events'] = list()

        if 'stop_events' in config:
            config['stop_events'] = Util.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
开发者ID:HarryXS,项目名称:mpf,代码行数:28,代码来源:mode.py

示例2: validate_config_item2

# 需要导入模块: from mpf.system.utility_functions import Util [as 别名]
# 或者: from mpf.system.utility_functions.Util import string_to_list [as 别名]
    def validate_config_item2(self, spec, validation_failure_info,
                              item='item not in [email protected]#',):

        default = 'default [email protected]#'

        item_type, validation, default = spec.split('|')

        if default.lower() == 'none':
            default = None

        if item == 'item not in [email protected]#':
            if default == 'default [email protected]#':
                log.error('Required setting missing from config file. Run with '
                          'verbose logging and look for the last '
                          'ConfigProcessor entry above this line to see where '
                          'the problem is.')
                sys.exit()
            else:
                item = default

        if item_type == 'single':
            item = self.validate_item(item, validation, validation_failure_info)


        elif item_type == 'list':
            item = Util.string_to_list(item)

            new_list = list()

            for i in item:
                new_list.append(
                    self.validate_item(i, validation, validation_failure_info))

            item = new_list

        elif item_type == 'set':
            item = set(Util.string_to_list(item))

            new_set = set()

            for i in item:
                new_set.add(
                    self.validate_item(i, validation, validation_failure_info))

            item = new_set

        elif item_type == 'dict':
            item = self.validate_item(item, validation,
                                               validation_failure_info)

            if not item:
                item = dict()

        else:
            self.log.error("Invalid Type '%s' in config spec %s:%s", item_type,
                           validation_failure_info[0][0],
                           validation_failure_info[1])
            sys.exit()

        return item
开发者ID:qcapen,项目名称:mpf,代码行数:62,代码来源:config.py

示例3: __init__

# 需要导入模块: from mpf.system.utility_functions import Util [as 别名]
# 或者: from mpf.system.utility_functions.Util import string_to_list [as 别名]
    def __init__(self, machine, name, config, collection=None, validate=True):

        self.shots = list()  # list of strings

        for shot in Util.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()
开发者ID:HarryXS,项目名称:mpf,代码行数:35,代码来源:shot_group.py

示例4: __init__

# 需要导入模块: from mpf.system.utility_functions import Util [as 别名]
# 或者: from mpf.system.utility_functions.Util 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
                    persist_state: boolean|False
                    '''

        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'] = Util.string_to_list(
                config['events_when_complete'])
开发者ID:HarryXS,项目名称:mpf,代码行数:30,代码来源:logic_blocks.py

示例5: __init__

# 需要导入模块: from mpf.system.utility_functions import Util [as 别名]
# 或者: from mpf.system.utility_functions.Util 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['led_settings']['gamma']
        self.whitepoint = Util.string_to_list(
            self.machine.config['led_settings']['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['led_settings']['linear_slope'])
        self.linear_cutoff = (
            self.machine.config['led_settings']['linear_cutoff'])
        self.keyframe_interpolation = (
            self.machine.config['led_settings']['keyframe_interpolation'])
        self.dithering = self.machine.config['led_settings']['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()
开发者ID:HarryXS,项目名称:mpf,代码行数:34,代码来源:fadecandy.py

示例6: bcp_receive_get

# 需要导入模块: from mpf.system.utility_functions import Util [as 别名]
# 或者: from mpf.system.utility_functions.Util import string_to_list [as 别名]
    def bcp_receive_get(self, names, **kwargs):
        """Processes an incoming BCP 'get' command by posting an event
        'bcp_get_<name>'. It's up to an event handler to register for that
        event and to send the response BCP 'set' command.

        """
        for name in Util.string_to_list(names):
            self.machine.events.post('bcp_get_{}'.format(name))
开发者ID:HarryXS,项目名称:mpf,代码行数:10,代码来源:bcp.py

示例7: getOptions

# 需要导入模块: from mpf.system.utility_functions import Util [as 别名]
# 或者: from mpf.system.utility_functions.Util import string_to_list [as 别名]
 def getOptions(self):
     return {
         'force_platform': self.get_platform(),
         'mpfconfigfile': "mpf/mpfconfig.yaml",
         'machine_path': self.getMachinePath(),
         'configfile': Util.string_to_list(self.getConfigFile()),
         'debug': True,
         'bcp': self.get_use_bcp()
            }
开发者ID:HarryXS,项目名称:mpf,代码行数:11,代码来源:MpfTestCase.py

示例8: register_mpfmc_trigger_events

# 需要导入模块: from mpf.system.utility_functions import Util [as 别名]
# 或者: from mpf.system.utility_functions.Util 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 Util.string_to_list(v['start_events']):
                        self.create_trigger_event(event)
                if 'stop_events' in v:
                    for event in Util.string_to_list(v['stop_events']):
                        self.create_trigger_event(event)
        except KeyError:
            pass
开发者ID:HarryXS,项目名称:mpf,代码行数:45,代码来源:bcp.py

示例9: load_config_file

# 需要导入模块: from mpf.system.utility_functions import Util [as 别名]
# 或者: from mpf.system.utility_functions.Util import string_to_list [as 别名]
    def load_config_file(filename, verify_version=True, halt_on_error=True):
        config = FileManager.load(filename, verify_version, halt_on_error)

        if 'config' in config:
            path = os.path.split(filename)[0]

            for file in Util.string_to_list(config['config']):
                full_file = os.path.join(path, file)
                config = Util.dict_merge(config,
                                           Config.load_config_file(full_file))
        return config
开发者ID:HarryXS,项目名称:mpf,代码行数:13,代码来源:config.py

示例10: _load_plugins

# 需要导入模块: from mpf.system.utility_functions import Util [as 别名]
# 或者: from mpf.system.utility_functions.Util 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 Util.string_to_list(
                self.config['mpf']['plugins']):


            self.log.debug("Loading '%s' plugin", plugin)

            pluginObj = self.string_to_class(plugin)(self)
            self.plugins.append(pluginObj)
开发者ID:HarryXS,项目名称:mpf,代码行数:16,代码来源:machine.py

示例11: collect_balls

# 需要导入模块: from mpf.system.utility_functions import Util [as 别名]
# 或者: from mpf.system.utility_functions.Util import string_to_list [as 别名]
    def collect_balls(self, target='home, trough'):
        """Used to ensure that all balls are in contained in ball devices with
        the tag or list of tags you pass.

        Typically this would be used after a game ends, or when the machine is
        reset or first starts up, to ensure that all balls are in devices
        tagged with 'home' and/or 'trough'.

        Args:
            target: A string of the tag name or a list of tags names of the
                ball devices you want all the balls to end up in. Default is
                ['home', 'trough'].

        """
        # I'm embarrassed at how ugly this code is. But meh, it works...

        tag_list = Util.string_to_list(target)

        self.log.debug("Collecting all balls to devices with tags '%s'",
                       tag_list)

        target_devices = set()
        source_devices = set()
        balls_to_collect = False

        for tag in tag_list:
            for device in self.machine.ball_devices.items_tagged(tag):
                target_devices.add(device)

        for device in self.machine.ball_devices:
            if device not in target_devices:
                if device.balls:
                    source_devices.add(device)
                    balls_to_collect = True

        self.log.debug("Ejecting all balls from: %s", source_devices)

        if balls_to_collect:
            self.machine.events.post('collecting_balls')

            for device in target_devices:
                self.machine.events.replace_handler(
                    'balldevice_{}_ball_enter'.format(device.name),
                    self._collecting_balls_entered_callback,
                    target=target)

            for device in source_devices:
                device.eject_all()
        else:
            self.log.debug("All balls are collected")
开发者ID:HarryXS,项目名称:mpf,代码行数:52,代码来源:ball_controller.py

示例12: _load_config_file

# 需要导入模块: from mpf.system.utility_functions import Util [as 别名]
# 或者: from mpf.system.utility_functions.Util import string_to_list [as 别名]
    def _load_config_file(self, filename, verify_version=True, halt_on_error=True):
        config_file = MPFConfigFile(filename, FileManager.load(filename, verify_version, halt_on_error, True))

        try:
            if 'config' in config_file.config:
                path = os.path.split(filename)[0]

                for file in Util.string_to_list(config_file.config['config']):
                    full_file = os.path.join(path, file)
                    new_config = self._load_config_file(full_file)
                    config_file.add_child_file(new_config)
            return config_file
        except TypeError:
            return dict()
开发者ID:missionpinball,项目名称:mpf-wizard,代码行数:16,代码来源:machinewizard.py

示例13: are_balls_collected

# 需要导入模块: from mpf.system.utility_functions import Util [as 别名]
# 或者: from mpf.system.utility_functions.Util import string_to_list [as 别名]
    def are_balls_collected(self, target=None, antitarget=None):
        """Checks to see if all the balls are contained in devices tagged with
        the parameter that was passed.

        Note if you pass a target that's not used in any ball devices, this
        method will return True. (Because you're asking if all balls are
        nowhere, and they always are. :)

        Args:
            target: String or list of strings of the tags you'd like to
                collect the balls to. Default of None will be replaced with
                'home' and 'trough'.

        """
        if not target:
            target = ['home', 'trough']

        self.log.debug("Checking to see if all the balls are in devices tagged"
                       " with '%s'", target)

        if type(target) is str:
            target = Util.string_to_list(target)

        count = 0
        devices = set()

        for tag in target:
            for device in self.machine.ball_devices.items_tagged(tag):
                devices.add(device)

        if len(devices) == 0:
            # didn't find any devices matching that tag, so we return True
            return True

        for device in devices:
            count += device.get_status('balls')
            self.log.debug('Found %s ball(s) in %s. Found %s total',
                           device.get_status('balls'), device.name, count)

        if count == self.machine.ball_controller.num_balls_known:
            self.log.debug("Yes, all balls are collected")
            return True
        else:
            self.log.debug("No, all balls are not collected. Balls Counted: %s. "
                           "Total balls known: %s", count,
                           self.machine.ball_controller.num_balls_known)
            return False
开发者ID:HarryXS,项目名称:mpf,代码行数:49,代码来源:ball_controller.py

示例14: process_random_event_player

# 需要导入模块: from mpf.system.utility_functions import Util [as 别名]
# 或者: from mpf.system.utility_functions.Util import string_to_list [as 别名]
    def process_random_event_player(self, config, mode=None, priority=0):
        # config is localized to 'event_player'
        if self.debug:
            self.log.debug("Processing random_event_player configuration. Priority:"
                       " %s", priority)

        event_keys = set()

        for event_name, events in config.iteritems():
            if type(events) is not list:
                events = Util.string_to_list(events)

            event_keys.add(self.machine.events.add_handler(event_name,
                self._random_event_player_callback, priority,
                event_list=events))

        return self.unload_event_player_events, event_keys
开发者ID:qcapen,项目名称:mpf,代码行数:19,代码来源:events.py

示例15: get_hw_switch_states

# 需要导入模块: from mpf.system.utility_functions import Util [as 别名]
# 或者: from mpf.system.utility_functions.Util import string_to_list [as 别名]
    def get_hw_switch_states(self):

        if not self.initial_states_sent:

            if 'virtual_platform_start_active_switches' in self.machine.config:

                initial_active_switches = [self.machine.switches[x].number for x in
                    Util.string_to_list(
                        self.machine.config['virtual_platform_start_active_switches'])]

                for k, v in self.hw_switches.iteritems():
                    if k in initial_active_switches:
                        self.hw_switches[k] ^= 1

            self.initial_states_sent = True

        else:
            switches = [x for x in self.machine.switches if x.platform == self]

            for switch in switches:
                self.hw_switches[switch.number] = switch.state ^ switch.invert

        return self.hw_switches
开发者ID:HarryXS,项目名称:mpf,代码行数:25,代码来源:virtual.py


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