original_docstring: Create a valid output filename. if the name of the file already exists the file name is auto-incremented.
docstring: Create a valid output filename. if the name of the file already exists the file name is auto-incremented.
docstring_tokens: Create a valid output filename . if the name of the file already exists the file name is auto - incremented .
code: def createOutputFileName(path, ext=""):
  	'''Create a valid output filename. if the name of the file already exists the file name is auto-incremented.'''
  	path = os.path.expanduser(path)
  	if not os.path.exists(os.path.dirname(path)):
  		os.makedirs(os.path.dirname(path))
  
  	if not os.path.exists(path):
  		return path
  
  	if len(ext) == 0:
  		root, ext = os.path.splitext(os.path.expanduser(path))
  	else:
  		# use the user supplied extension
  		root, ext2 = os.path.splitext(os.path.expanduser(path))
  
  	dir		= os.path.dirname(root)
  	fname	= os.path.basename(root)
  	candidate = fname+ext
  	index	= 1
  	ls		= set(os.listdir(dir))
  	candidate = "{}_{}{}".format(fname,index,ext)
  	while candidate in ls:
  			candidate = "{}_{}{}".format(fname,index,ext)
  			index	+= 1
  
  	return os.path.join(dir, candidate).replace('\\','/')
code_tokens: def createOutputFileName ( path , ext = "" ) : path = os . path . expanduser ( path ) if not os . path . exists ( os . path . dirname ( path ) ) : os . makedirs ( os . path . dirname ( path ) ) if not os . path . exists ( path ) : return path if len ( ext ) == 0 : root , ext = os . path . splitext ( os . path . expanduser ( path ) ) else : root , ext2 = os . path . splitext ( os . path . expanduser ( path ) ) dir = os . path . dirname ( root ) fname = os . path . basename ( root ) candidate = fname + ext index = 1 ls = set ( os . listdir ( dir ) ) candidate = "{}_{}{}" . format ( fname , index , ext ) while candidate in ls : candidate = "{}_{}{}" . format ( fname , index , ext ) index += 1 return os . path . join ( dir , candidate ) . replace ( '\\' , '/' )
short_docstring: Create a valid output filename.
short_docstring_tokens: Create a valid output filename .
comment: '''Create a valid output filename. if the name of the file already exists the file name is auto-incremented.'''$SEP$# use the user supplied extension