From: Christian Herdtweck Date: Tue, 12 Jan 2016 11:17:18 +0000 (+0100) Subject: cleaned up CircularBuffer X-Git-Tag: v1.2~86 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=e1ebb38e2c53b6d547bf546b636cad72b7952e06;p=pyi2ncommon cleaned up CircularBuffer --- diff --git a/buffers.py b/buffers.py index ed45b61..96e065d 100644 --- a/buffers.py +++ b/buffers.py @@ -1,5 +1,3 @@ -#!/usr/bin/env python - # The software in this package is distributed under the GNU General # Public License version 2 (with a special exception described below). # @@ -19,12 +17,18 @@ # on this file might be covered by the GNU General Public License. """ -OutputBuffer: classes to buffer line-based output +buffers.py: buffers of various shapes, sizes and functionalities + +Featuring:: + +* CircularBuffer +* LogBuffer (saves one of the 2 last items, one of the 4 last items, .. + of the 8 last, 16 last, ... .. codeauthor:: Christian Herdtweck, christian.herdtweck@intra2net.com """ -class OutputLineBuffer: +class CircularBuffer: """ circular buffer for text lines; saves last N lines can output them afterwards in correct order @@ -58,32 +62,3 @@ class OutputLineBuffer: for idx in range(0, self._buff_idx): output_func(self._buffer[idx]) - - -def main(): - """ Main function, called when running file as script - - currently raises a NotImplementedError - """ - raise NotImplementedError - - line_buffer = OutputLineBuffer(3) - for output_line in proc.stdout: - progress_reporter.inc_current_points() - line_buffer.add(output_line) - - proc.stdout.close() - return_code = proc.wait() - - if return_code != 0: - self.logger.warning('extraction returned {0}!'.format(return_code)) - self.logger.warning('command was: {0}'.format(' '.join(cpio))) - self.logger.warning('last {0} output lines:'.format( - min(line_buffer.buffer_size, line_buffer.n_lines))) - line_buffer.output(self.logger.warning) - -# end: function main - - -if __name__ == '__main__': - main()