24 from Cheetah.Template
import Template
28 if __name__ ==
"__main__":
30 parser = argparse.ArgumentParser(description=
'Generate topic relay factory source.')
31 parser.add_argument(
'--msg-srv-names', metavar=
'msg_srv_names', nargs=
'*', help=
'Message/Service Names')
32 parser.add_argument(
'--cpp-tmpl', metavar=
'*.cpp.tmpl', help=
'Input template', required=
True)
33 parser.add_argument(
'--cpp-out', metavar=
'*.cpp', help=
'Output source file', required=
True)
35 args = parser.parse_args()
37 template_namespace = {}
39 template_namespace[
'msg_srv_names'] = args.msg_srv_names
40 template_namespace[
'pkg_names'] = set(s.rsplit(
'/', 1)[0]
for s
in args.msg_srv_names)
46 with open(args.cpp_tmpl,
'r') as f: 47 source_template = Template(f.read(), searchList=[template_namespace]) 50 with open(args.cpp_out,
'w')
as f:
51 f.write(str(source_template))