radis.misc.utils module¶
@author: Erwan
- class Chdir(newPath)[source]¶
Bases:
objectbecause we need to change directory to get into the RADIS folder to find the Git files and version, when imported from another program. This class then ensures we get back in the correct directory.
Examples
Do:
cd = Chdir(os.path.dirname(__file__)) try: (...) except: (...) finally: (...) cd.__del__()
- exception DatabankNotFound[source]¶
Bases:
FileNotFoundErrorUsed when a line database is not found in radis.rc.
- class Default(value)[source]¶
Bases:
objectContains a value. Used to know whether a function argument equal to its default value was explicitly given by the user or not. This allows to prevent user errors.
Examples
Check if a value is Default:
from radis.misc.utils import Default a = Default("42") isinstance(a, Default) >>> True a.value >>> 42
- class NotInstalled(name, info='')[source]¶
Bases:
objectA class to deal with optional packages. Will raise an error only if the package is used (but not if imported only)
Examples
some function = NotInstalled("you should install C drivers") a = some_function # no error a() # will raise the NotInstalled error and display the message
- get_default_arg(func, arg)[source]¶
Get default value of argument
argin functionfuncAdapted from https://stackoverflow.com/questions/12627118/get-a-function-arguments-default-value
- get_files_from_regex(path)[source]¶
Returns a list of absolute paths of all the files whose names match the input regular expression.