How to use the mpf.file_interfaces.yaml_roundtrip.YamlRoundtrip.rename_key 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
'animations')

        if 'cursor_decorators' in element:
            element = self._migrate_decorators(element, 'cursor_decorators',
                                               'cursor_animations')

        if 'color' in element:
            element['color'] = self._get_color(element['color'])

        if 'movie' in element:
            YamlRoundtrip.rename_key('movie', 'video', element, self.log)

            if 'repeat' in element:  # indented on purpose
                YamlRoundtrip.rename_key('repeat', 'loop', element, self.log)
            if 'loops' in element:  # indented on purpose
                YamlRoundtrip.rename_key('loops', 'loop', element, self.log)

        self._convert_tokens(element)

        return element
github missionpinball / mpf / mpf / migrator / config_version_4.py View on Github external
def _migrate_asset_defaults(self):
        # convert asset_defaults to assets:
        if 'asset_defaults' in self.fc:
            self.log.debug('Renaming key: asset_defaults -> assets:')
            YamlRoundtrip.rename_key('asset_defaults', 'assets', self.fc,
                                     self.log)

            assets = self.fc['assets']

            if 'animations' in assets:
                self.log.debug("Converting assets:animations to assets:images")
                if 'images' in assets:
                    self.log.debug("Merging animations: into current "
                                   "asset:images:")
                    YamlRoundtrip.copy_with_comments(assets, 'animations',
                                                     assets, 'images',
                                                     True, self.log)
                else:
                    YamlRoundtrip.rename_key('animations', 'images', assets,
                                             self.log)
                YamlRoundtrip.del_key_with_comments(self.fc, 'animations',
github missionpinball / mpf / mpf / migrator / config_version_4.py View on Github external
def _migrate_animation_assets(self):
        if 'animations' in self.fc:
            self.log.debug("Converting assets:animations to assets:images")
            if 'images' in self.fc:
                self.log.debug("Merging animations: into current "
                               "asset:images:")

                YamlRoundtrip.copy_with_comments(self.fc, 'animations',
                                                 self.fc, 'images',
                                                 True, self.log)

            else:
                YamlRoundtrip.rename_key('animations', 'images', self.fc,
                                         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
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)

            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
def _migrate_light_scripts(self):
        if 'light_scripts' not in self.fc:
            return

        YamlRoundtrip.rename_key('light_scripts', 'shows', self.fc, self.log)

        for show_contents in self.fc['shows'].values():
            self._convert_tocks_to_time(show_contents)

            for step in show_contents:

                if 'color' in step:
                    step['color'] = self._get_color(step['color'])
                    if len(str(step['color'])) > 2:
                        YamlRoundtrip.rename_key('color', '(leds)', step,
                                                 self.log)
                        step['leds'] = CommentedMap()
                        YamlRoundtrip.copy_with_comments(step, '(leds)',
                                                         step['leds'], '(leds)', True, self.log)
                    else:
                        YamlRoundtrip.rename_key('color', '(lights)', step,
                                                 self.log)
                        step['lights'] = CommentedMap()
                        YamlRoundtrip.copy_with_comments(step, '(lights)',
                                                         step['lights'], '(lights)', True, self.log)
github missionpinball / mpf / mpf / migrator / config_version_4.py View on Github external
text='text',
                        shape='shape',
                        animation='animation',
                        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':
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
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