hyperspy.misc.io.tools module

hyperspy.misc.io.tools.append2pathname(filename, to_append)

Append a string to a path name

Parameters:
  • filename (str) –

  • to_append (str) –

hyperspy.misc.io.tools.ensure_directory(path)

Check if the path exists and if it does not, creates the directory.

hyperspy.misc.io.tools.incremental_filename(filename, i=1)

If a file with the same file name exists, returns a new filename that does not exists.

The new file name is created by appending -n (where n is an integer) to path name

Parameters:
  • filename (str) –

  • i (int) – The number to be appended.

hyperspy.misc.io.tools.overwrite(fname)

If file exists ‘fname’, ask for overwriting and return True or False, else return True.

Parameters:

fname (str or pathlib.Path) – File to check for overwriting.

Returns:

Whether to overwrite file.

Return type:

bool