Intended for overwriting in subclasses.
- This function is called from __iter__ for each new data that becomes
+ This function is called from `__iter__` for each new data that becomes
available. It has to provide results which are forwarded to caller.
This base implementation just yields its input, so new data is yielded
:py:data:`self.descriptions`
:param str data: Text data read from source
:param idx: Index of data source
- :returns: nothing but yields [(description, data, idx], same as input
+ :returns: nothing but yields [(description, data, idx)], same as input
"""
yield description, data, idx
If line is not complete, then buffer it.
Args: see super class method :py:meth:`IterativeReader.prepare_result`
+
:returns: list of 3-tuples `(description, line, idx)` where
`description` and `idx` are same as args, and `line` is
without trailing newline characters
Iteration returns :py:class:`re.match` result or -- if matching failed --
None. The latest unparsed line is available as `self.last_unparsed_line`.
- Usage recommendation:
+ Usage recommendation::
with open(log_file_name, 'rt') as file_handle:
parser = log_read.LogParser(file_handle, pattern=my_pattern):
Try parsing lines.
Args: see super class method :py:meth:`IterativeReader.prepare_result`
+
:returns: 3-tuples `(description, line, idx)` where `description` and
`idx` are same as input args and `line` is either a
:py:class:`re.Match` if line matched :py:data:`self.pattern`
"""
Open single file, yield LogParser. Ensures file is closed afterwards.
- This allows opening file and creation LogParser for it to one line:
+ This allows opening file and creation LogParser for it to one line::
with LogParser.create_for('/var/log/messages', SYS_LOG_PATTERN) as parser:
for _, matches, _ in parser: