#NEWLINE# def increment_filename( filename ) : #NEWLINE# #INDENT# dirname = os . path . dirname ( filename ) #NEWLINE# ( root , ext ) = os . path . splitext ( os . path . basename ( filename ) ) #NEWLINE# result = None #NEWLINE# try : #NEWLINE# #INDENT# ( root_start , root_number_end ) = rx_numbered . match ( root ) . groups ( ) #NEWLINE# #UNINDENT# except AttributeError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# result = ( '%s%s' % ( root_start , str ( ( int ( root_number_end ) + 1 ) ) ) ) #NEWLINE# #UNINDENT# if ( not result ) : #NEWLINE# #INDENT# ( root_start , root_end ) = ( root [ : ( - 1 ) ] , root [ ( - 1 ) ] ) #NEWLINE# if ( root_end in ( 'z' , 'Z' ) ) : #NEWLINE# #INDENT# root_end = ( '%sa' % root_end ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# root_end = chr ( ( ord ( root_end ) + 1 ) ) #NEWLINE# #UNINDENT# result = ( '%s%s' % ( root_start , root_end ) ) #NEWLINE# #UNINDENT# return ( '%(dirname)s%(sep)s%(root)s%(ext)s' % { #NEWLINE# #INDENT# 'dirname' : dirname , #NEWLINE# 'sep' : ( ( dirname and '/' ) or '' ) , #NEWLINE# 'root' : result , #NEWLINE# 'ext' : ext , #NEWLINE# #UNINDENT# } )