Files
idapython-src/tools/split_hexrays_templates.py
2019-10-15 15:05:24 +02:00

31 lines
748 B
Python

from argparse import ArgumentParser
p = ArgumentParser()
p.add_argument("-i", "--input", required=True)
p.add_argument("--out-templates", required=True)
p.add_argument("--out-body", required=True)
args = p.parse_args()
templates = []
body = []
with open(args.input) as fin:
lines = fin.readlines()
in_template=False
for line in lines:
if not in_template:
if line.startswith("template <"):
in_template=True
else:
body.append(line)
if in_template:
templates.append(line)
if line.startswith("};"):
in_template = False
with open(args.out_templates, "w") as fout:
fout.write("".join(templates))
with open(args.out_body, "w") as fout:
fout.write("".join(body))