17 from __future__
import print_function
19 from optparse
import OptionParser
25 import genmsg.command_line
27 from genmsg
import MsgGenerationException
28 from . generate
import generate_msg, generate_srv
31 print(
"%(progname)s file(s)"%vars())
34 parser = OptionParser(
"%s file"%(progname))
35 parser.add_option(
'-p', dest=
'package')
36 parser.add_option(
'-o', dest=
'outdir')
37 parser.add_option(
'-I', dest=
'includepath', action=
'append')
38 options, args = parser.parse_args(argv)
41 parser.error(
"please specify args")
42 if not os.path.exists(options.outdir):
47 os.makedirs(options.outdir)
49 if not os.path.exists(options.outdir):
51 search_path = genmsg.command_line.includepath_to_dict(options.includepath)
53 if filename.endswith(
'.msg'):
54 retcode =
generate_msg(options.package, args[1:], options.outdir, search_path)
56 retcode =
generate_srv(options.package, args[1:], options.outdir, search_path)
57 except genmsg.InvalidMsgSpec
as e:
58 print(
"ERROR: ", e, file=sys.stderr)
60 except MsgGenerationException
as e:
61 print(
"ERROR: ", e, file=sys.stderr)
63 except Exception
as e:
67 sys.exit(retcode
or 0)
def genmain(argv, progname)
def generate_srv(pkg, files, out_dir, search_path)
def generate_msg(pkg, files, out_dir, search_path)