Write data to filename Only write changed data to avoid updating timestamps unnecessarily
(filename, data)
| 313 | |
| 314 | |
| 315 | def write_file(filename, data): |
| 316 | """ |
| 317 | Write data to filename |
| 318 | Only write changed data to avoid updating timestamps unnecessarily |
| 319 | """ |
| 320 | if os.path.exists(filename): |
| 321 | with open(filename) as f: |
| 322 | if data == f.read(): |
| 323 | return |
| 324 | |
| 325 | with open(filename, 'w') as fid: |
| 326 | fid.write(data) |
| 327 | |
| 328 | |
| 329 | # Those *Api classes instances know how to output strings for the generated code |