pyarts.utils
This module contains convenience functions for any purposes.
- class pyarts.utils.TempFileHandler(prefix='pyarts', suffix='.tmp', dir=None)[source]
Context manager for creating and deleting temporary files.
This class is a context manager that creates a temporary file and deletes it when the context is exited. The file is automatically removed if an exception occurs.
- Parameters:
- pyarts.utils.deprecated(func=None, new_name=None, message=None)[source]
Decorator which can be used to mark functions as deprecated.
Examples
Calling
foo()
will raise aDeprecationWarning
.>>> @deprecated ... def deprecated_function(): ... pass
Display message with additional information:
>>> @deprecated(message='Additional information message.') ... def deprecated_function(): ... pass
- pyarts.utils.path_append(dirname, path='PATH')[source]
Append a directory to environment path variable.
Append entries to colon-separated variables (e.g. the system path). If the entry is already in the list, it is moved to the end. A path variable is set, if not existing at function call.
- pyarts.utils.path_prepend(dirname, path='PATH')[source]
Prepend a directory to environment path variable.
Append entries to colon-separated variables (e.g. the system path). If the entry is already in the list, it is moved to the end. A path variable is set, if not existing at function call.
- pyarts.utils.path_remove(dirname, path='PATH')[source]
Remove a directory from environment path variable.
Remove entries from colon-separated variables (e.g. the system path). If the path variable is not set, nothing is done.
- pyarts.utils.unique(seq)[source]
Remove duplicates from list whilst keeping the original order
Notes
If you do not care about keeping the order, use this code: >>>> list(set([0, 5, 1, 2, 0, 3, 1,])) [0, 1, 2, 3, 5]
This code is taken from https://stackoverflow.com/a/480227.
- Parameters:
seq – A sequence (list, etc.) of elements.
- Returns:
A list with unique items with original order.
Examples
>>>> unique([0, 5, 1, 2, 0, 3, 1,])