(target: str)
| 4 | |
| 5 | |
| 6 | def find_callable(target: str) -> Callable: |
| 7 | target_module_path, target_callable_path = target.rsplit(".", 1) |
| 8 | target_callable_paths = [target_callable_path] |
| 9 | |
| 10 | target_module = None |
| 11 | while len(target_module_path): |
| 12 | try: |
| 13 | target_module = importlib.import_module(target_module_path) |
| 14 | break |
| 15 | except Exception as e: |
| 16 | target_module_path, target_callable_path = target_module_path.rsplit(".", 1) |
| 17 | if len(target_module_path) == 0: |
| 18 | raise e |
| 19 | target_callable_paths.append(target_callable_path) |
| 20 | target_callable = target_module |
| 21 | for attr in reversed(target_callable_paths): |
| 22 | target_callable = getattr(target_callable, attr) |
| 23 | |
| 24 | return target_callable |
| 25 | |
| 26 | |
| 27 | def instantiate(config, target="_ltp_target_", partial="_ltp_partial_"): |
no outgoing calls
no test coverage detected