mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-28 19:20:54 +00:00
tool: add simple replace string helper in python for cmake builds
This commit is contained in:
parent
063853173c
commit
9ee1e74141
20
tool/replace_string.py
Normal file
20
tool/replace_string.py
Normal 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:])
|
Loading…
x
Reference in New Issue
Block a user