Muscat.Helpers.IO.FileTools module

CheckIntegrity(GUI: bool = False)[source]
GetUniqueTempFile(suffix: str = '', prefix: str = 'tmp') Tuple[int, str][source]

Create a unique temporary file on the temp directory

Parameters:
  • suffix (str, optional) – If ‘suffix’ is not None, the file name will end with that suffix, otherwise there will be no suffix., by default “”

  • prefix (str, optional) – If ‘prefix’ is not None, the file name will begin with that prefix, otherwise a default prefix is used., by default ‘tmp’

Returns:

please read the doc of module tempfile.mkstemp

Return type:

Tuple[int,str]

WriteTempFile(filename: str, content: str | bytes, mode: str = 'w') str[source]

Create and fill a temporary file on the temporary folder read the documentation of TemporaryDirectory

Parameters:
  • filename (str) – the name of the file to be created

  • content (str, optional) – the content of the file, by default None

  • mode (str, optional) – read python “open” function documentation for more detail, by default “w”

Returns:

the name of the filename (with the path attached)

Return type:

str

Raises:

Exception – if error during the file creation