setup_util.py 346 B

123456789
  1. import re
  2. # Replaces all text found using the regular expression to_replace with the supplied replacement.
  3. def replace_text(file, to_replace, replacement):
  4. with open(file, "r") as conf:
  5. contents = conf.read()
  6. replaced_text = re.sub(to_replace, replacement, contents)
  7. with open(file, "w") as f:
  8. f.write(replaced_text)