Resolve all the modules in the registry that start with the specified path.
(self, path: str)
| 128 | return lambda fn: fn |
| 129 | |
| 130 | def import_prefix(self, path: str) -> None: |
| 131 | """Resolve all the modules in the registry that start with the |
| 132 | specified path. |
| 133 | """ |
| 134 | for module in self.module_registry: |
| 135 | if self.prefix: |
| 136 | key = module.split(self.prefix)[-1].replace(".", "_") |
| 137 | else: |
| 138 | key = module |
| 139 | if ( |
| 140 | not path or module.startswith(path) |
| 141 | ) and key not in self.__dict__: |
| 142 | __import__(module, globals(), locals()) |
| 143 | self.__dict__[key] = globals()[key] = sys.modules[module] |
| 144 | |
| 145 | |
| 146 | _reg = _ModuleRegistry() |