changeset 1820:9595d9d5e5ae

logfile: removed some unused code, added some checks
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 25 Feb 2007 18:15:42 +0100
parents 4cf97d47a314
children b88810a5c7b5 e2be013c7204
files MoinMoin/logfile/__init__.py
diffstat 1 files changed, 3 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/logfile/__init__.py	Sun Feb 25 17:18:49 2007 +0100
+++ b/MoinMoin/logfile/__init__.py	Sun Feb 25 18:15:42 2007 +0100
@@ -120,16 +120,7 @@
         """
         generate some attributes when needed
         """
-        if name == "_LogFile__rel_index": # XXX where is this used?
-            # starting iteration from begin
-            self.__buffer1 = LineBuffer(self._input, 0, self.buffer_size)
-            self.__buffer2 = LineBuffer(self._input,
-                                        self.__buffer1.offsets[-1],
-                                        self.buffer_size)
-            self.__buffer = self.__buffer1
-            self.__rel_index = 0
-            return 0
-        elif name == "_input":
+        if name == "_input":
             try:
                 # Open the file (NOT using codecs.open, it breaks our offset calculation. We decode it later.).
                 # Use binary mode in order to retain \r - otherwise the offset calculation would fail.
@@ -296,7 +287,7 @@
 
     def to_begin(self):
         """moves file position to the begin"""
-        if self.__buffer1.offsets[0] != 0:
+        if self.__buffer1 is None or self.__buffer1.offsets[0] != 0:
             self.__buffer1 = LineBuffer(self._input,
                                         0,
                                         self.buffer_size)
@@ -311,7 +302,7 @@
         """moves file position to the end"""
         self._input.seek(0, 2) # to end of file
         size = self._input.tell()
-        if (not self.__buffer2) or (size > self.__buffer2.offsets[-1]):
+        if self.__buffer2 is None or size > self.__buffer2.offsets[-1]:
             self.__buffer2 = LineBuffer(self._input,
                                         size,
                                         self.buffer_size,