setup_util.py 336 B

12345678910
  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. f = open(file, "w")
  8. f.write(replaced_text)
  9. f.close()