pingspice.util.TempfileManager(object)
class documentation
Part of pingspice.util
(View In Hierarchy)
I manage temporary files in my temporary file subdirectory, attempting to remove all the ones I've created when Python shuts down.
Class Variable | prefix | The prefix for all temp files. (type: str) |
Instance Variable | tempDir | The subdirectory where I keep all of my temporary files, creating it if necessary. (type: str) |
Instance Variable | filePaths | Full paths of temp files registered for deletion when Python shuts down. (type: set) |
Method | __init__ | TempfileManager() |
Method | __del__ | Removes my temp directory and all files in it when my instance gets deleted. |
Method | new | Generates and returns a new, unique temporary file path, given the supplied extension (a string beginning with or lacking a dot). |
Method | rm | Call with a filePath to delete a single specified file,
immediately unless register is set True . In that case,
registers the file path for deletion when Python shuts down. |
Removes my temp directory and all files in it when my instance gets deleted.
This should work consistently, so long as you never construct your own
instance of me. Do everything through the tempfile
function.
Generates and returns a new, unique temporary file path, given the supplied extension (a string beginning with or lacking a dot).
The file path will be in my temp directory, which I create if necessary.
Creating the actual temp file is up to you, though I will delete it when
Python shuts down or if you call rm
with the
file path. (Set the keep keyword True to prevent that deletion from
happening.)