(src, dst, replacements)
| 76 | return f.read() |
| 77 | |
| 78 | def copy_replace(src, dst, replacements): |
| 79 | original = slurp(src) |
| 80 | updated = original |
| 81 | for key, value in replacements.items(): |
| 82 | updated = updated.replace(key, value) |
| 83 | makedirs(os.path.dirname(dst)) |
| 84 | if updated != slurp(dst): |
| 85 | print("Writing", dst, flush=True) |
| 86 | with open(dst, 'w') as f: |
| 87 | f.write(updated) |
| 88 | |
| 89 | def copy_newer(src, dst): |
| 90 | if not os.path.exists(dst) or os.path.getmtime(src) > os.path.getmtime(dst): |