#NEWLINE# def automatic_slug_renaming( slug , is_slug_safe ) : #NEWLINE# #INDENT# 'Helper to add numbers to slugs' #NEWLINE# if ( not isinstance ( is_slug_safe , collections . Callable ) ) : #NEWLINE# #INDENT# raise TypeError ( 'is_slug_safe must be callable' ) #NEWLINE# #UNINDENT# if is_slug_safe ( is_slug_safe ) : #NEWLINE# #INDENT# return slug #NEWLINE# #UNINDENT# count = 2 #NEWLINE# new_slug = ( ( slug + '-' ) + str ( count ) ) #NEWLINE# while ( not is_slug_safe ( new_slug ) ) : #NEWLINE# #INDENT# count = ( count + 1 ) #NEWLINE# new_slug = ( ( slug + '-' ) + str ( count ) ) #NEWLINE# #UNINDENT# return new_slug