How to use the mpf.file_interfaces.yaml_roundtrip.YamlRoundtrip.del_key_with_comments function in mpf

To help you get started, we’ve selected a few mpf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github missionpinball / mpf / mpf / migrator / config_version_4.py View on Github external
def _migrate_layer(self, element):
        # Migrate layer
        YamlRoundtrip.rename_key('layer', 'z', element, self.log)
        YamlRoundtrip.rename_key('h_pos', 'anchor_x', element, self.log)
        YamlRoundtrip.rename_key('v_pos', 'anchor_y', element, self.log)
        YamlRoundtrip.rename_key('font', 'style', element, self.log)
        YamlRoundtrip.rename_key('shade', 'brightness', element, self.log)
        YamlRoundtrip.del_key_with_comments(element, 'pixel_spacing', self.log)
        YamlRoundtrip.del_key_with_comments(element, 'antialias', self.log)
        YamlRoundtrip.del_key_with_comments(element, 'thickness', self.log)
        YamlRoundtrip.del_key_with_comments(element, 'bg_shade', self.log)
        YamlRoundtrip.del_key_with_comments(element, 'slide', self.log)
        return element
github missionpinball / mpf / mpf / migrator / config_version_4.py View on Github external
show_name = action.pop('script')

                elif 'key' in action:
                    show_name = action.pop('key')

                else:
                    continue

                if 'action' in action and action['action'] == 'start':
                    del action['action']

                this_events_shows[show_name] = action

            self._add_to_show_player(event, this_events_shows)

        YamlRoundtrip.del_key_with_comments(self.fc, 'light_player', self.log)
github missionpinball / mpf / mpf / migrator / config_version_4.py View on Github external
def _migrate_layer(self, element):
        # Migrate layer
        YamlRoundtrip.rename_key('layer', 'z', element, self.log)
        YamlRoundtrip.rename_key('h_pos', 'anchor_x', element, self.log)
        YamlRoundtrip.rename_key('v_pos', 'anchor_y', element, self.log)
        YamlRoundtrip.rename_key('font', 'style', element, self.log)
        YamlRoundtrip.rename_key('shade', 'brightness', element, self.log)
        YamlRoundtrip.del_key_with_comments(element, 'pixel_spacing', self.log)
        YamlRoundtrip.del_key_with_comments(element, 'antialias', self.log)
        YamlRoundtrip.del_key_with_comments(element, 'thickness', self.log)
        YamlRoundtrip.del_key_with_comments(element, 'bg_shade', self.log)
        YamlRoundtrip.del_key_with_comments(element, 'slide', self.log)
        return element
github missionpinball / mpf / mpf / migrator / config_version_4.py View on Github external
# physical color DMD
                YamlRoundtrip.del_key_with_comments(self.fc['dmd'], 'type',
                                                    self.log)
                YamlRoundtrip.rename_key('dmd', 'physical_rgb_dmd', self.fc,
                                         self.log)

            else:  # physical mono DMD
                YamlRoundtrip.del_key_with_comments(self.fc['dmd'], 'type',
                                                    self.log)

                YamlRoundtrip.rename_key('dmd', 'physical_dmd', self.fc,
                                         self.log)

            YamlRoundtrip.del_key_with_comments(self.fc['displays']['dmd'],
                                                'physical', self.log)
            YamlRoundtrip.del_key_with_comments(self.fc['displays']['dmd'],
                                                'shades', self.log)
            YamlRoundtrip.del_key_with_comments(self.fc['displays']['dmd'],
                                                'fps', self.log)
github missionpinball / mpf / mpf / migrator / config_version_4.py View on Github external
keys_to_keep = set(self.mpf_config_spec[section_name].keys())
            empty_entries = set()

            self.log.debug("Converting %s: section", section_name)

            if self.fc[section_name]:

                for name, settings in self.fc[section_name].items():
                    self.log.debug("Converting %s:%s:", section_name, name)
                    if isinstance(settings, dict):
                        keys = set(settings.keys())
                        keys_to_remove = keys - keys_to_keep

                        for key in keys_to_remove:
                            YamlRoundtrip.del_key_with_comments(settings, key,
                                                                self.log)

                    if not settings:
                        self.log.debug("%s:%s: is now empty. Will remove it.",
                                       section_name, name)
                        empty_entries.add(name)

                for name in empty_entries:
                    YamlRoundtrip.del_key_with_comments(self.fc[section_name],
                                                        name, self.log)

            if not self.fc[section_name]:
                self.log.debug("%s: is now empty. Will remove it.",
                               section_name)
                YamlRoundtrip.del_key_with_comments(self.fc, section_name,
                                                    self.log)
