get_fpath

sknano.core.get_fpath(fname=None, ext=None, outpath='/home/androo/projects/scikit-nano/scikit-nano/doc/source', overwrite=False, add_fnum=True, fnum=None, include_fname=False, fname_only=False, verbose=False)[source] [edit on github][source]

Generate absolute path to modified fname.

Parameters:
  • fname (str) – Name of file, with or without an extension.
  • ext (str, optional) – File extension to append to fname. If ext is None, then fname is analyzed to see if it likely already has an extension. An extension is set to the last element in the list of strings returned by fname.split('.') if this list has more than 1 element. Otherwise, ext will be set to an empty string ''. If ext is not None and is a valid string, then fname is analyzed to see if it already ends with ext. If fname.endswith(ext) is True from the start, then ext will not be duplicately appended.
  • outpath (str, optional) – Absolute or relative path for generated output file. Default is the absolute path returned by os.getcwd().
  • overwrite (bool, optional) – If True, overwrite an existing file if it has the same generated file path.
  • add_fnum (bool, optional) – Append integer number to output file name, starting with 1.
  • fnum ({None, int}, optional) –

    Starting file number to append if add_fnum is True.

    If the generated file path exists and overwrite is False, setting this parameter has no effect.

  • include_fname (bool, optional) – If True, return (fpath, fname) tuple.
  • fname_only (bool, optional) – If True, return only fname.
  • verbose (bool, optional) – Show verbose output.
Returns:

  • fpath (str) – The concatenation of outpath followed by the updated fname.
  • (fpath, fname) (tuple (only if include_fname is True)) – 2-tuple of strings (fpath, fname).
  • fname (str (only if fname_only is True)) – Updated fname.