changeset 1000:6f6fcbe200b5

whitespace-only cleanup and minor style changes
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 22 Jul 2006 12:47:55 +0200
parents 97ce857bdebf
children ed7febba892b
files MoinMoin/logfile/__init__.py MoinMoin/logfile/editlog.py MoinMoin/logfile/eventlog.py
diffstat 3 files changed, 44 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/logfile/__init__.py	Sat Jul 22 12:39:18 2006 +0200
+++ b/MoinMoin/logfile/__init__.py	Sat Jul 22 12:47:55 2006 +0200
@@ -67,7 +67,7 @@
         while i < length:
             result = self.offsets[i-1] + tmp
             tmp = self.offsets[i]
-            self.offsets[i] =  result
+            self.offsets[i] = result
             i = i + 1
         self.offsets[0] = offset
 
@@ -79,7 +79,7 @@
     Overwrite .parser() and .add() to customize this class to
     special log files
     """
-    
+
     def __init__(self, filename, buffer_size=65536):
         """
         @param filename: name of the log file
@@ -106,7 +106,7 @@
             except StopIteration:
                 return
             yield result
-            
+
     def sanityCheck(self):
         """ Check for log file write access.
         
@@ -122,7 +122,7 @@
         """
         generate some attributes when needed
         """
-        if name=="_LogFile__rel_index":
+        if name == "_LogFile__rel_index":
             # starting iteration from begin
             self.__buffer1 = LineBuffer(self._input, 0, self.buffer_size)
             self.__buffer2 = LineBuffer(self._input,
@@ -164,7 +164,7 @@
             return os.path.getsize(self.__filename)
         except OSError, err:
             if err.errno == errno.ENOENT:
-                return 0            
+                return 0
             raise
 
     def lines(self):
@@ -194,7 +194,7 @@
     def date(self):
         """ Return timestamp of log file in usecs """
         try:
-            mtime = os.path.getmtime(self.__filename)            
+            mtime = os.path.getmtime(self.__filename)
         except OSError, err:
             if err.errno == errno.ENOENT:
                 # This can happen on fresh wiki when building the index
@@ -237,7 +237,7 @@
                     self.__rel_index = (self.__rel_index +
                                         self.__buffer1.len)
                     self.__buffer = self.__buffer1
-                
+
         while self.__rel_index >= self.__buffer.len:
             if self.__buffer == self.__buffer1:
                 # change to buffer 2
@@ -248,7 +248,7 @@
                 tmpbuff = LineBuffer(self._input,
                                      self.__buffer1.offsets[-1],
                                      self.buffer_size)
-                if tmpbuff.len==0:
+                if tmpbuff.len == 0:
                     # end of file
                     if self.__lineno:
                         self.__lineno = (self.__lineno + lines -
@@ -258,7 +258,7 @@
                     return True
                 # shift buffers
                 self.__buffer1 = self.__buffer2
-                self.__buffer2 = tmpbuff                
+                self.__buffer2 = tmpbuff
                 self.__rel_index = self.__rel_index - self.__buffer1.len
         if self.__lineno: self.__lineno += lines
         return False
@@ -278,15 +278,16 @@
         XXX It does not raise anything!
         """
         result = None
-        while result == None:
-            while result == None:
+        while result is None:
+            while result is None:
                 result = self.__next()
             if self.filter and not self.filter(result):
                 result = None
         return result
-    
+
     def __previous(self):
-        if self.peek(-1): raise StopIteration
+        if self.peek(-1):
+            raise StopIteration
         return self.parser(self.__buffer.lines[self.__rel_index])
 
     def previous(self):
@@ -295,8 +296,8 @@
         raises StopIteration at file begin
         """
         result = None
-        while result == None:
-            while result == None:
+        while result is None:
+            while result is None:
                 result = self.__previous()
             if self.filter and not self.filter(result):
                 result = None
@@ -319,16 +320,16 @@
         """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 (not self.__buffer2) or (size > self.__buffer2.offsets[-1]):
             self.__buffer2 = LineBuffer(self._input,
                                         size,
                                         self.buffer_size,
-                                        forward = False)
-            
+                                        forward=False)
+
             self.__buffer1 = LineBuffer(self._input,
                                         self.__buffer2.offsets[0],
                                         self.buffer_size,
-                                        forward = False)
+                                        forward=False)
         self.__buffer = self.__buffer2
         self.__rel_index = self.__buffer2.len
         self.__lineno = None
@@ -341,7 +342,7 @@
         For this plain file implementation position is an Integer.
         """
         return self.__buffer.offsets[self.__rel_index]
-        
+
     def seek(self, position, line_no=None):
         """ moves file position to an value formerly gotten from .position().
         To enable line counting line_no must be provided.
@@ -362,7 +363,7 @@
             self.__buffer1 = LineBuffer(self._input,
                                         position,
                                         self.buffer_size,
-                                        forward = False)
+                                        forward=False)
             self.__buffer2 = LineBuffer(self._input,
                                         position,
                                         self.buffer_size)
