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

Function get_importer

Lib/pkgutil.py:210–232  ·  view source on GitHub ↗

Retrieve a finder for the given path item The returned finder is cached in sys.path_importer_cache if it was newly created by a path hook. The cache (or part of it) can be cleared manually if a rescan of sys.path_hooks is necessary.

(path_item)

Source from the content-addressed store, hash-verified

208
209
210def get_importer(path_item):
211 """Retrieve a finder for the given path item
212
213 The returned finder is cached in sys.path_importer_cache
214 if it was newly created by a path hook.
215
216 The cache (or part of it) can be cleared manually if a
217 rescan of sys.path_hooks is necessary.
218 """
219 path_item = os.fsdecode(path_item)
220 try:
221 importer = sys.path_importer_cache[path_item]
222 except KeyError:
223 for path_hook in sys.path_hooks:
224 try:
225 importer = path_hook(path_item)
226 sys.path_importer_cache.setdefault(path_item, importer)
227 break
228 except ImportError:
229 pass
230 else:
231 importer = None
232 return importer
233
234
235def iter_importers(fullname=""):

Callers 4

run_pathFunction · 0.90
iter_importersFunction · 0.85
extend_pathFunction · 0.85
test_iter_importersMethod · 0.85

Calls 1

setdefaultMethod · 0.45

Tested by 1

test_iter_importersMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…