Functions | Variables
grepros.library Namespace Reference

Functions

def grep (args=None, **kwargs)
 
def init (args=None, **kwargs)
 
def sink (args=None, **kwargs)
 
def source (args=None, **kwargs)
 

Variables

list __all__
 
bool _inited = False
 

Function Documentation

◆ grep()

def grepros.library.grep (   args = None,
**  kwargs 
)
Yields matching messages from specified source.

Initializes grepros if not already initialized.

Read from bagfiles: `grep(file="2022-10-*.bag", pattern="cpu")`.

Read from live topics: `grep(live=True, pattern="cpu")`.


@param   args                     arguments as namespace or dictionary, case-insensitive;
                                  or a single path as the ROS bagfile to read,
                                  or one or more {@link grepros.api.Bag Bag} instances
@param   kwargs                   any and all arguments as keyword overrides, case-insensitive
<!--sep-->

Bag source:
@param   args.file                names of ROS bagfiles to read if not all in directory
@param   args.path                paths to scan if not current directory
@param   args.recurse             recurse into subdirectories when looking for bagfiles
@param   args.decompress          decompress archived bags to file directory
@param   args.reindex             make a copy of unindexed bags and reindex them (ROS1 only)
@param   args.orderby             "topic" or "type" if any to group results by
@param   args.bag                 one or more {@link grepros.api.Bag Bag} instances
<!--sep-->

Live source:
@param   args.live                whether reading messages from live ROS topics
@param   args.queue_size_in       subscriber queue size (default 10)
@param   args.ros_time_in         stamp messages with ROS time instead of wall time
<!--sep-->

App source:
@param   args.app                 whether reading messages from iterable or pushed data;
                                  may contain the iterable itself
@param   args.iterable            iterable yielding (topic, msg, stamp) or (topic, msg);
                                  yielding `None` signals end of content
Any source:
@param   args.topic               ROS topics to read if not all
@param   args.type                ROS message types to read if not all
@param   args.skip_topic          ROS topics to skip
@param   args.skip_type           ROS message types to skip
@param   args.start_time          earliest timestamp of messages to read
@param   args.end_time            latest timestamp of messages to read
@param   args.start_index         message index within topic to start from
@param   args.end_index           message index within topic to stop at

@param   args.nth_message         read every Nth message in topic
@param   args.nth_interval        minimum time interval between messages in topic

@param   args.select_field        message fields to use in matching if not all
@param   args.noselect_field      message fields to skip in matching

@param   args.unique              emit messages that are unique in topic
                                  (select_field and noselect_field apply if specified)
@param   args.condition           Python expressions that must evaluate as true
                                  for message to be processable, see ConditionMixin
<!--sep-->

Search&zwj;:
@param   args.pattern             pattern(s) to find in message field values
@param   args.fixed_string        pattern contains ordinary strings, not regular expressions
@param   args.case                use case-sensitive matching in pattern
@param   args.invert              select messages not matching pattern

@param   args.nth_match           emit every Nth match in topic
@param   args.max_count           number of matched messages to emit (per file if bag input)
@param   args.max_per_topic       number of matched messages to emit from each topic
@param   args.max_topics          number of topics to print matches from

@param   args.before              number of messages of leading context to emit before match
@param   args.after               number of messages of trailing context to emit after match
@param   args.context             number of messages of leading and trailing context
                                  to emit around match

@param   args.highlight           highlight matched values
@param   args.match_wrapper       string to wrap around matched values,
                                  both sides if one value, start and end if more than one,
                                  or no wrapping if zero values

@return  {@link grepros.Scanner.GrepMessage GrepMessage} namedtuples
         of (topic, message, timestamp, match, index)

Definition at line 71 of file library.py.

◆ init()

def grepros.library.init (   args = None,
**  kwargs 
)
Initializes ROS version bindings, loads all built-in plugins if dependencies available.

@param   args
@param   args.plugin   one or more extra plugins to load,
                       as full names or instances of Python module/class
@param   kwargs        any and all arguments as keyword overrides, case-insensitive

Definition at line 337 of file library.py.

◆ sink()

def grepros.library.sink (   args = None,
**  kwargs 
)
Convenience for creating a {@link grepros.outputs.Sink Sink} instance from arguments,
{@link grepros.outputs.MultiSink MultiSink} if several outputs.

Initializes grepros if not already initialized.

@param   args                       arguments as namespace or dictionary, case-insensitive;
                                    or a single item as sink target like bag filename
@param   kwargs                     any and all arguments as keyword overrides, case-insensitive
@param   args.app                   provide messages to given callback function
@param   args.console               print matches to console
@param   args.publish               publish matches to live topics
@param   args.write                 file or other target like Postgres database to write,
                                    as "target", or ["target", dict(format="format", ..)]
                                    or [[..target1..], [..target2..], ..]
@param   args.write_options         format-specific options like
                                    {"overwrite": whether to overwrite existing file
                                                  (default false)}
<!--sep-->

