import the block "key" from "path" patch_func is applied to each element if defined
(self, path, key, mandatory=False, patch_func=None)
| 1127 | self._import_config(path) |
| 1128 | |
| 1129 | def _import_sub(self, path, key, mandatory=False, patch_func=None): |
| 1130 | """ |
| 1131 | import the block "key" from "path" |
| 1132 | patch_func is applied to each element if defined |
| 1133 | """ |
| 1134 | if self._debug: |
| 1135 | self._dbg(f'import \"{key}\" from \"{path}\"') |
| 1136 | extdict = self._load_yaml(path) |
| 1137 | new = self._get_entry(extdict, key, mandatory=mandatory) |
| 1138 | if patch_func: |
| 1139 | if self._debug: |
| 1140 | self._dbg(f'calling patch: {patch_func}') |
| 1141 | new = patch_func(new) |
| 1142 | if not new and mandatory: |
| 1143 | err = f'no \"{key}\" imported from \"{path}\"' |
| 1144 | self._log.warn(err) |
| 1145 | raise YamlException(err) |
| 1146 | if self._debug: |
| 1147 | self._dbg(f'imported \"{key}\": {new}') |
| 1148 | return new |
| 1149 | |
| 1150 | ######################################################## |
| 1151 | # add/remove entries |
no test coverage detected