Modify `filename`, reading its contents and replacing the strings specified in `self.replacements`.
(self, filename, log)
| 62 | f.write(self.contents) |
| 63 | |
| 64 | def replace_contents(self, filename, log): |
| 65 | """Modify `filename`, reading its contents and replacing the strings |
| 66 | specified in `self.replacements`. |
| 67 | """ |
| 68 | with codecs.open(filename, "r", encoding="utf-8") as f: |
| 69 | contents = f.read() |
| 70 | for old, new_ in self.replacements.items(): |
| 71 | contents = contents.replace(old, new_) |
| 72 | with codecs.open(filename, "w", encoding="utf-8") as f: |
| 73 | f.write(contents) |
| 74 | |
| 75 | |
| 76 | class EditMixin(PluginMixin): |