34 from __future__
import print_function
36 from optparse
import OptionParser
42 import genmsg.command_line
44 from genmsg
import MsgGenerationException
45 from . generate
import generate_msg, generate_srv
48 print(
"%(progname)s file(s)"%vars())
51 parser = OptionParser(
"%s file"%(progname))
52 parser.add_option(
'-p', dest=
'package')
53 parser.add_option(
'-o', dest=
'outdir')
54 parser.add_option(
'-I', dest=
'includepath', action=
'append')
55 options, args = parser.parse_args(argv)
58 parser.error(
"please specify args")
59 if not os.path.exists(options.outdir):
64 os.makedirs(options.outdir)
66 if not os.path.exists(options.outdir):
68 search_path = genmsg.command_line.includepath_to_dict(options.includepath)
70 if filename.endswith(
'.msg'):
71 retcode =
generate_msg(options.package, args[1:], options.outdir, search_path)
73 retcode =
generate_srv(options.package, args[1:], options.outdir, search_path)
74 except genmsg.InvalidMsgSpec
as e:
75 print(
"ERROR: ", e, file=sys.stderr)
77 except MsgGenerationException
as e:
78 print(
"ERROR: ", e, file=sys.stderr)
80 except Exception
as e:
84 sys.exit(retcode
or 0)
def generate_msg(pkg, files, out_dir, search_path)
def generate_srv(pkg, files, out_dir, search_path)
def genmain(argv, progname)