parameters: (
          self,
          entry: Union[dict, None] = None,
          prefix: str = '',
      )
return_statement: return None
docstring: Recursively compile input into game-compatible objects in-place
docstring_summary: Recursively compile input into game-compatible objects in-place
docstring_tokens: Recursively compile input into game - compatible objects in - place
function: def convert(
          self,
          entry: Union[dict, None] = None,
          prefix: str = '',
      ) -> Optional[dict]:
          '''
          Recursively compile input into game-compatible objects in-place
          '''
          if entry is None:
              entry = self.data
  
          entry_ids = entry.get('id')
          fg_layer = entry.get('fg')
          bg_layer = entry.get('bg')
  
          if not entry_ids or (not fg_layer and not bg_layer):
              log.warning(
                  'skipping empty entry in %s%s',
                  self.filepath,
                  f' with IDs {prefix}{entry_ids} ' if entry_ids else '',
              )
              return None
  
          # make sure entry_ids is a list
          if entry_ids:
              if not isinstance(entry_ids, list):
                  entry_ids = [entry_ids]
  
          # convert fg value
          if fg_layer:
              entry['fg'] = list_or_first(self.convert_entry_layer(fg_layer))
          else:
              # don't pop at the start because that affects order of the keys
              entry.pop('fg', None)
  
          # convert bg value
          if bg_layer:
              entry['bg'] = list_or_first(self.convert_entry_layer(bg_layer))
          else:
              # don't pop at the start because that affects order of the keys
              entry.pop('bg', None)
  
          # recursively convert additional_tiles value
          additional_entries = entry.get('additional_tiles', [])
          for additional_entry in additional_entries:
              # recursive part
              self.convert(additional_entry, f'{entry_ids[0]}_')
  
          # remember processed IDs and remove duplicates
          for entry_id in entry_ids:
              full_id = f'{prefix}{entry_id}'
  
              if full_id not in self.tilesheet.tileset.processed_ids:
                  self.tilesheet.tileset.processed_ids.append(full_id)
  
              else:
                  entry_ids.remove(entry_id)
  
                  if self.tilesheet.is_filler:
                      if self.tilesheet.tileset.obsolete_fillers:
                          log.warning(
                              'skipping filler for %s from %s',
                              full_id, self.filepath)
  
                  else:
                      log.error(
                          '%s encountered more than once, last time in %s',
                          full_id, self.filepath)
  
          # return converted entry if there are new IDs
          if entry_ids:
              entry['id'] = list_or_first(entry_ids)
              return entry
  
          return None
function_tokens: def convert ( self , entry : Union [ dict , None ] = None , prefix : str = '' , ) -> Optional [ dict ] : if entry is None : entry = self . data entry_ids = entry . get ( 'id' ) fg_layer = entry . get ( 'fg' ) bg_layer = entry . get ( 'bg' ) if not entry_ids or ( not fg_layer and not bg_layer ) : log . warning ( 'skipping empty entry in %s%s' , self . filepath , f' with IDs {prefix}{entry_ids} ' if entry_ids else '' , ) return None # make sure entry_ids is a list if entry_ids : if not isinstance ( entry_ids , list ) : entry_ids = [ entry_ids ] # convert fg value if fg_layer : entry [ 'fg' ] = list_or_first ( self . convert_entry_layer ( fg_layer ) ) else : # don't pop at the start because that affects order of the keys entry . pop ( 'fg' , None ) # convert bg value if bg_layer : entry [ 'bg' ] = list_or_first ( self . convert_entry_layer ( bg_layer ) ) else : # don't pop at the start because that affects order of the keys entry . pop ( 'bg' , None ) # recursively convert additional_tiles value additional_entries = entry . get ( 'additional_tiles' , [ ] ) for additional_entry in additional_entries : # recursive part self . convert ( additional_entry , f'{entry_ids[0]}_' ) # remember processed IDs and remove duplicates for entry_id in entry_ids : full_id = f'{prefix}{entry_id}' if full_id not in self . tilesheet . tileset . processed_ids : self . tilesheet . tileset . processed_ids . append ( full_id ) else : entry_ids . remove ( entry_id ) if self . tilesheet . is_filler : if self . tilesheet . tileset . obsolete_fillers : log . warning ( 'skipping filler for %s from %s' , full_id , self . filepath ) else : log . error ( '%s encountered more than once, last time in %s' , full_id , self . filepath ) # return converted entry if there are new IDs if entry_ids : entry [ 'id' ] = list_or_first ( entry_ids ) return entry return None