| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 33c62da commit 7712e28
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -106,7 +106,7 @@ def _schedule_refresh(self, when: float) -> None: | |||
| 106 | 106 | return self._schedule_refresh_callback(when) | |
| 107 | 107 | ||
| 108 | 108 | def _request_reload(self, files_modified: Sequence[str]) -> None: | |
| 109 | - return self._request_reload_callback(files_modified) | ||
| 109 | + return self._request_reload_callback(files_modified=files_modified) | ||
| 110 | 110 | ||
| 111 | 111 | def interrupting_refresh(self) -> None: | |
| 112 | 112 | return self._interrupting_refresh_callback() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -269,54 +269,39 @@ def __init__(self, watcher, loader): | |||
| 269 | 269 | def __getattr__(self, name): | |
| 270 | 270 | if name == "create_module" and hasattr(self.loader, name): | |
| 271 | 271 | return self._create_module | |
| 272 | - if name == "load_module" and hasattr(self.loader, name): | ||
| 273 | - return self._load_module | ||
| 274 | 272 | return getattr(self.loader, name) | |
| 275 | 273 | ||
| 276 | 274 | def _create_module(self, spec): | |
| 277 | - spec = self.loader.create_module(spec) | ||
| 275 | + module_object = self.loader.create_module(spec) | ||
| 278 | 276 | if ( | |
| 279 | 277 | getattr(spec, "origin", None) is not None | |
| 280 | 278 | and spec.origin != "builtin" | |
| 281 | 279 | ): | |
| 282 | 280 | self.watcher.track_module(spec.origin) | |
| 283 | - return spec | ||
| 284 | - | ||
| 285 | - def _load_module(self, name): | ||
| 286 | - module = self.loader.load_module(name) | ||
| 287 | - if hasattr(module, "__file__"): | ||
| 288 | - self.watcher.track_module(module.__file__) | ||
| 289 | - return module | ||
| 281 | + return module_object | ||
| 290 | 282 | ||
| 291 | 283 | ||
| 292 | 284 | class ImportFinder: | |
| 293 | - """Wrapper for finders in sys.meta_path to replace wrap all loaders with ImportLoader.""" | ||
| 285 | + """Wrapper for finders in sys.meta_path to wrap all loaders with ImportLoader.""" | ||
| 294 | 286 | ||
| 295 | - def __init__(self, finder, watcher): | ||
| 287 | + def __init__(self, watcher, finder): | ||
| 296 | 288 | self.watcher = watcher | |
| 297 | 289 | self.finder = finder | |
| 298 | 290 | ||
| 299 | 291 | def __getattr__(self, name): | |
| 300 | 292 | if name == "find_spec" and hasattr(self.finder, name): | |
| 301 | 293 | return self._find_spec | |
| 302 | - if name == "find_module" and hasattr(self.finder, name): | ||
| 303 | - return self._find_module | ||
| 304 | 294 | return getattr(self.finder, name) | |
| 305 | 295 | ||
| 306 | 296 | def _find_spec(self, fullname, path, target=None): | |
| 307 | 297 | # Attempt to find the spec | |
| 308 | 298 | spec = self.finder.find_spec(fullname, path, target) | |
| 309 | 299 | if spec is not None: | |
| 310 | - if getattr(spec, "__loader__", None) is not None: | ||
| 300 | + if getattr(spec, "loader", None) is not None: | ||
| 311 | 301 | # Patch the loader to enable reloading | |
| 312 | - spec.__loader__ = ImportLoader(self.watcher, spec.__loader__) | ||
| 302 | + spec.loader = ImportLoader(self.watcher, spec.loader) | ||
| 313 | 303 | return spec | |
| 314 | 304 | ||
| 315 | - def _find_module(self, fullname, path=None): | ||
| 316 | - loader = self.finder.find_module(fullname, path) | ||
| 317 | - if loader is not None: | ||
| 318 | - return ImportLoader(self.watcher, loader) | ||
| 319 | - | ||
| 320 | 305 | ||
| 321 | 306 | def _process_ps(ps, default_ps: str): | |
| 322 | 307 | """Replace ps1/ps2 with the default if the user specified value contains control characters.""" | |
@@ -607,14 +592,7 @@ def __enter__(self): | |||
| 607 | 592 | if self.watcher: | |
| 608 | 593 | meta_path = [] | |
| 609 | 594 | for finder in sys.meta_path: | |
| 610 | - # All elements get wrapped in ImportFinder instances execepted for instances of | ||
| 611 | - # _SixMetaPathImporter (from six). When importing six, it will check if the importer | ||
| 612 | - # is already part of sys.meta_path and will remove instances. We do not want to | ||
| 613 | - # break this feature (see also #874). | ||
| 614 | - if type(finder).__name__ == "_SixMetaPathImporter": | ||
| 615 | - meta_path.append(finder) | ||
| 616 | - else: | ||
| 617 | - meta_path.append(ImportFinder(finder, self.watcher)) | ||
| 595 | + meta_path.append(ImportFinder(self.watcher, finder)) | ||
| 618 | 596 | sys.meta_path = meta_path | |
| 619 | 597 | ||
| 620 | 598 | sitefix.monkeypatch_quit() | |
| Back | FazBrowse Home | New Git URL |
0 commit comments