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

Provides output file rollover by size, duration, or message count. More...

Inheritance diagram for RolloverSinkMixin:
Inheritance graph

Public Member Functions

 __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 Attributes

 filename
 Current output file path.
 

Static Public Attributes

 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 "
 

Properties

 size = property
 Returns current file size in bytes, or None if size lookup failed.
 

Detailed Description

Provides output file rollover by size, duration, or message count.

Definition at line 353 of file outputs.py.

Constructor & Destructor Documentation

◆ __init__()

__init__ (   self,
  args = None,
**  kwargs 
)
Parameters
argsarguments as namespace or dictionary, case-insensitive
args.writebase name of output file to write if not using rollover-template
args.write_options{"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, "overwrite": whether to overwrite existing file (default false)}
args.verbosewhether to emit debug information
kwargsany and all arguments as keyword overrides, case-insensitive

Reimplemented in BagSink, HtmlSink, SqliteSink, and McapSink.

Definition at line 397 of file outputs.py.

Member Function Documentation

◆ close_output()

close_output (   self)

Closes output file, if any.

Reimplemented in BagSink, HtmlSink, and McapSink.

Definition at line 476 of file outputs.py.

◆ ensure_rollover()

ensure_rollover (   self,
  topic,
  msg,
  stamp 
)

Closes current output file and prepares new filename if rollover limit reached.

Definition at line 449 of file outputs.py.

◆ format_output_meta()

format_output_meta (   self)

Returns output file metainfo string, with names and sizes and message/topic counts.

Definition at line 493 of file outputs.py.

◆ get_write_options()

get_write_options (   cls,
  label 
)

Returns command-line help texts for rollover options, as [(name, help)].

Definition at line 537 of file outputs.py.

◆ make_filename()

make_filename (   self)

Returns new filename for output, accounting for rollover template and overwrite.

Definition at line 481 of file outputs.py.

◆ validate()

validate (   self)

Returns whether write options are valid, emits error if not, else populates options.

Reimplemented in BagSink, HtmlSink, SqliteSink, and McapSink.

Definition at line 406 of file outputs.py.

Member Data Documentation

◆ DEFAULT_ARGS

DEFAULT_ARGS = dict(WRITE=None, WRITE_OPTIONS={}, VERBOSE=False)
static

Constructor argument defaults.

Definition at line 357 of file outputs.py.

◆ FILE_META_TEMPLATE

str FILE_META_TEMPLATE = "{name} ({size})"
static

Definition at line 376 of file outputs.py.

◆ filename

filename

Current output file path.

Definition at line 403 of file outputs.py.

◆ MULTI_META_TEMPLATE

str MULTI_META_TEMPLATE = "\n- {name} ({size}, {mcount}, {tcount})"
static

Definition at line 378 of file outputs.py.

◆ OPTIONS_TEMPLATES

list OPTIONS_TEMPLATES
static
Initial value:
= [
("rollover-size=NUM", "size limit for individual files\nin {label} output\n"
"as bytes (supports abbreviations like 1K or 2M or 3G)"),
("rollover-count=NUM", "message limit for individual files\nin {label} output\n"
"(supports abbreviations like 1K or 2M or 3G)"),
("rollover-duration=INTERVAL", "message time span limit for individual files\n"
"in {label} output\n"
"as seconds (supports abbreviations like 60m or 2h or 1d)"),
("rollover-template=STR", "output filename template for individual files\n"
"in {label} output,\n"
'supporting strftime format codes like "%%H-%%M-%%S"\n'
'and "%%(index)s" as output file index'),
]

Command-line help templates for rollover options, as [(name, text with s label placeholder)].

Definition at line 360 of file outputs.py.

◆ START_META_TEMPLATE

str START_META_TEMPLATE = "{mcount} in {tcount} to "
static

Definition at line 374 of file outputs.py.

Property Documentation

◆ size

size = property
static

Returns current file size in bytes, or None if size lookup failed.

Definition at line 527 of file outputs.py.


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