MCPcopy Create free account
hub / github.com/anthropics/anthropic-sdk-python / read_sdist

Function read_sdist

scripts/utils/check-dist.py:163–183  ·  view source on GitHub ↗

Readers differ in how they take odd headers, so every byte has to be what plain files give

(path: Path)

Source from the content-addressed store, hash-verified

161
162
163def read_sdist(path: Path) -> list[Member]:
164 """Readers differ in how they take odd headers, so every byte has to be what plain files give"""
165 tar = decompress(path.read_bytes(), wbits=31)
166 if tar is None:
167 problems.append(f"{path.name} is not one gzip stream")
168 return []
169
170 members: list[Member] = []
171 expected: list[bytes] = []
172 with tarfile.open(fileobj=io.BytesIO(tar), mode="r:") as archive:
173 for entry in archive:
174 data = tar[entry.offset_data : entry.offset_data + entry.size]
175 executable = bool(entry.mode & 0o111)
176 members.append(Member(entry.name, data, executable))
177
178 plain = tarfile.TarInfo(entry.name)
179 plain.size, plain.mtime, plain.mode = len(data), entry.mtime, 0o755 if executable else 0o644
180 expected += [plain.tobuf(tarfile.PAX_FORMAT), data, bytes(-len(data) % 512)]
181 if tar.rstrip(b"\0") != b"".join(expected).rstrip(b"\0"):
182 problems.append(f"{path.name} has something besides plain files")
183 return members
184
185
186def check_files(

Callers 1

check_sdistFunction · 0.85

Calls 4

decompressFunction · 0.85
openMethod · 0.80
MemberClass · 0.70
appendMethod · 0.45

Tested by

no test coverage detected