We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d6ecdf1 commit bfaa187Copy full SHA for bfaa187
tools/substitute.py
@@ -0,0 +1,24 @@
1
+import argparse
2
+import os
3
+import os.path
4
+
5
6
+if __name__ == "__main__":
7
+ parser = argparse.ArgumentParser()
8
+ parser.add_argument("--input-file")
9
+ parser.add_argument("--output-file")
10
+ parser.add_argument("--install_dir")
11
+ parser.add_argument("--replace", action="append", nargs=2)
12
+ options = parser.parse_args()
13
14
+ with open(options.input_file, "r") as f:
15
+ contents = f.read()
16
17
+ output_file = os.path.join(options.install_dir, options.output_file)
18
+ os.makedirs(os.path.dirname(output_file), exist_ok=True)
19
20
+ for old, new in options.replace:
21
+ contents = contents.replace(old, new)
22
23
+ with open(output_file, "w") as f:
24
+ f.write(contents)
0 commit comments