Method
_apply_map
(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""" |
Tested by
no test coverage detected