#NEWLINE# def get_available_name( self , name ) : #NEWLINE# #INDENT# ( dir_name , file_name ) = os . path . split ( name ) #NEWLINE# ( file_root , file_ext ) = os . path . splitext ( file_name ) #NEWLINE# md5_sub = hashlib . md5 ( file_root . encode ( 'utf8' ) ) . hexdigest ( ) [ 0 : 6 ] #NEWLINE# file_root = ( time . strftime ( '%Y-%m-%d-%H-%M-%S-' , time . localtime ( ) ) + file_name ) #NEWLINE# name = os . path . join ( dir_name , ( file_root + file_ext ) ) #NEWLINE# count = itertools . count ( 1 ) #NEWLINE# while self . exists ( name ) : #NEWLINE# #INDENT# name = os . path . join ( dir_name , ( '%s_%s%s' % ( file_root , count . next ( ) , file_ext ) ) ) #NEWLINE# #UNINDENT# return name