earthkit.data.core.temporary¶
Classes¶
Create and return a temporary directory. This has the same |
|
A context manager that temporarily sets environment variables. |
|
The TmpFile objects are designed to be used for temporary files. |
Functions¶
|
|
|
|
|
Create a temporary file with the given extension . |
Module Contents¶
- class earthkit.data.core.temporary.TmpDirectory(*args, **kwargs)¶
Bases:
tempfile.TemporaryDirectoryCreate and return a temporary directory. This has the same behavior as mkdtemp but can be used as a context manager. For example:
- with TemporaryDirectory() as tmpdir:
…
Upon exiting the context, the directory and everything contained in it are removed.
- property path¶
- class earthkit.data.core.temporary.TmpEnv(**kwargs)¶
A context manager that temporarily sets environment variables.
Usage: >>> import os >>> with TmpEnv(CLIMETLAB_TESTS_FOO=”123”, CLIMETLAB_TESTS_BAR=”456”): … print(os.environ[“CLIMETLAB_TESTS_FOO”]) … print(os.environ[“CLIMETLAB_TESTS_BAR”]) … 123 456 >>> print(os.environ.get(“CLIMETLAB_TESTS_FOO”)) None
- kwargs¶
- previous¶
- class earthkit.data.core.temporary.TmpFile(path)¶
The TmpFile objects are designed to be used for temporary files. It ensures that the file is unlinked when the object is out-of-scope (with __del__).
- Parameters:
path (
str) – Actual path of the file.
- cleanup()¶
- path¶
- earthkit.data.core.temporary.temp_directory(dir=None)¶
- earthkit.data.core.temporary.temp_env(**kwargs)¶