Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
grepros.plugins.auto.html.HtmlSink Class Reference
Inheritance diagram for grepros.plugins.auto.html.HtmlSink:
Inheritance graph
[legend]

Public Member Functions

def __init__ (self, args=None, **kwargs)
 
def close (self)
 
def close_output (self)
 
def emit (self, topic, msg, stamp=None, match=None, index=None)
 
def flush (self)
 
def format_message (self, msg, highlight=False)
 
def is_highlighting (self)
 
def validate (self)
 
- Public Member Functions inherited from grepros.outputs.Sink
def __enter__ (self)
 
def __exit__ (self, exc_type, exc_value, traceback)
 
def autodetect (cls, target)
 
def bind (self, source)
 
def emit_meta (self)
 
def thread_excepthook (self, text, exc)
 
- Public Member Functions inherited from grepros.outputs.RolloverSinkMixin
def ensure_rollover (self, topic, msg, stamp)
 
def format_output_meta (self)
 
def get_write_options (cls, label)
 
def make_filename (self)
 
def size (self)
 
- Public Member Functions inherited from grepros.outputs.TextSinkMixin
def message_to_yaml (self, val, top=(), typename=None)
 

Public Attributes

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

Static Public Attributes

 DEFAULT_ARGS
 Constructor argument defaults. More...
 
tuple FILE_EXTENSIONS = (".htm", ".html")
 Auto-detection file extensions. More...
 
 TEMPLATE_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "html.tpl")
 HTML template path. More...
 
int WRAP_WIDTH = 120
 Character wrap width for message YAML. More...
 
- Static Public Attributes inherited from grepros.outputs.Sink
 DEFAULT_ARGS = dict(META=False)
 Constructor argument defaults. More...
 
tuple FILE_EXTENSIONS = ()
 Auto-detection file extensions for subclasses, as (".ext", ) More...
 
- Static Public Attributes inherited from grepros.outputs.RolloverSinkMixin
 DEFAULT_ARGS = dict(VERBOSE=False, WRITE=None, WRITE_OPTIONS={})
 Constructor argument defaults. More...
 
string FILE_META_TEMPLATE = "{name} ({size})"
 
string 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)]. More...
 
string START_META_TEMPLATE = "{mcount} in {tcount} to "
 
- Static Public Attributes inherited from grepros.outputs.TextSinkMixin
 DEFAULT_ARGS
 Constructor argument defaults. More...
 
string NOCOLOR_HIGHLIGHT_WRAPPERS = "**", "**"
 Default highlight wrappers if not color output. More...
 

Private Member Functions

def _produce (self)
 
def _stream (self)
 

Private Attributes

 _close_printed
 
 _overwrite
 
 _queue
 
 _tag_repls
 
 _tag_rgx
 
 _template_path
 
 _writer
 

Detailed Description

Writes messages to an HTML file.

Definition at line 30 of file html.py.

Constructor & Destructor Documentation

◆ __init__()

def grepros.plugins.auto.html.HtmlSink.__init__ (   self,
  args = None,
**  kwargs 
)
@param   args                       arguments as namespace or dictionary, case-insensitive;
                            or a single path as the name of HTML file to write
@param   args.write                 name of HTML file to write,
                            will add counter like .2 to filename if exists
@param   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}
                            ```
@param   args.highlight             highlight matched values (default true)
@param   args.orderby               "topic" or "type" if any to group results by
@param   args.color                 False or "never" for not using colors in replacements
@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
@param   args.meta                  whether to emit metainfo
@param   args.verbose               whether to emit debug information
@param   kwargs                     any and all arguments as keyword overrides,
                            case-insensitive

Reimplemented from grepros.outputs.Sink.

Definition at line 49 of file html.py.

Member Function Documentation

◆ _produce()

def grepros.plugins.auto.html.HtmlSink._produce (   self)
private
Yields messages from emit queue, as (topic, msg, stamp, match, index).

Definition at line 200 of file html.py.

◆ _stream()

def grepros.plugins.auto.html.HtmlSink._stream (   self)
private
Writer-loop, streams HTML template to file.

Definition at line 176 of file html.py.

◆ close()

def grepros.plugins.auto.html.HtmlSink.close (   self)
Closes output file, if any, emits metainfo.

Reimplemented from grepros.outputs.Sink.

Definition at line 145 of file html.py.

◆ close_output()

def grepros.plugins.auto.html.HtmlSink.close_output (   self)
Closes output file, if any.

Reimplemented from grepros.outputs.RolloverSinkMixin.

Definition at line 154 of file html.py.

◆ emit()

def grepros.plugins.auto.html.HtmlSink.emit (   self,
  topic,
  msg,
  stamp = None,
  match = None,
  index = None 
)
Writes message to output file.

Reimplemented from grepros.outputs.Sink.

Definition at line 113 of file html.py.

◆ flush()

def grepros.plugins.auto.html.HtmlSink.flush (   self)
Writes out any pending data to disk.

Reimplemented from grepros.outputs.Sink.

Definition at line 161 of file html.py.

◆ format_message()

def grepros.plugins.auto.html.HtmlSink.format_message (   self,
  msg,
  highlight = False 
)
Returns message as formatted string, optionally highlighted for matches if configured.

Reimplemented from grepros.outputs.TextSinkMixin.

Definition at line 165 of file html.py.

◆ is_highlighting()

def grepros.plugins.auto.html.HtmlSink.is_highlighting (   self)
Returns True if sink is configured to highlight matched values.

Reimplemented from grepros.outputs.Sink.

Definition at line 172 of file html.py.

◆ validate()

def grepros.plugins.auto.html.HtmlSink.validate (   self)
Returns whether write options are valid and ROS environment is set and file is writable,
emits error if not.

Reimplemented from grepros.outputs.Sink.

Definition at line 125 of file html.py.

Member Data Documentation

◆ _close_printed

grepros.plugins.auto.html.HtmlSink._close_printed
private

Definition at line 99 of file html.py.

◆ _overwrite

grepros.plugins.auto.html.HtmlSink._overwrite
private

Definition at line 97 of file html.py.

◆ _queue

grepros.plugins.auto.html.HtmlSink._queue
private

Definition at line 95 of file html.py.

◆ _tag_repls

grepros.plugins.auto.html.HtmlSink._tag_repls
private

Definition at line 104 of file html.py.

◆ _tag_rgx

grepros.plugins.auto.html.HtmlSink._tag_rgx
private

Definition at line 108 of file html.py.

◆ _template_path

grepros.plugins.auto.html.HtmlSink._template_path
private

Definition at line 98 of file html.py.

◆ _writer

grepros.plugins.auto.html.HtmlSink._writer
private

Definition at line 96 of file html.py.

◆ DEFAULT_ARGS

grepros.plugins.auto.html.HtmlSink.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 grepros.plugins.auto.html.HtmlSink.FILE_EXTENSIONS = (".htm", ".html")
static

Auto-detection file extensions.

Definition at line 34 of file html.py.

◆ filename

grepros.plugins.auto.html.HtmlSink.filename

Definition at line 187 of file html.py.

◆ TEMPLATE_PATH

grepros.plugins.auto.html.HtmlSink.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

grepros.plugins.auto.html.HtmlSink.valid

Definition at line 142 of file html.py.

◆ WRAP_WIDTH

int grepros.plugins.auto.html.HtmlSink.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:


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