def apply_matches(d):
 some_map = list(d.values())[0]
 keys = some_map.keys()
 if (('tag' in keys) and (not equal_fields(d, 'tag'))):
  return
 if ('artist' in keys):
  if equal_fields(d, 'artist'):
   artist = some_map['artist']
   title_field = 'title'
  elif equal_fields(d, 'title'):
   artist = some_map['title']
   title_field = 'artist'
  else:
   return
  for item in d:
   if (not item.artist):
    item.artist = artist
 else:
  title_field = 'title'
 for item in d:
  if bad_title(item.title):
   item.title = six.text_type(d[item][title_field])
  if (('track' in d[item]) and (item.track == 0)):
   item.track = int(d[item]['track'])

def apply_matches ( d ) : some_map = list ( d . values ( ) ) [ 0 ] keys = some_map . keys ( ) if ( ( 'tag' in keys ) and ( not equal_fields ( d , 'tag' ) ) ) : return if ( 'artist' in keys ) : if equal_fields ( d , 'artist' ) : artist = some_map [ 'artist' ] title_field = 'title' elif equal_fields ( d , 'title' ) : artist = some_map [ 'title' ] title_field = 'artist' else : return for item in d : if ( not item . artist ) : item . artist = artist else : title_field = 'title' for item in d : if bad_title ( item . title ) : item . title = six . text_type ( d [ item ] [ title_field ] ) if ( ( 'track' in d [ item ] ) and ( item . track == 0 ) ) : item . track = int ( d [ item ] [ 'track' ] )
given a mapping from items to field dicts .