lezargus.library.temporary module#
Functions to handle the management of a temporary directory for files.
Some of the procedures that are done require the use of a temporary location to write, read, and store files. The temporary directory is generally created on initialization of this module. The user rarely would need access to this function.
- lezargus.library.temporary.create_temporary_directory(directory: str, flag_filename: str | None = None, overwrite: bool = False) None [source]#
Create the temporary directory based on the directory path.
We attempt to create the temporary directory. We check to make sure that it can be made and it does not already exist with files inside and we also add a file description to notify any passerby.
- Parameters:
directory (str) – The directory path to make the temporary directory.
flag_filename (str, default = None) – This is the filename of the file which serves the the description to inform people that the directory is temporary. If None, the file is not written.
overwrite (bool, default = None) – If True, we “overwrite” the temporary directory. We do not actually clear any files, but we do not error when it exists.
- Return type:
None
- lezargus.library.temporary.delete_temporary_directory(directory: str, flag_filename: str | None = None, force: bool = False) None [source]#
Delete the temporary directory based on the directory path.
We attempt to delete the temporary directory. We make sure that it is a temporary directory based on the expected presence of the flag file. We stop if the flag file does not exist.
- Parameters:
directory (str) – The directory path to make the temporary directory.
flag_filename (str, default = None) – This is the filename of the file which serves the the description to inform people that the directory is temporary. If None, this check is skipped.
force (bool, default = None) – Force the deletion of the directory and its contents regardless of the presence of the flag file.
- Return type:
None
- lezargus.library.temporary.write_temporary_directory_file(filename: str) None [source]#
Write the information for the temporary directory file.
We just write a few lines informing the user of the temporary directory. Though we could store the raw text in data, it might complicate initialization so we just have a hard copy here.
- Parameters:
filename (str) – The full filename of the temporary directory file which will be written. If the file already exists, we will overwrite it.
- Return type:
None