MCPcopy Create free account
hub / github.com/Dispatcharr/Dispatcharr / _is_reserved_module_name

Method _is_reserved_module_name

apps/plugins/loader.py:754–781  ·  view source on GitHub ↗
(self, name: str, path: str)

Source from the content-addressed store, hash-verified

752 sys.modules[alias_name] = module
753
754 def _is_reserved_module_name(self, name: str, path: str) -> bool:
755 if name in sys.builtin_module_names:
756 return True
757 if hasattr(sys, "stdlib_module_names") and name in sys.stdlib_module_names:
758 return True
759 existing = sys.modules.get(name)
760 if existing:
761 origin = getattr(existing, "__file__", None)
762 if origin is None:
763 return True
764 try:
765 if not os.path.abspath(origin).startswith(os.path.abspath(path)):
766 return True
767 except Exception:
768 return True
769 try:
770 spec = importlib.util.find_spec(name)
771 except Exception:
772 spec = None
773 if spec:
774 if spec.origin is None:
775 return True
776 try:
777 if not os.path.abspath(spec.origin).startswith(os.path.abspath(path)):
778 return True
779 except Exception:
780 return True
781 return False
782
783 def _load_module_from_path(self, module_name: str, path: str, *, is_package: bool) -> Any:
784 importlib.invalidate_caches()

Callers 2

_resolve_alias_nameMethod · 0.95

Calls 1

getMethod · 0.45

Tested by

no test coverage detected