MCPcopy Create free account
hub / github.com/bpython/bpython / ImportLoader

Class ImportLoader

bpython/curtsiesfrontend/repl.py:256–275  ·  view source on GitHub ↗

Wrapper for module loaders to watch their paths with watchdog.

Source from the content-addressed store, hash-verified

254
255
256class ImportLoader:
257 """Wrapper for module loaders to watch their paths with watchdog."""
258
259 def __init__(self, watcher, loader):
260 self.watcher = watcher
261 self.loader = loader
262
263 def __getattr__(self, name):
264 if name == "create_module" and hasattr(self.loader, name):
265 return self._create_module
266 return getattr(self.loader, name)
267
268 def _create_module(self, spec):
269 module_object = self.loader.create_module(spec)
270 if (
271 getattr(spec, "origin", None) is not None
272 and spec.origin != "builtin"
273 ):
274 self.watcher.track_module(spec.origin)
275 return module_object
276
277
278class ImportFinder:

Callers 1

_find_specMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected