mirror of
https://github.com/imarkoff/Marble-shell-theme.git
synced 2025-09-18 01:07:55 -07:00
20 lines
558 B
Python
20 lines
558 B
Python
def replace_keywords(file, *args):
|
|
"""
|
|
Replace file with several keywords
|
|
:param file: file name where keywords must be replaced
|
|
:param args: (keyword, replacement), (...), ...
|
|
"""
|
|
|
|
# skip binary files in project
|
|
if not file.lower().endswith(('.css', '.scss', '.svg')):
|
|
return
|
|
|
|
with open(file, "r") as read_file:
|
|
content = read_file.read()
|
|
|
|
for keyword, replacement in args:
|
|
content = content.replace(keyword, replacement)
|
|
|
|
with open(file, "w") as write_file:
|
|
write_file.write(content)
|