MCPcopy Index your code
hub / github.com/RustPython/RustPython / get_resource_reader

Function get_resource_reader

Lib/importlib/resources/_common.py:59–72  ·  view source on GitHub ↗

Return the package's loader if it's a ResourceReader.

(package: types.ModuleType)

Source from the content-addressed store, hash-verified

57
58
59def get_resource_reader(package: types.ModuleType) -> Optional[ResourceReader]:
60 """
61 Return the package's loader if it's a ResourceReader.
62 """
63 # We can't use
64 # a issubclass() check here because apparently abc.'s __subclasscheck__()
65 # hook wants to create a weak reference to the object, but
66 # zipimport.zipimporter does not support weak references, resulting in a
67 # TypeError. That seems terrible.
68 spec = package.__spec__
69 reader = getattr(spec.loader, 'get_resource_reader', None) # type: ignore[union-attr]
70 if reader is None:
71 return None
72 return reader(spec.name) # type: ignore[union-attr]
73
74
75@functools.singledispatch

Callers

nothing calls this directly

Calls 2

getattrFunction · 0.85
readerFunction · 0.85

Tested by

no test coverage detected