34 from optparse
import OptionParser, IndentedHelpFormatter
35 from .color
import colorize, warning, message
41 OptionParser.error(self, msg)
44 _original_wrap = textwrap.wrap
49 for paragraph
in text.split(
'\n'):
56 IndentedHelpFormatter.__init__(self, *args, **kwargs)
59 textwrap.wrap, old = wrap_with_newlines, textwrap.wrap
60 result = IndentedHelpFormatter.format_option(self, text)
68 parser.add_option(
"-o", dest=
"output", metavar=
"FILE",
69 help=
"write output to FILE instead of stdout")
70 parser.add_option(
"--inorder",
"-i", action=
"store_true", dest=
"in_order",
71 help=
"use processing in read order [default]")
72 parser.add_option(
"--legacy", action=
"store_false", dest=
"in_order",
73 help=
"use legacy processing order [deprecated]")
74 parser.add_option(
"--check-order", action=
"store_true", dest=
"do_check_order",
75 help=
"check document for inorder processing", default=
False)
77 parser.add_option(
"--deps", action=
"store_true", dest=
"just_deps",
78 help=
"print file dependencies")
79 parser.add_option(
"--includes", action=
"store_true", dest=
"just_includes",
80 help=
"only process includes [deprecated]")
81 parser.add_option(
"--xacro-ns", action=
"store_false", default=
True, dest=
"xacro_ns",
82 help=
"require xacro namespace prefix for xacro tags")
85 parser.add_option(
"-q", action=
"store_const", dest=
"verbosity", const=0,
86 help=
"quiet operation suppressing warnings")
87 parser.add_option(
"-v", action=
"count", dest=
"verbosity",
88 help=
"increase verbosity")
89 parser.add_option(
"--verbosity", metavar=
'level', dest=
"verbosity", type=
'int',
90 help=textwrap.dedent(
"""\ 92 0: quiet, suppressing warnings 93 1: default, showing warnings and error locations 95 3: log property definitions and usage on top level 96 4: log property definitions and usage on all levels"""))
100 from rosgraph.names
import load_mappings, REMAP
101 mappings = load_mappings(argv)
102 filtered_args = [a
for a
in argv
if REMAP
not in a]
103 except ImportError
as e:
108 parser.set_defaults(just_deps=
False, just_includes=
False, verbosity=1)
109 (options, pos_args) = parser.parse_args(filtered_args)
110 if options.in_order
is None:
112 options.in_order =
not options.just_includes
113 elif options.in_order ==
True:
114 message(
"xacro: in-order processing became default in ROS Melodic. You can drop the option.")
115 if options.in_order ==
False:
116 warning(
"xacro: Legacy processing is deprecated since ROS Jade and will be removed in N-turtle.")
117 message(
"To check for compatibility of your document, use option --check-order.", color=
'yellow')
118 message(
"For more infos, see http://wiki.ros.org/xacro#Processing_Order", color=
'yellow')
120 if options.just_includes:
121 warning(
"xacro: option --includes is deprecated")
125 if options.in_order
and options.just_includes:
126 parser.error(
"options --inorder and --includes are mutually exclusive")
128 if options.do_check_order:
129 options.in_order =
True 131 if len(pos_args) != 1:
133 parser.error(
"expected exactly one input file as argument")
137 options.mappings = mappings
138 return options, pos_args[0]
def wrap_with_newlines(text, width, kwargs)
def message(msg, args, kwargs)
def warning(args, kwargs)
def process_args(argv, require_input=True)
def colorize(msg, color, file=sys.stderr, alt_text=None)