libICEpost.src.base.dataStructures.Dictionary
@author: F. Ramognino <federico.ramognino@polimi.it> Last update: 12/06/2023
Attributes
Classes
Ordered dictionary embedding some useful OpenFOAM-like methods. |
Module Contents
- libICEpost.src.base.dataStructures.Dictionary.T
- class libICEpost.src.base.dataStructures.Dictionary.Dictionary(*args, _fileName: str = None, **argv)[source]
Bases:
collections.OrderedDict,libICEpost.src.base.Utilities.UtilitiesOrdered dictionary embedding some useful OpenFOAM-like methods.
- path: str | None
- file: str | None
- classmethod fromFile(fileName: str)[source]
Read the variables stored in a python file (Runs the code in the file and retrieves the local variables)
- Parameters:
fileName (str) – Path of the file
- Returns:
A Dictionary object containing the variables defined in the file.
- Return type:
- lookup(entryName: str, *, varType: T | Iterable[type] = None, **kwargs) T | Any[source]
Same as __getitem__ but embeds error handling and type checking.
- Parameters:
- Raises:
KeyError – If the entry is not found
TypeError – If the type is not consistent with varType
- Returns:
self[entryName]
- Return type:
varType|Any
- pop(entryName: str)[source]
- entryName: str
Name of the entry to look for
Same as dictionary.pop but custom error message
- lookupOrDefault(entryName: str, default: T, fatal: bool = True, **kwargs) T[source]
Lookup of give a default value if not found
- Parameters:
entryName (str) – Name of the entry to look for
default (T) – Instance to return in case the value is not found. It is also used for typeChecking
fatal (bool, optional) – If the type is not consistent rise a TypeError. Defaults to True.
**kwargs (dict[str,object]) – Additional arguments to pass to the checkType function in case of type checking.
- Returns:
self[entryName] if entryName is found, else default
- Return type: