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)
| 1210 | |
| 1211 | @classmethod |
| 1212 | def _path_importer_cache(cls, path): |
| 1213 | """Get the finder for the path entry from sys.path_importer_cache. |
| 1214 | |
| 1215 | If the path entry is not in the cache, find the appropriate finder |
| 1216 | and cache it. If no finder is available, store None. |
| 1217 | |
| 1218 | """ |
| 1219 | if path == '': |
| 1220 | try: |
| 1221 | path = _os.getcwd() |
| 1222 | except (FileNotFoundError, PermissionError): |
| 1223 | # Don't cache the failure as the cwd can easily change to |
| 1224 | # a valid directory later on. |
| 1225 | return None |
| 1226 | try: |
| 1227 | finder = sys.path_importer_cache[path] |
| 1228 | except KeyError: |
| 1229 | finder = cls._path_hooks(path) |
| 1230 | sys.path_importer_cache[path] = finder |
| 1231 | return finder |
| 1232 | |
| 1233 | @classmethod |
| 1234 | def _get_spec(cls, fullname, path, target=None): |
no test coverage detected