ROS message grepper.
More...
|
| __init__ (self, args=None, **kwargs) |
|
| __enter__ (self) |
| Context manager entry, does nothing, returns self.
|
|
| __exit__ (self, exc_type, exc_value, traceback) |
| Context manager exit, does nothing.
|
|
| find (self, source, highlight=None) |
| Yields matched and context messages from source.
|
|
| get_match (self, msg) |
| Returns transformed message if all patterns find a match in message, else None.
|
|
| match (self, topic, msg, stamp, highlight=None) |
| Returns matched message if message matches search filters.
|
|
| validate (self, reset=False) |
| Returns whether conditions have valid syntax, prints errors.
|
|
| work (self, source, sink) |
| Greps messages yielded from source and emits matched content to sink.
|
|
|
list | ANY_MATCHES = [((), re.compile("(.*)", re.DOTALL)), (), re.compile("(.?)", re.DOTALL)] |
| Match patterns for global any-match.
|
|
| DEFAULT_ARGS |
| Constructor argument defaults.
|
|
| GrepMessage = collections.namedtuple("BagMessage", "topic message timestamp match index") |
| Namedtuple of (topic name, ROS message, ROS time object, message if matched, index in topic).
|
|
ROS message grepper.
In highlighted results, message field values that match search criteria are modified to wrap the matching parts in MatchMarkers
tags, with numeric field values converted to strings beforehand.
Definition at line 36 of file search.py.
◆ __init__()
__init__ |
( |
|
self, |
|
|
|
args = None , |
|
|
** |
kwargs |
|
) |
| |
- Parameters
-
args | arguments as namespace or dictionary, case-insensitive |
args.pattern | pattern(s) to find in message field values |
args.fixed_string | pattern contains ordinary strings, not regular expressions |
args.case | use case-sensitive matching in pattern |
args.invert | select messages not matching pattern |
args.expression | pattern(s) are a logical expression like 'this AND (this2 OR NOT "skip this")', with elements as patterns to find in message fields |
args.highlight | highlight matched values |
args.before | number of messages of leading context to emit before match |
args.after | number of messages of trailing context to emit after match |
args.context | number of messages of leading and trailing context to emit around match, overrides args.before and args.after |
args.max_count | number of matched messages to emit (per file if bag input) |
args.max_per_topic | number of matched messages to emit from each topic |
args.max_topics | number of topics to emit matches from |
args.nth_match | emit every Nth match in topic, starting from first |
args.select_field | message fields to use in matching if not all |
args.noselect_field | message fields to skip in matching |
args.match_wrapper | string to wrap around matched values in find() and match(), both sides if one value, start and end if more than one, or no wrapping if zero values (default "**") |
kwargs | any and all arguments as keyword overrides, case-insensitive |
Additional arguments when using match() or find(grepros.api.Bag):
- Parameters
-
args.topic | ROS topics to read if not all |
args.type | ROS message types to read if not all |
args.skip_topic | ROS topics to skip |
args.skip_type | ROS message types to skip |
args.start_time | earliest timestamp of messages to read |
args.end_time | latest timestamp of messages to read |
args.start_index | message index within topic to start from |
args.end_index | message index within topic to stop at |
args.unique | emit messages that are unique in topic |
args.nth_message | read every Nth message in topic, starting from first |
args.nth_interval | minimum time interval between messages in topic, as seconds or ROS duration |
args.condition | Python expressions that must evaluate as true for message to be processable, see ConditionMixin |
args.progress | whether to print progress bar |
args.stop_on_error | stop execution on any error like unknown message type |
Definition at line 96 of file search.py.
◆ __enter__()
Context manager entry, does nothing, returns self.
Definition at line 236 of file search.py.
◆ __exit__()
__exit__ |
( |
|
self, |
|
|
|
exc_type, |
|
|
|
exc_value, |
|
|
|
traceback |
|
) |
| |
Context manager exit, does nothing.
Definition at line 241 of file search.py.
◆ find()
find |
( |
|
self, |
|
|
|
source, |
|
|
|
highlight = None |
|
) |
| |
Yields matched and context messages from source.
- Parameters
-
source | inputs.Source or api.Bag instance |
highlight | whether to highlight matched values in message fields, defaults to flag from constructor |
- Returns
- GrepMessage namedtuples of
(topic, message, timestamp, match, index in topic),
where match is matched optionally highlighted message or None
if yielding a context message
Definition at line 143 of file search.py.
◆ get_match()
Returns transformed message if all patterns find a match in message, else None.
Matching field values are converted to strings and surrounded by markers. Returns original message if any-match and sink does not require highlighting.
Definition at line 472 of file search.py.
◆ match()
match |
( |
|
self, |
|
|
|
topic, |
|
|
|
msg, |
|
|
|
stamp, |
|
|
|
highlight = None |
|
) |
| |
Returns matched message if message matches search filters.
- Parameters
-
topic | topic name |
msg | ROS message |
stamp | message ROS timestamp |
highlight | whether to highlight matched values in message fields, defaults to flag from constructor |
- Returns
- original or highlighted message on match else
None
Definition at line 162 of file search.py.
◆ validate()
validate |
( |
|
self, |
|
|
|
reset = False |
|
) |
| |
Returns whether conditions have valid syntax, prints errors.
Definition at line 210 of file search.py.
◆ work()
work |
( |
|
self, |
|
|
|
source, |
|
|
|
sink |
|
) |
| |
Greps messages yielded from source and emits matched content to sink.
- Parameters
-
source | inputs.Source or api.Bag instance |
sink | outputs.Sink instance |
- Returns
- count matched
Definition at line 196 of file search.py.
◆ ANY_MATCHES
list ANY_MATCHES = [((), re.compile("(.*)", re.DOTALL)), (), re.compile("(.?)", re.DOTALL)] |
|
static |
Match patterns for global any-match.
Definition at line 42 of file search.py.
◆ args
◆ args0
◆ DEFAULT_ARGS
Initial value:= dict(PATTERN=(), CASE=False, FIXED_STRING=False, INVERT=False, EXPRESSION=False,
HIGHLIGHT=False, NTH_MATCH=1, BEFORE=0, AFTER=0, CONTEXT=0, MAX_COUNT=0,
MAX_PER_TOPIC=0, MAX_TOPICS=0, SELECT_FIELD=(), NOSELECT_FIELD=(),
MATCH_WRAPPER="**")
Constructor argument defaults.
Definition at line 45 of file search.py.
◆ GrepMessage
GrepMessage = collections.namedtuple("BagMessage", "topic message timestamp match index") |
|
static |
Namedtuple of (topic name, ROS message, ROS time object, message if matched, index in topic).
Definition at line 39 of file search.py.
◆ sink
◆ source
◆ valid
Result of validate()
Definition at line 124 of file search.py.
The documentation for this class was generated from the following file: