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

Public Member Functions

def __init__ (self, args=None, **kwargs)
 
def close (self)
 
def emit (self, topic, msg, stamp=None, match=None, index=None)
 
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 flush (self)
 
def is_highlighting (self)
 
def thread_excepthook (self, text, exc)
 

Public Attributes

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

Static Public Attributes

 DEFAULT_ARGS = dict(EMIT_FIELD=(), META=False, NOEMIT_FIELD=(), WRITE_OPTIONS={}, VERBOSE=False)
 Constructor argument defaults. More...
 
tuple FILE_EXTENSIONS = (".csv", )
 Auto-detection file extensions. 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...
 

Private Member Functions

def _iter_fields (self, msg, top=())
 
def _make_writer (self, topic, msg)
 

Private Attributes

 _close_printed
 
 _filebase
 
 _files
 
 _lasttopickey
 
 _overwrite
 
 _patterns
 
 _writers
 

Detailed Description

Writes messages to CSV files, each topic to a separate file.

Definition at line 29 of file csv.py.

Constructor & Destructor Documentation

◆ __init__()

def grepros.plugins.auto.csv.CsvSink.__init__ (   self,
  args = None,
**  kwargs 
)
@param   args                 arguments as namespace or dictionary, case-insensitive;
                      or a single path as the base name of CSV files to write
@param   args.emit_field      message fields to emit in output if not all
@param   args.noemit_field    message fields to skip in output
@param   args.write           base name of CSV files to write,
                      will add topic name like "name.__my__topic.csv" for "/my/topic",
                      will add counter like "name.__my__topic.2.csv" if exists
@param   args.write_options   {"overwrite": whether to overwrite existing files
                                    (default false)}
@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 38 of file csv.py.

Member Function Documentation

◆ _iter_fields()

def grepros.plugins.auto.csv.CsvSink._iter_fields (   self,
  msg,
  top = () 
)
private
Yields ((nested, path), scalar value) from ROS message.

Lists are returned as ((nested, path, index), value), e.g. (("data", 0), 666).

Definition at line 152 of file csv.py.

◆ _make_writer()

def grepros.plugins.auto.csv.CsvSink._make_writer (   self,
  topic,
  msg 
)
private
Returns a csv.writer for writing topic data.

File is populated with header if not created during this session.

Definition at line 118 of file csv.py.

◆ close()

def grepros.plugins.auto.csv.CsvSink.close (   self)
Closes output file(s), if any.

Reimplemented from grepros.outputs.Sink.

Definition at line 92 of file csv.py.

◆ emit()

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

Reimplemented from grepros.outputs.Sink.

Definition at line 68 of file csv.py.

◆ validate()

def grepros.plugins.auto.csv.CsvSink.validate (   self)
Returns whether overwrite option is valid and file base is writable.

Reimplemented from grepros.outputs.Sink.

Definition at line 78 of file csv.py.

Member Data Documentation

◆ _close_printed

grepros.plugins.auto.csv.CsvSink._close_printed
private

Definition at line 62 of file csv.py.

◆ _filebase

grepros.plugins.auto.csv.CsvSink._filebase
private

Definition at line 56 of file csv.py.

◆ _files

grepros.plugins.auto.csv.CsvSink._files
private

Definition at line 57 of file csv.py.

◆ _lasttopickey

grepros.plugins.auto.csv.CsvSink._lasttopickey
private

Definition at line 60 of file csv.py.

◆ _overwrite

grepros.plugins.auto.csv.CsvSink._overwrite
private

Definition at line 61 of file csv.py.

◆ _patterns

grepros.plugins.auto.csv.CsvSink._patterns
private

Definition at line 59 of file csv.py.

◆ _writers

grepros.plugins.auto.csv.CsvSink._writers
private

Definition at line 58 of file csv.py.

◆ DEFAULT_ARGS

grepros.plugins.auto.csv.CsvSink.DEFAULT_ARGS = dict(EMIT_FIELD=(), META=False, NOEMIT_FIELD=(), WRITE_OPTIONS={}, VERBOSE=False)
static

Constructor argument defaults.

Definition at line 36 of file csv.py.

◆ FILE_EXTENSIONS

tuple grepros.plugins.auto.csv.CsvSink.FILE_EXTENSIONS = (".csv", )
static

Auto-detection file extensions.

Definition at line 33 of file csv.py.

◆ valid

grepros.plugins.auto.csv.CsvSink.valid

Definition at line 89 of file csv.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