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

Writes messages to an HTML file. More...

Inheritance diagram for HtmlSink:
Inheritance graph

Public Member Functions

 __init__ (self, args=None, **kwargs)
 
 close (self)
 Closes output file, if any, emits metainfo.
 
 close_output (self)
 Closes output file, if any.
 
 emit (self, topic, msg, stamp=None, match=None, index=None)
 Writes message to output file.
 
 flush (self)
 Writes out any pending data to disk.
 
 format_message (self, msg, highlight=False)
 Returns message as formatted string, optionally highlighted for matches if configured.
 
 is_highlighting (self)
 Returns True if sink is configured to highlight matched values.
 
 validate (self)
 Returns whether write options are valid and ROS environment is set and file is writable, 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 RolloverSinkMixin
 __init__ (self, args=None, **kwargs)
 
 close_output (self)
 Closes output file, if any.
 
 ensure_rollover (self, topic, msg, stamp)
 Closes current output file and prepares new filename if rollover limit reached.
 
 format_output_meta (self)
 Returns output file metainfo string, with names and sizes and message/topic counts.
 
 get_write_options (cls, label)
 Returns command-line help texts for rollover options, as [(name, help)].
 
 make_filename (self)
 Returns new filename for output, accounting for rollover template and overwrite.
 
 validate (self)
 Returns whether write options are valid, emits error if not, else populates options.
 
- 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

 close
 
 filename
 
 valid
 
- Public Attributes inherited from Sink
 args
 
 source
 inputs.Source instance bound to this sink
 
 valid
 Result of validate()
 
- Public Attributes inherited from RolloverSinkMixin
 filename
 Current output file path.
 

Static Public Attributes

 DEFAULT_ARGS
 Constructor argument defaults.
 
tuple FILE_EXTENSIONS = (".htm", ".html")
 Auto-detection file extensions.
 
 TEMPLATE_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "html.tpl")
 HTML template path.
 
int WRAP_WIDTH = 120
 Character wrap width for message YAML.
 
- 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 RolloverSinkMixin
 DEFAULT_ARGS = dict(WRITE=None, WRITE_OPTIONS={}, VERBOSE=False)
 Constructor argument defaults.
 
str FILE_META_TEMPLATE = "{name} ({size})"
 
str MULTI_META_TEMPLATE = "\n- {name} ({size}, {mcount}, {tcount})"
 
list OPTIONS_TEMPLATES
 Command-line help templates for rollover options, as [(name, text with s label placeholder)].
 
str START_META_TEMPLATE = "{mcount} in {tcount} to "
 
- Static Public Attributes inherited from TextSinkMixin
 DEFAULT_ARGS
 Constructor argument defaults.
 
str NOCOLOR_HIGHLIGHT_WRAPPERS = "**", "**"
 Default highlight wrappers if not color output.
 

Additional Inherited Members

- Properties inherited from RolloverSinkMixin
 size = property
 Returns current file size in bytes, or None if size lookup failed.
 

Detailed Description

Writes messages to an HTML file.

Definition at line 30 of file html.py.

Constructor & Destructor Documentation

◆ __init__()

__init__ (   self,
  args = None,
**  kwargs 
)
Parameters
argsarguments as namespace or dictionary, case-insensitive; or a single path as the name of HTML file to write
args.writename of HTML file to write, will add counter like .2 to filename if exists
args.write_options
{"template": path to custom HTML template, if any,
 "overwrite": whether to overwrite existing file
              (default false),
 "rollover-size": bytes limit for individual output files,
 "rollover-count": message limit for individual output files,
 "rollover-duration": time span limit for individual output files,
                      as ROS duration or convertible seconds,
 "rollover-template": output filename template, supporting
                      strftime format codes like "%H-%M-%S"
                      and "%(index)s" as output file index}
args.highlighthighlight matched values (default true)
args.orderby"topic" or "type" if any to group results by
args.colorFalse or "never" for not using colors in replacements
args.emit_fieldmessage fields to emit if not all
args.noemit_fieldmessage fields to skip in output
args.max_field_linesmaximum number of lines to output 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
args.metawhether to emit metainfo
args.verbosewhether to emit debug information
kwargsany and all arguments as keyword overrides,
case-insensitive

Reimplemented from Sink.

Definition at line 88 of file html.py.

Member Function Documentation

◆ close()

close (   self)

Closes output file, if any, emits metainfo.

Reimplemented from Sink.

Definition at line 155 of file html.py.

◆ close_output()

close_output (   self)

Closes output file, if any.

Reimplemented from RolloverSinkMixin.

Definition at line 164 of file html.py.

◆ emit()

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

Writes message to output file.

Reimplemented from Sink.

Definition at line 107 of file html.py.

◆ flush()

flush (   self)

Writes out any pending data to disk.

Reimplemented from Sink.

Definition at line 171 of file html.py.

◆ format_message()

format_message (   self,
  msg,
  highlight = False 
)

Returns message as formatted string, optionally highlighted for matches if configured.

Reimplemented from TextSinkMixin.

Definition at line 175 of file html.py.

◆ is_highlighting()

is_highlighting (   self)

Returns True if sink is configured to highlight matched values.

Reimplemented from Sink.

Definition at line 182 of file html.py.

◆ validate()

validate (   self)

Returns whether write options are valid and ROS environment is set and file is writable, emits error if not.

Reimplemented from Sink.

Definition at line 123 of file html.py.

Member Data Documentation

◆ close

close

Definition at line 105 of file html.py.

◆ DEFAULT_ARGS

DEFAULT_ARGS
static
Initial value:
= dict(META=False, WRITE_OPTIONS={}, HIGHLIGHT=True, MATCH_WRAPPER=None,
ORDERBY=None, VERBOSE=False, COLOR=True, EMIT_FIELD=(), NOEMIT_FIELD=(),
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)

Constructor argument defaults.

Definition at line 43 of file html.py.

◆ FILE_EXTENSIONS

tuple FILE_EXTENSIONS = (".htm", ".html")
static

Auto-detection file extensions.

Definition at line 34 of file html.py.

◆ filename

filename

Definition at line 199 of file html.py.

◆ TEMPLATE_PATH

TEMPLATE_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "html.tpl")
static

HTML template path.

Definition at line 37 of file html.py.

◆ valid

valid

Definition at line 138 of file html.py.

◆ WRAP_WIDTH

int WRAP_WIDTH = 120
static

Character wrap width for message YAML.

Definition at line 40 of file html.py.


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