(self, path)
| 60 | # entry in sys.path_importer_cache, fetch the file directory from there |
| 61 | # if found, or else read it from the archive. |
| 62 | def __init__(self, path): |
| 63 | if not isinstance(path, str): |
| 64 | raise TypeError(f"expected str, not {type(path)!r}") |
| 65 | if not path: |
| 66 | raise ZipImportError('archive path is empty', path=path) |
| 67 | if alt_path_sep: |
| 68 | path = path.replace(alt_path_sep, path_sep) |
| 69 | |
| 70 | prefix = [] |
| 71 | while True: |
| 72 | try: |
| 73 | st = _bootstrap_external._path_stat(path) |
| 74 | except (OSError, ValueError): |
| 75 | # On Windows a ValueError is raised for too long paths. |
| 76 | # Back up one path element. |
| 77 | dirname, basename = _bootstrap_external._path_split(path) |
| 78 | if dirname == path: |
| 79 | raise ZipImportError('not a Zip file', path=path) |
| 80 | path = dirname |
| 81 | prefix.append(basename) |
| 82 | else: |
| 83 | # it exists |
| 84 | if (st.st_mode & 0o170000) != 0o100000: # stat.S_ISREG |
| 85 | # it's a not file |
| 86 | raise ZipImportError('not a Zip file', path=path) |
| 87 | break |
| 88 | |
| 89 | if path not in _zip_directory_cache: |
| 90 | _zip_directory_cache[path] = _read_directory(path) |
| 91 | self.archive = path |
| 92 | # a prefix directory following the ZIP file path. |
| 93 | self.prefix = _bootstrap_external._path_join(*prefix[::-1]) |
| 94 | if self.prefix: |
| 95 | self.prefix += path_sep |
| 96 | |
| 97 | |
| 98 | def find_spec(self, fullname, target=None): |
nothing calls this directly
no test coverage detected