#NEWLINE# def generate_new_element( items , prefix , numeric = False ) : #NEWLINE# #INDENT# "Creates a random string with prefix, that is not in 'items' list." #NEWLINE# while True : #NEWLINE# #INDENT# if numeric : #NEWLINE# #INDENT# candidate = ( prefix + generate_random_numeric ( 8 ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# candidate = ( prefix + generate_random_alphanumeric ( 8 ) ) #NEWLINE# #UNINDENT# if ( not ( candidate in items ) ) : #NEWLINE# #INDENT# return candidate #NEWLINE# #UNINDENT# LOG . debug ( ( 'Random collision on %s' % prefix ) )