Skip to content

Commit bfaa187

Browse files
linbinyupytorchmergebot
authored andcommitted
move substitute lib to open source (pytorch#79093)
Summary: as title Test Plan: buck build //xplat/caffe2:generated_aten_config_header Reviewed By: kit1980 Differential Revision: D36989348 Pull Request resolved: pytorch#79093 Approved by: https://github.com/malfet
1 parent d6ecdf1 commit bfaa187

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tools/substitute.py

+24
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)