Console sink:
@param   args.line_prefix           print source prefix like bag filename on each message line
@param   args.max_field_lines       maximum number of lines to print per field
@param   args.start_line            message line number to start output from
@param   args.end_line              message line number to stop output at
@param   args.max_message_lines     maximum number of lines to output per message
@param   args.lines_around_match    number of message lines around matched fields to output
@param   args.matched_fields_only   output only the fields where match was found
@param   args.wrap_width            character width to wrap message YAML output at
@param   args.match_wrapper         string to wrap around matched values,
                                    both sides if one value, start and end if more than one,
                                    or no wrapping if zero values
<!--sep-->

Console / HTML sink:
@param   args.color                 False or "never" for not using colors in replacements
@param   args.highlight             highlight matched values (default true)
@param   args.emit_field            message fields to emit if not all
@param   args.noemit_field          message fields to skip in output
@param   args.max_field_lines       maximum number of lines to output per field
@param   args.start_line            message line number to start output from
@param   args.end_line              message line number to stop output at
@param   args.max_message_lines     maximum number of lines to output per message
@param   args.lines_around_match    number of message lines around matched fields to output
@param   args.matched_fields_only   output only the fields where match was found
@param   args.wrap_width            character width to wrap message YAML output at
@param   args.match_wrapper         string to wrap around matched values,
                                    both sides if one value, start and end if more than one,
                                    or no wrapping if zero values
<!--sep-->

Topic sink:
@param   args.queue_size_out        publisher queue size (default 10)
@param   args.publish_prefix        output topic prefix, prepended to input topic
@param   args.publish_suffix        output topic suffix, appended to output topic
@param   args.publish_fixname       single output topic name to publish to,
                                    overrides prefix and suffix if given
<!--sep-->

App sink:
@param   args.emit                  callback(topic, msg, stamp, highlighted msg, index in topic)
                                    if any
@param   args.metaemit              callback(metadata dict) if any,
                                    invoked before first emit from source batch
<!--sep-->

Any sink:
@param   args.meta                  whether to print metainfo
@param   args.verbose               whether to print debug information

Definition at line 246 of file library.py.

◆ source()

def grepros.library.source (   args = None,
**  kwargs 
)
Convenience for creating a {@link grepros.inputs.Source Source} instance from arguments.

Initializes grepros if not already initialized.

@param   args                  arguments as namespace or dictionary, case-insensitive;
                               or a single path as the ROS bagfile to read
@param   kwargs                any and all arguments as keyword overrides, case-insensitive
@param   args.file             one or more names of ROS bagfiles to read from
@param   args.live             read messages from live ROS topics instead
@param   args.app              read messages from iterable or pushed data instead;
                               may contain the iterable itself
<!--sep-->

Bag source:
@param   args.file             names of ROS bagfiles to read if not all in directory
@param   args.path             paths to scan if not current directory
@param   args.recurse          recurse into subdirectories when looking for bagfiles
@param   args.orderby          "topic" or "type" if any to group results by
@param   args.decompress       decompress archived bags to file directory
@param   args.reindex          make a copy of unindexed bags and reindex them (ROS1 only)
@param   args.progress         whether to print progress bar
<!--sep-->

Live source:
@param   args.queue_size_in    subscriber queue size (default 10)
@param   args.ros_time_in      stamp messages with ROS time instead of wall time
@param   args.progress         whether to print progress bar
<!--sep-->

App source:
@param   args.iterable         iterable yielding (topic, msg, stamp) or (topic, msg);
                               yielding `None` signals end of content
<!--sep-->

Any source:
@param   args.topic            ROS topics to read if not all
@param   args.type             ROS message types to read if not all
@param   args.skip_topic       ROS topics to skip
@param   args.skip_type        ROS message types to skip
@param   args.start_time       earliest timestamp of messages to read
@param   args.end_time         latest timestamp of messages to read
@param   args.start_index      message index within topic to start from
@param   args.end_index        message index within topic to stop at
@param   args.unique           emit messages that are unique in topic
@param   args.select_field     message fields to use for uniqueness if not all
@param   args.noselect_field   message fields to skip for uniqueness
@param   args.nth_message      read every Nth message in topic
@param   args.nth_interval     minimum time interval between messages in topic
@param   args.condition        Python expressions that must evaluate as true
                               for message to be processable, see ConditionMixin

Definition at line 181 of file library.py.

Variable Documentation

◆ __all__

list grepros.library.__all__
private
Initial value:
1 = [
2  "AppSink", "AppSource", "Bag", "BagSink", "BagSource", "ConsoleSink", "CsvSink", "HtmlSink",
3  "McapBag", "McapSink", "MultiSink", "ParquetSink", "PostgresSink", "Scanner", "Sink", "Source",
4  "SqliteSink", "SqlSink", "TopicSink", "TopicSource",
5  "grep", "init", "sink", "source",
6 ]

Definition at line 367 of file library.py.

◆ _inited

bool grepros.library._inited = False
private

Definition at line 68 of file library.py.



grepros
Author(s): Erki Suurjaak
autogenerated on Sat Jan 6 2024 03:11:30