@@ -374,7 +375,7 @@
     def line_no(self):
         """@return: the current line number or None if line number is unknown"""
         return self.__lineno
-    
+
     def calculate_line_no(self):
         """ Calculate the current line number from buffer offsets
         
@@ -404,14 +405,14 @@
         """
         line = "\t".join(data)
         self._add(line)
-        
+
     def _add(self, line):
         """
         @param line: flat line
         @type line: String
         write on entry in the log file
         """
-        if line != None:
+        if line is not None:
             if line[-1] != '\n':
                 line += '\n'
             self._output.write(line)
--- a/MoinMoin/logfile/editlog.py	Sat Jul 22 12:39:18 2006 +0200
+++ b/MoinMoin/logfile/editlog.py	Sat Jul 22 12:47:55 2006 +0200
@@ -34,8 +34,9 @@
 
     def is_from_current_user(self, request):
         user = request.user
-        if user.id: return user.id==self.userid
-        return request.remote_addr==self.addr        
+        if user.id:
+            return user.id == self.userid
+        return request.remote_addr == self.addr
 
     def getEditorData(self, request):
         """ Return a tuple of type id and string or Page object
@@ -112,7 +113,7 @@
                     request.formatter.url(0))
         elif kind == 'ip':
             idx = info.find('.')
-            if idx==-1:
+            if idx == -1:
                 idx = len(info)
             title = wikiutil.escape('???' + title)
             text = wikiutil.escape(info[:idx])
@@ -124,7 +125,7 @@
 class EditLog(LogFile):
 
     def __init__(self, request, filename=None, buffer_size=65536, **kw):
-        if filename == None:
+        if filename is None:
             rootpagename = kw.get('rootpagename', None)
             if rootpagename:
                 filename = Page(request, rootpagename).getPagePath('edit-log', isfile=1)
@@ -133,7 +134,7 @@
         LogFile.__init__(self, filename, buffer_size)
         self._NUM_FIELDS = 9
         self._usercache = {}
-        
+
         # Used by antispam in order to show an internal name instead
         # of a confusing userid
         self.uid_override = kw.get('uid_override', None)
@@ -155,16 +156,16 @@
                     hostname = host
             else:
                 hostname = host
-            
-            remap_chars = {u'\t': u' ', u'\r': u' ', u'\n': u' ',}
+
+            remap_chars = {u'\t': u' ', u'\r': u' ', u'\n': u' ', }
             comment = comment.translate(remap_chars)
             user_id = request.user.valid and request.user.id or ''
 
-            if self.uid_override != None:
+            if self.uid_override is not None:
                 user_id = ''
                 hostname = self.uid_override
                 host = ''
-            
+
             line = u"\t".join((str(long(mtime)), # has to be long for py 2.2.x
                                "%08d" % rev,
                                action,
@@ -193,16 +194,16 @@
         result.pagename = wikiutil.unquoteWikiname(result.pagename.encode('ascii'))
         result.ed_time_usecs = long(result.ed_time_usecs or '0') # has to be long for py 2.2.x
         return result
-    
+
     def set_filter(self, **kw):
         expr = "1"
         for field in ['pagename', 'addr', 'hostname', 'userid']:
             if kw.has_key(field):
                 expr = "%s and x.%s == %s" % (expr, field, `kw[field]`)
-                
+
         if kw.has_key('ed_time_usecs'):
             expr = "%s and long(x.ed_time_usecs) == %s" % (expr, long(kw['ed_time_usecs'])) # must be long for py 2.2.x
 
         self.filter = eval("lambda x: " + expr)
-    
 
+
--- a/MoinMoin/logfile/eventlog.py	Sat Jul 22 12:39:18 2006 +0200
+++ b/MoinMoin/logfile/eventlog.py	Sat Jul 22 12:47:55 2006 +0200
@@ -10,9 +10,9 @@
 from MoinMoin.util import web
 
 class EventLog(LogFile):
-    
+
     def __init__(self, request, filename=None, buffer_size=65536, **kw):
-        if filename == None:
+        if filename is None:
             rootpagename = kw.get('rootpagename', None)
             if rootpagename:
                 from MoinMoin.Page import Page
@@ -28,7 +28,7 @@
         """
         if request.isSpiderAgent:
             return
-        
+
         if mtime_usecs is None:
             mtime_usecs = wikiutil.timestamp2version(time.time())
 
@@ -52,9 +52,9 @@
             # badly formatted line in file, skip it
             return None
         return long(time_usecs), eventtype, wikiutil.parseQueryString(kvpairs)
-                                                                        
-    def set_filter(self, event_types = None):
-        if event_types == None:
+
+    def set_filter(self, event_types=None):
+        if event_types is None:
             self.filter = None
         else:
             self.filter = lambda line: (line[1] in event_types)