MCPcopy Index your code
hub / github.com/astral-sh/python-build-standalone / write_if_different

Function write_if_different

pythonbuild/utils.py:162–173  ·  view source on GitHub ↗

Write a file if it is missing or its content is different.

(p: pathlib.Path, data: bytes)

Source from the content-addressed store, hash-verified

160
161
162def write_if_different(p: pathlib.Path, data: bytes):
163 """Write a file if it is missing or its content is different."""
164 if p.exists():
165 with p.open("rb") as fh:
166 existing = fh.read()
167 write = existing != data
168 else:
169 write = True
170
171 if write:
172 with p.open("wb") as fh:
173 fh.write(data)
174
175
176def write_triples_makefiles(

Callers 5

write_triples_makefilesFunction · 0.85
write_package_versionsFunction · 0.85
write_cpython_versionFunction · 0.85
write_target_settingsFunction · 0.85
write_dockerfilesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected