MCPcopy
hub / github.com/beetbox/beets / replace_contents

Method replace_contents

test/plugins/test_edit.py:64–73  ·  view source on GitHub ↗

Modify `filename`, reading its contents and replacing the strings specified in `self.replacements`.

(self, filename, log)

Source from the content-addressed store, hash-verified

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
76class EditMixin(PluginMixin):

Callers

nothing calls this directly

Calls 4

replaceMethod · 0.80
readMethod · 0.45
itemsMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected