def _unique_label(previous_labels, label):
 while (label in previous_labels):
  label_split = label.split('.')
  if label_split[(-1)].startswith('copy'):
   copy_num = 1
   if (label_split[(-1)] != 'copy'):
    copy_num = (int(label_split[(-1)][4:]) + 1)
   new_label = ('%s.copy%s' % ('.'.join(label_split[:(-1)]), copy_num))
   label = new_label
  else:
   label += '.copy'
 return label

def _unique_label ( previous_labels , label ) : while ( label in previous_labels ) : label_split = label . split ( '.' ) if label_split [ ( - 1 ) ] . startswith ( 'copy' ) : copy_num = 1 if ( label_split [ ( - 1 ) ] != 'copy' ) : copy_num = ( int ( label_split [ ( - 1 ) ] [ 4 : ] ) + 1 ) new_label = ( '%s.copy%s' % ( '.' . join ( label_split [ : ( - 1 ) ] ) , copy_num ) ) label = new_label else : label += '.copy' return label
returns a unique name if label is already in previous_labels .