libICEpost.src.base.dataStructures.Dictionary ============================================= .. py:module:: libICEpost.src.base.dataStructures.Dictionary .. autoapi-nested-parse:: @author: F. Ramognino Last update: 12/06/2023 Attributes ---------- .. autoapisummary:: libICEpost.src.base.dataStructures.Dictionary.T Classes ------- .. autoapisummary:: libICEpost.src.base.dataStructures.Dictionary.Dictionary Module Contents --------------- .. py:data:: T .. py:class:: Dictionary(*args, _fileName: str = None, **argv) Bases: :py:obj:`collections.OrderedDict`, :py:obj:`libICEpost.src.base.Utilities.Utilities` Ordered dictionary embedding some useful OpenFOAM-like methods. .. py:attribute:: path :type: str | None .. py:attribute:: file :type: str | None .. py:method:: fromFile(fileName: str) :classmethod: fileName: str Path of the file Read the variables stored in a python file (Runs the code in the file and retrieves the local variables) NOTE: local variable 'this' for this file. You can access the local folder as 'this.path' within the dictionary. .. py:method:: lookup(entryName: str, *, varType: T | Iterable[type] = None) -> T | Any Same as __getitem__ but embeds error handling and type checking. :param entryName: Name of the entry to look for :type entryName: str :param varType: Type of the variable to lookup for. Performes type-checking if it is given. Defaults to None. :type varType: type|Iterable[type], optional :raises KeyError: If the entry is not found :raises TypeError: If the type is not consistent with varType :returns: self[entryName] :rtype: varType|Any .. py:method:: pop(entryName: str) entryName: str Name of the entry to look for Same as dictionary.pop but custom error message .. py:method:: lookupOrDefault(entryName: str, default: T, fatal: bool = True) -> T Lookup of give a default value if not found :param entryName: Name of the entry to look for :type entryName: str :param default: Instance to return in case the value is not found. It is also used for typeChecking :type default: T :param fatal: If the type is not consistent rise a TypeError. Defaults to True. :type fatal: bool, optional :returns: self[entryName] if entryName is found, else default :rtype: T .. py:method:: _correctSubdicts() Convert recursively every subdictionary into Dictionary classes. .. py:method:: __setitem__(*args, **argv) Set self[key] to value. .. py:method:: update(/, dictionary=None, **kwargs) Performs like dict.update() method but recursively updates sub-dictionaries. Accepts both a dictionary and keyword arguments. :param dictionary: Dictionary to update with. Defaults to None. :type dictionary: dict, optional