grepros 1.2.2
grep for ROS bag files and live topics
Loading...
Searching...
No Matches
ConsoleSink Class Reference

Prints messages to console. More...

Inheritance diagram for ConsoleSink:
Inheritance graph

Public Member Functions

 __init__ (self, args=None, **kwargs)
 
 emit (self, topic, msg, stamp=None, match=None, index=None)
 Prints separator line and message text.
 
 emit_meta (self)
 Prints source metainfo like bag header, if not already printed.
 
 is_highlighting (self)
 Returns True if sink is configured to highlight matched values.
 
 validate (self)
 Returns whether arguments environment set, populates options, emits error if not.
 
- Public Member Functions inherited from Sink
 __init__ (self, args=None, **kwargs)
 
 __enter__ (self)
 Context manager entry.
 
 __exit__ (self, exc_type, exc_value, traceback)
 Context manager exit, closes sink.
 
 autodetect (cls, target)
 Returns true if target is recognizable as output for this sink class.
 
 bind (self, source)
 Attaches source to sink.
 
 close (self)
 Shuts down output, closing any files or connections.
 
 configure (self, args=None, **kwargs)
 Updates sink configuration.
 
 emit (self, topic, msg, stamp=None, match=None, index=None)
 Outputs ROS message.
 
 emit_meta (self)
 Outputs source metainfo like bag header as debug stream, if not already emitted.
 
 flush (self)
 Writes out any pending data to disk.
 
 is_highlighting (self)
 Returns whether this sink requires highlighted matches.
 
 thread_excepthook (self, text, exc)
 Handles exception, used by background threads.
 
 validate (self)
 Returns whether sink prerequisites are met (like ROS environment set if LiveSink).
 
- Public Member Functions inherited from TextSinkMixin
 __init__ (self, args=None, **kwargs)
 
 format_message (self, msg, highlight=False)
 Returns message as formatted string, optionally highlighted for matches if configured.
 
 message_to_yaml (self, val, top=(), typename=None)
 Returns ROS message or other value as YAML.
 
 validate (self)
 Returns whether arguments are valid, emits error if not, else populates options.
 

Public Attributes

 valid
 
- Public Attributes inherited from Sink
 args
 
 source
 inputs.Source instance bound to this sink
 
 valid
 Result of validate()
 

Static Public Attributes

str CONTEXT_PREFIX_SEP = "-"
 
 DEFAULT_ARGS
 Constructor argument defaults.
 
str MATCH_PREFIX_SEP = ":"
 
str MESSAGE_SEP_TEMPLATE = "{ll0}{sep}{ll1}"
 
str META_LINE_TEMPLATE = "{ll0}{sep} {line}{ll1}"
 
str PREFIX_TEMPLATE = "{pfx0}{batch}{pfx1}{sep0}{sep}{sep1}"
 
str SEP = "---"
 
- Static Public Attributes inherited from Sink
 DEFAULT_ARGS = dict(META=False)
 Constructor argument defaults.
 
tuple FILE_EXTENSIONS = ()
 Auto-detection file extensions for subclasses, as (".ext", )
 
- Static Public Attributes inherited from TextSinkMixin
 DEFAULT_ARGS
 Constructor argument defaults.
 
str NOCOLOR_HIGHLIGHT_WRAPPERS = "**", "**"
 Default highlight wrappers if not color output.
 

Detailed Description

Prints messages to console.

Definition at line 543 of file outputs.py.

Constructor & Destructor Documentation

◆ __init__()

__init__ (   self,
  args = None,
**  kwargs 
)
Parameters
argsarguments as namespace or dictionary, case-insensitive
args.colorFalse or "never" for not using colors in replacements
args.highlighthighlight matched values (default true)
args.metawhether to print metainfo
args.emit_fieldmessage fields to emit if not all
args.noemit_fieldmessage fields to skip in output
args.line_prefixprint source prefix like bag filename on each message line
args.max_field_linesmaximum number of lines to print per field
args.start_linemessage line number to start output from
args.end_linemessage line number to stop output at
args.max_message_linesmaximum number of lines to output per message
args.lines_around_matchnumber of message lines around matched fields to output
args.matched_fields_onlyoutput only the fields where match was found
args.wrap_widthcharacter width to wrap message YAML output at
args.match_wrapperstring to wrap around matched values, both sides if one value, start and end if more than one, or no wrapping if zero values
kwargsany and all arguments as keyword overrides, case-insensitive

Reimplemented from Sink.

Definition at line 581 of file outputs.py.

Member Function Documentation

◆ emit()

emit (   self,
  topic,
  msg,
  stamp = None,
  match = None,
  index = None 
)

Prints separator line and message text.

Reimplemented from Sink.

Definition at line 599 of file outputs.py.

◆ emit_meta()

emit_meta (   self)

Prints source metainfo like bag header, if not already printed.

Reimplemented from Sink.

Definition at line 587 of file outputs.py.

◆ is_highlighting()

is_highlighting (   self)

Returns True if sink is configured to highlight matched values.

Reimplemented from Sink.

Definition at line 621 of file outputs.py.

◆ validate()

validate (   self)

Returns whether arguments environment set, populates options, emits error if not.

Reimplemented from Sink.

Definition at line 626 of file outputs.py.

Member Data Documentation

◆ CONTEXT_PREFIX_SEP

str CONTEXT_PREFIX_SEP = "-"
static

Definition at line 550 of file outputs.py.

◆ DEFAULT_ARGS

DEFAULT_ARGS
static
Initial value:
= dict(COLOR=True, EMIT_FIELD=(), NOEMIT_FIELD=(), HIGHLIGHT=True, META=False,
LINE_PREFIX=True, MAX_FIELD_LINES=None, START_LINE=None,
END_LINE=None, MAX_MESSAGE_LINES=None, LINES_AROUND_MATCH=None,
MATCHED_FIELDS_ONLY=False, WRAP_WIDTH=None, MATCH_WRAPPER=None)

Constructor argument defaults.

Definition at line 554 of file outputs.py.

◆ MATCH_PREFIX_SEP

str MATCH_PREFIX_SEP = ":"
static

Definition at line 549 of file outputs.py.

◆ MESSAGE_SEP_TEMPLATE

str MESSAGE_SEP_TEMPLATE = "{ll0}{sep}{ll1}"
static

Definition at line 547 of file outputs.py.

◆ META_LINE_TEMPLATE

str META_LINE_TEMPLATE = "{ll0}{sep} {line}{ll1}"
static

Definition at line 546 of file outputs.py.

◆ PREFIX_TEMPLATE

str PREFIX_TEMPLATE = "{pfx0}{batch}{pfx1}{sep0}{sep}{sep1}"
static

Definition at line 548 of file outputs.py.

◆ SEP

str SEP = "---"
static

Definition at line 551 of file outputs.py.

◆ valid

valid

Definition at line 631 of file outputs.py.


The documentation for this class was generated from the following file: