def _migrate_light_scripts(self): if 'light_scripts' not in self.fc: return YamlInterface.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: YamlInterface.rename_key('color', '(leds)', step, self.log) step['leds'] = CommentedMap() YamlInterface.copy_with_comments(step, '(leds)', step['leds'], '(leds)', True, self.log) else: YamlInterface.rename_key('color', '(lights)', step, self.log) step['lights'] = CommentedMap() YamlInterface.copy_with_comments(step, '(lights)', step['lights'], '(lights)', True, self.log)
def _migrate_asset_defaults(self): # convert asset_defaults to assets: if 'asset_defaults' in self.fc: self.log.debug('Renaming key: asset_defaults -> assets:') YamlInterface.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:") YamlInterface.copy_with_comments(assets, 'animations', assets, 'images', True, self.log) else: YamlInterface.rename_key('animations', 'images', assets, self.log) YamlInterface.del_key_with_comments(self.fc, 'animations', self.log) if 'movies' in assets: YamlInterface.rename_key('movies', 'videos', assets, self.log) if 'images' in assets: self.log.debug("Converting assets:images:") for settings in assets['images'].values(): YamlInterface.del_key_with_comments(settings, 'target', self.log) if 'sounds' in assets: self.log.debug("Converting assets:sounds:")
def _migrate_show_file(self): self.log.debug("Migrating show file: %s", self.file_name) show_name_stub = os.path.splitext(os.path.split(self.file_name)[1])[0] self._add_show_version() # Convert tocks to time self._convert_tocks_to_time(self.fc) # migrate the components in each step self.log.debug("Converting settings for each show step") slide_num = 0 for i, step in enumerate(self.fc): self._remove_tags(step) if 'display' in step: self.log.debug("Show step %s: Converting 'display' section", i + 1) found_transition = False for widget in step['display']: if 'transition' in widget: found_transition = True break if found_transition: step['display'] = CommentedMap( widgets=self._migrate_elements(step['display'])) for widget in step['display']['widgets']: self._convert_tokens(widget) if 'transition' in widget: YamlInterface.copy_with_comments( widget, 'transition', step['display'], 'transition', True, self.log) else: step['display'] = self._migrate_elements(step['display']) self._convert_tokens(step['display']) YamlInterface.rename_key('display', 'slides', step) slide_num += 1 old_slides = step['slides'] step['slides'] = CommentedMap() step['slides']['{}_slide_{}'.format(show_name_stub, slide_num)] = old_slides return True
def _convert_show_call_to_tokens(cls, settings): token_list = ['light', 'lights', 'leds', 'led'] for token in token_list: if token in settings: if 'show_tokens' not in settings: settings['show_tokens'] = CommentedMap() YamlInterface.copy_with_comments(settings, token, settings['show_tokens'], token, True)
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:") YamlInterface.copy_with_comments(self.fc, 'animations', self.fc, 'images', True, self.log) else: YamlInterface.rename_key('animations', 'images', self.fc, self.log)