Replace old string with new string in file. Args: filename: string for filename. old: string to replace. new: new string to replace to.
(filename, old, new)
| 120 | |
| 121 | |
| 122 | def sed_in_place(filename, old, new): |
| 123 | """Replace old string with new string in file. |
| 124 | |
| 125 | Args: |
| 126 | filename: string for filename. |
| 127 | old: string to replace. |
| 128 | new: new string to replace to. |
| 129 | """ |
| 130 | with open(filename, 'r') as f: |
| 131 | filedata = f.read() |
| 132 | newdata = filedata.replace(old, new) |
| 133 | with open(filename, 'w') as f: |
| 134 | f.write(newdata) |
| 135 | |
| 136 | |
| 137 | def write_to_bazelrc(line): |
no test coverage detected