MCPcopy
hub / github.com/szczyglis-dev/py-gpt / _apply_map

Method _apply_map

src/pygpt_net/controller/lang/mapping.py:27–48  ·  view source on GitHub ↗
(self, items, targets, getter_name: str, setter_name: str)

Source from the content-addressed store, hash-verified

25 self.mapping = {}
26
27 def _apply_map(self, items, targets, getter_name: str, setter_name: str):
28 t = trans
29 get = getattr
30 for k, key in items.items():
31 w = targets.get(k)
32 if w is None:
33 continue
34 try:
35 v = t(key)
36 getter = get(w, getter_name, None)
37 setter = get(w, setter_name, None)
38 if setter is None:
39 continue
40 if getter:
41 try:
42 if getter() == v:
43 continue
44 except Exception as e:
45 pass
46 setter(v)
47 except Exception:
48 pass
49
50 def apply(self):
51 """Apply mapped keys"""

Callers 1

applyMethod · 0.95

Calls 3

tFunction · 0.50
getFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected