threeML.io.file_utils module

threeML.io.file_utils.file_existing_and_readable(filename) bool[source]
threeML.io.file_utils.fits_file_existing_and_readable(filename) bool[source]

checks if a FITS file exists ignoring extension ({}) info

threeML.io.file_utils.get_random_unique_name()[source]

Returns a name which is random and (with extremely high probability) unique

Returns:

random file name

threeML.io.file_utils.if_directory_not_existing_then_make(directory) None[source]

If the given directory does not exists, then make it

Parameters:

directory – directory to check or make

Returns:

None

threeML.io.file_utils.path_exists_and_is_directory(path) bool[source]
threeML.io.file_utils.sanitize_filename(filename, abspath: bool = False) Path[source]
threeML.io.file_utils.temporary_directory(prefix='', within_directory=None)[source]

This context manager creates a temporary directory in the most secure possible way (with no race condition), and removes it at the end.

Parameters:
  • prefix – the directory name will start with this prefix, if specified

  • within_directory – create within a specific directory (assumed to exist). Otherwise, it will be created in the

default system temp directory (/tmp in unix) :return: the absolute pathname of the provided directory

threeML.io.file_utils.within_directory(directory)[source]