tool: add simple replace string helper in python for cmake builds

This commit is contained in:
Matthias Ringwald 2025-01-14 15:16:23 +01:00
parent 063853173c
commit 9ee1e74141

20
tool/replace_string.py Normal file
View File

@ -0,0 +1,20 @@
#!/usr/bin/env python3
# BlueKitchen GmbH (c) 2025
# This script replaces a string in a file with another string, introduced to create Ozone project files from CMakeLists.txt
import sys
def replace_string(input_file, output_file, search_string, replacement_string):
with open(input_file, 'r') as infile:
content = infile.read()
modified_content = content.replace(search_string, replacement_string)
with open(output_file, 'w') as outfile:
outfile.write(modified_content)
if __name__ == "__main__":
if len(sys.argv) != 5:
print("Usage: python3 replace_string.py <input_file> <output_file> <search_string> <replacement_string>")
sys.exit(1)
replace_string(*sys.argv[1:])