temporary_config_dir_path#
- astropy.config.temporary_config_dir_path(dir_=None, /, *, namespace, suffix=None, prefix=None, delete=True)[source]#
A context manager to create a temporary directory and define it as the configuration directory associated with some namespace.
The directory returned will shadow both ASTROPY_CONFIG_DIR and XDG_CONFIG_HOME environment variable if defined.
This may also be used as a decorator on a function to set the config path just within that function.
Thread safety is guaranteed, but concurrency isn’t: only a single thread at a time may execute code within this context.
All arguments from
tempfile.TemporaryDirectoryare optionally supported, with a couple differences:diris positional-only and must come firstall other arguments are keyword-only
Added in version 8.0.
- Parameters:
- dir_path-like object or
None, optional, positional-only The directory in which to create the temporary directory.
None(default) uses the platform default, as intempfile.TemporaryDirectory.- namespace
str, keyword-only A mandatory unique identifier for the namespace associated to a temporary directory, which will used to name the directory itself. This string must be non-empty, and can only contain alphanumeric characters,
_,-or...is special cased to represent a path separator (seeos.sep) in the output directory.- suffix
strorNone, optional, keyword-only Passed to
tempfile.TemporaryDirectory.- prefix
strorNone, optional, keyword-only Passed to
tempfile.TemporaryDirectory.- deletebool, optional, keyword-only
Whether to delete the directory when exiting the context. Default is
True. Passed totempfile.TemporaryDirectory.
- dir_path-like object or
See also
temporary_cache_dir_patha similar function for cache directories
set_temp_configa legacy function with similar goals but a much less predictable behavior