Get the finder for the path entry from sys.path_importer_cache. If the path entry is not in the cache, find the appropriate finder and cache it. If no finder is available, store None.
(cls, path)
| 1232 | |
| 1233 | @classmethod |
| 1234 | def _path_importer_cache(cls, path): |
| 1235 | """Get the finder for the path entry from sys.path_importer_cache. |
| 1236 | |
| 1237 | If the path entry is not in the cache, find the appropriate finder |
| 1238 | and cache it. If no finder is available, store None. |
| 1239 | |
| 1240 | """ |
| 1241 | if path == '': |
| 1242 | try: |
| 1243 | path = _os.getcwd() |
| 1244 | except (FileNotFoundError, PermissionError): |
| 1245 | # Don't cache the failure as the cwd can easily change to |
| 1246 | # a valid directory later on. |
| 1247 | return None |
| 1248 | try: |
| 1249 | finder = sys.path_importer_cache[path] |
| 1250 | except KeyError: |
| 1251 | finder = cls._path_hooks(path) |
| 1252 | sys.path_importer_cache[path] = finder |
| 1253 | return finder |
| 1254 | |
| 1255 | @classmethod |
| 1256 | def _get_spec(cls, fullname, path, target=None): |