MCPcopy
hub / github.com/deadc0de6/dotdrop / _import_sub

Method _import_sub

dotdrop/cfg_yaml.py:1129–1148  ·  view source on GitHub ↗

import the block "key" from "path" patch_func is applied to each element if defined

(self, path, key, mandatory=False, patch_func=None)

Source from the content-addressed store, hash-verified

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

Callers 3

_import_variablesMethod · 0.95
_import_actionsMethod · 0.95

Calls 5

_dbgMethod · 0.95
_load_yamlMethod · 0.95
_get_entryMethod · 0.95
YamlExceptionClass · 0.90
warnMethod · 0.80

Tested by

no test coverage detected