Write a file if it is missing or its content is different.
(p: pathlib.Path, data: bytes)
| 160 | |
| 161 | |
| 162 | def 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 | |
| 176 | def write_triples_makefiles( |
no outgoing calls
no test coverage detected