feat: add python script for automation

This commit is contained in:
Pranav Santhosh
2022-12-07 20:12:01 +05:30
committed by GitHub
parent ddf996b0a4
commit b0e49b42a6
17720 changed files with 554 additions and 299897 deletions

22
scripts/utils.py Normal file
View File

@@ -0,0 +1,22 @@
import re
def replacetext(file_name: str, search_text: str, replace_text: str) -> None:
"""
Helper function to replace the color in the file.
Can be used to replace any text in the file.
Args:
file_name (str): The file to replace the text in.
search_text (str): The text to be replaced.
replace_text (str): The text to replace with.
Returns:
None
"""
with open(file_name, 'r+') as f:
file = f.read()
file = re.sub(search_text, replace_text, file)
f.seek(0)
f.write(file)
f.truncate()