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

Method resolve

Lib/test/test_pathlib/support/zip_path.py:162–200  ·  view source on GitHub ↗

Traverse zip hierarchy (parents, children and symlinks) starting from this PathInfo. This is called from three places: - When a zip file member is added to ZipFile.filelist, this method populates the ZipPathInfo tree (using create=True). - When ReadableZip

(self, path=None, create=False, follow_symlinks=True)

Source from the content-addressed store, hash-verified

160 return False
161
162 def resolve(self, path=None, create=False, follow_symlinks=True):
163 """
164 Traverse zip hierarchy (parents, children and symlinks) starting
165 from this PathInfo. This is called from three places:
166
167 - When a zip file member is added to ZipFile.filelist, this method
168 populates the ZipPathInfo tree (using create=True).
169 - When ReadableZipPath.info is accessed, this method is finds a
170 ZipPathInfo entry for the path without resolving any final symlink
171 (using follow_symlinks=False)
172 - When ZipPathInfo methods are called with follow_symlinks=True, this
173 method resolves any symlink in the final path position.
174 """
175 link_count = 0
176 stack = path.split('/')[::-1] if path else []
177 info = self
178 while True:
179 if info.is_symlink() and (follow_symlinks or stack):
180 link_count += 1
181 if link_count >= 40:
182 return missing_zip_path_info # Symlink loop!
183 path = info.zip_file.read(info.zip_info).decode()
184 stack += path.split('/')[::-1] if path else []
185 info = info.parent
186
187 if stack:
188 name = stack.pop()
189 else:
190 return info
191
192 if name == '..':
193 info = info.parent
194 elif name and name != '.':
195 if name not in info.children:
196 if create:
197 info.children[name] = ZipPathInfo(info.zip_file, info)
198 else:
199 return missing_zip_path_info # No such child!
200 info = info.children[name]
201
202
203class ZipFileList:

Callers 15

existsMethod · 0.95
is_dirMethod · 0.95
is_fileMethod · 0.95
files_to_testMethod · 0.45
expect_any_treeMethod · 0.45
test_with_segmentsMethod · 0.45
_check_resolveMethod · 0.45
test_resolve_commonMethod · 0.45
test_resolve_dotMethod · 0.45
_check_symlink_loopMethod · 0.45
test_resolve_loopMethod · 0.45

Calls 6

ZipPathInfoClass · 0.85
splitMethod · 0.45
is_symlinkMethod · 0.45
decodeMethod · 0.45
readMethod · 0.45
popMethod · 0.45

Tested by 13

files_to_testMethod · 0.36
expect_any_treeMethod · 0.36
test_with_segmentsMethod · 0.36
_check_resolveMethod · 0.36
test_resolve_commonMethod · 0.36
test_resolve_dotMethod · 0.36
_check_symlink_loopMethod · 0.36
test_resolve_loopMethod · 0.36