github missionpinball / mpf / mpf / migrator / config_version_4.py View on Github external
element['y'] = self._format_anchor_and_value('bottom', element['y'])
            elif element['anchor_y'] in ('middle', 'center'):
                element['y'] = self._format_anchor_and_value('middle', element['y'])
            elif element['anchor_y'] == 'top':
                element['y'] = self._format_anchor_and_value('top', element['y'])

            self.log.debug("Changing y:%s to y:%s (Based on anchor_y:%s"
                           "and %s height:%s)", old_y, element['y'],
                           element['anchor_y'], display, height)

        except KeyError:
            pass

        try:
            if element['anchor_y'] in ('middle', 'center'):
                YamlRoundtrip.del_key_with_comments(element, 'anchor_y',
                                                    self.log)

        except KeyError:
            pass

        if ('anchor_y' in element and 'y' not in element and
                element['anchor_y'] != 'middle'):
            element['y'] = element['anchor_y']
        return element
github missionpinball / mpf / mpf / migrator / config_version_4.py View on Github external
elif element['anchor_x'] in ('middle', 'center'):
                element['x'] = self._format_anchor_and_value('center', element['x'])

            elif element['anchor_x'] == 'right':
                element['x'] = self._format_anchor_and_value('right', element['x'])

            self.log.debug("Changing x:%s to x:%s (Based on anchor_x:%s"
                           "and %s width:%s)", old_x, element['x'],
                           element['anchor_x'], display, width)

        except KeyError:
            pass

        try:
            if element['anchor_x'] in ('middle', 'center'):
                YamlRoundtrip.del_key_with_comments(element, 'anchor_x',
                                                    self.log)
        except KeyError:
            pass

        if ('anchor_x' in element and 'x' not in element and
                element['anchor_x'] != 'center'):
            element['x'] = element['anchor_x']
        return element
github missionpinball / mpf / mpf / migrator / config_version_4.py View on Github external
image='image',
                        movie='video',
                        character_picker='character_picker',
                        entered_chars='entered_chars')

        # Migrate the element type
        element['type'] = type_map[element_type]

        self.log.debug('Converting "%s" display_element to "%s" widget',
                       element_type, element['type'])

        if element_type == 'text':
            YamlRoundtrip.rename_key('size', 'font_size', element, self.log)

        if element_type != 'dmd':
            YamlRoundtrip.del_key_with_comments(element, 'bg_color', self.log)

        if element_type == 'virtualdmd' and V4Migrator.color_dmd:
            YamlRoundtrip.del_key_with_comments(element, 'pixel_color',
                                                self.log)
            self.log.debug('Changing widget type from "dmd" to "color_dmd"')
            element['type'] = 'color_dmd'

        element = self._migrate_element_x_and_anchor(element, display, height)
        element = self._migrate_element_y_and_anchor(element, display, width)

        if element_type == 'animation':
            element = self._migrate_animation(element)
        elif element_type == 'shape':
            element = self._migrate_shape(element)

        if 'decorators' in element:
github missionpinball / mpf / mpf / migrator / config_version_4.py View on Github external
def _migrate_physical_dmd(self):
        if ('dmd' in self.fc and 'physical' in self.fc['dmd'] and
                self.fc['dmd']['physical']):

            self.log.debug("Converting physical dmd: settings")

            YamlRoundtrip.del_key_with_comments(self.fc['dmd'], 'physical',
                                                self.log)
            YamlRoundtrip.del_key_with_comments(self.fc['dmd'], 'fps',
                                                self.log)

            if 'type' in self.fc['dmd'] and self.fc['dmd']['type'] == 'color':
                # physical color DMD
                YamlRoundtrip.del_key_with_comments(self.fc['dmd'], 'type',
                                                    self.log)
                YamlRoundtrip.rename_key('dmd', 'physical_rgb_dmd', self.fc,
                                         self.log)

            else:  # physical mono DMD
                YamlRoundtrip.del_key_with_comments(self.fc['dmd'], 'type',
                                                    self.log)

                YamlRoundtrip.rename_key('dmd', 'physical_dmd', self.fc,
                                         self.log)