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

Method __init__

Lib/zipimport.py:67–100  ·  view source on GitHub ↗
(self, path)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 5

isinstanceFunction · 0.85
ZipImportErrorClass · 0.85
_read_directoryFunction · 0.85
replaceMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected