Skip to content

Instantly share code, notes, and snippets.

@psachin
Last active July 4, 2017 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save psachin/abfc6d9285231bc6141effc60b4d09cb to your computer and use it in GitHub Desktop.
Save psachin/abfc6d9285231bc6141effc60b4d09cb to your computer and use it in GitHub Desktop.
sos/sos/plugins:do_file_sub
import codecs
import re
result, replacement = re.subn(r"^(auth_url[\t\ ]*=[\t\ ]*)(.+)", r"\1****", "auth_url = http://localhost.com:5000/")
print(result, replacement)
with codecs.open("/etc/aodh/aodh.conf", "r", encoding='utf-8') as infile:
for line in infile:
result, replacement = re.subn(r"(^auth_url[\t\ ]*=[\t\ ]*)(.+)", r"\1****", line)
if replacement:
print(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment