python/pycolmap/utils.py
raw| 1 | from collections.abc import MutableSequence |
| 2 | from types import ModuleType |
| 3 | from typing import Any |
| 4 | |
| 5 | |
| 6 | def import_module_symbols( |
| 7 | dst_vars: dict[str, Any], |
| 8 | src_module: ModuleType, |
| 9 | exclude: set[str] | None = None, |
| 10 | ) -> MutableSequence[str]: |
| 11 | symbols = {} |
| 12 | for n, s in vars(src_module).items(): |
| 13 | if n.startswith("_"): |
| 14 | continue |
| 15 | if exclude is not None and n in exclude: |
| 16 | continue |
| 17 | symbols[n] = s |
| 18 | dst_vars.update(symbols) |
| 19 | return list(symbols) |