MCPcopy Index your code
hub / github.com/python/cpython / get_resource_reader

Function get_resource_reader

Lib/importlib/resources/_common.py:25–38  ·  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

23
24
25def get_resource_reader(package: types.ModuleType) -> Optional[ResourceReader]:
26 """
27 Return the package's loader if it's a ResourceReader.
28 """
29 # We can't use
30 # a issubclass() check here because apparently abc.'s __subclasscheck__()
31 # hook wants to create a weak reference to the object, but
32 # zipimport.zipimporter does not support weak references, resulting in a
33 # TypeError. That seems terrible.
34 spec = package.__spec__
35 reader = getattr(spec.loader, 'get_resource_reader', None) # type: ignore[union-attr]
36 if reader is None:
37 return None
38 return reader(spec.name) # type: ignore[union-attr]
39
40
41@functools.singledispatch

Callers

nothing calls this directly

Calls 1

readerFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…