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

Method _fill_cache

Lib/importlib/_bootstrap_external.py:1408–1437  ·  view source on GitHub ↗

Fill the cache of potential modules and packages for this directory.

(self)

Source from the content-addressed store, hash-verified

1406 return None
1407
1408 def _fill_cache(self):
1409 """Fill the cache of potential modules and packages for this directory."""
1410 path = self.path
1411 try:
1412 contents = _os.listdir(path or _os.getcwd())
1413 except (FileNotFoundError, PermissionError, NotADirectoryError):
1414 # Directory has either been removed, turned into a file, or made
1415 # unreadable.
1416 contents = []
1417 # We store two cached versions, to handle runtime changes of the
1418 # PYTHONCASEOK environment variable.
1419 if not sys.platform.startswith('win'):
1420 self._path_cache = set(contents)
1421 else:
1422 # Windows users can import modules with case-insensitive file
1423 # suffixes (for legacy reasons). Make the suffix lowercase here
1424 # so it's done once instead of for every import. This is safe as
1425 # the specified suffixes to check against are always specified in a
1426 # case-sensitive manner.
1427 lower_suffix_contents = set()
1428 for item in contents:
1429 name, dot, suffix = item.partition('.')
1430 if dot:
1431 new_name = f'{name}.{suffix.lower()}'
1432 else:
1433 new_name = name
1434 lower_suffix_contents.add(new_name)
1435 self._path_cache = lower_suffix_contents
1436 if sys.platform.startswith(_CASE_INSENSITIVE_PLATFORMS):
1437 self._relaxed_path_cache = {fn.lower() for fn in contents}
1438
1439 @classmethod
1440 def path_hook(cls, *loader_details):

Callers 1

find_specMethod · 0.95

Calls 6

setFunction · 0.85
listdirMethod · 0.80
startswithMethod · 0.45
partitionMethod · 0.45
lowerMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected