Files
api/envmaster.py
Xuan Loi 6427f6a04d changes
2026-01-15 11:53:16 +07:00

25 lines
612 B
Python
Executable File

def search_text(file, text, new_text):
f = open(file, 'r')
content = f.read()
print(text, content.find(new_text))
#if len(text) < len(new_text) and content.find(new_text)>=0:
# return
content = content.replace(text, new_text)
f.close()
with open(file, 'w') as f:
f.write(content)
file = './api/settings.py'
text1 = "'PORT': '5424'"
newtext1 = "'PORT': '5423'"
search_text(file, text1, newtext1)
text1 = "MODE = 'dev'"
newtext1 = "MODE = 'prod'"
search_text(file, text1, newtext1)
text1 = "DEBUG = True"
newtext1 = "DEBUG = False"
search_text(file, text1, newtext1)