in3Utils.cfgUtils.getModuleConfig
- getModuleConfig(module, avalancheDir='', fileOverride='', batchCfgDir='', modInfo=False, toPrint=True, onlyDefault=False)[source]
Returns the configuration for a given module returns a configParser object OR pathlib.Path (when batchCfgDir is used)
- Priority order:
batchCfgDir (returns Path) -> onlyDefault -> fileOverride -> expert config (CFGs/) -> local_MODULECfg.ini -> MODULECfg.ini
- Parameters
module (module object or pathlib.Path) – The calling function provides the already imported module eg.: from avaframe.com2AB import com2AB leads to getModuleConfig(com2AB) OR: pathlib Path to module (python file)
avalancheDir (str or pathlib.Path) – Path to avalanche directory. If provided and {avalancheDir}/Inputs/CFGs/{moduleName}Cfg.ini exists, that config is taken and only filled up with missing values from the default config. The local_{moduleName}Cfg.ini file is ignored for moduleName then. Default “” skips this check.
fileOverride (str or pathlib.Path) – Allows for a completely different file location. Missing values from the default cfg will always be added. Takes highest priority UNLESS onlyDefault is true.
batchCfgDir (str or pathlib.Path) – Path to directory containing multiple .ini config files for batch processing. When provided, validates the directory exists and contains .ini files, then returns the path as pathlib.Path (not a ConfigParser). Takes highest priority - all other config resolution is skipped.
modInfo (bool) – If True, return tuple (cfg, modDict) with info on differences to standard config. Ignored when batchCfgDir is provided.
toPrint (bool) – If True, print configuration info
onlyDefault (bool) – If True, only use the default configuration (skip all overrides). Ignored when batchCfgDir is provided.
- Returns
ConfigParser object with merged configuration, OR pathlib.Path when batchCfgDir is provided
- Return type
configparser.ConfigParser or pathlib.Path