log_line.py
changeset 92 74f6a0b01ddf
parent 91 df2a6780cdf9
child 97 6165f1ba458d
--- a/log_line.py	Wed Feb 11 01:00:18 2009 +0200
+++ b/log_line.py	Wed Feb 11 01:21:22 2009 +0200
@@ -41,41 +41,45 @@
         ('LOG_CLOSE',   0x03),
 
         ## messages
-        # normal message
+        # <source> sent message <data> to <channel>
         ('MSG',         0x10),
         
-        # notice
+        # <source> sent notice with message <data> to <channel>
         ('NOTICE',      0x11),
 
-        # CTCP action
+        # <source> sent CTCP action with message <data> to <channel>
         ('ACTION',      0x12),
         
         ## user-channel stats
-        # join
+        # <source> joined <channel>
         ('JOIN',        0x21),
 
-        # part
+        # <source> left <channel> with message <data>
         ('PART',        0x22),
 
-        # kick
+        # <source> kicked <target> from <channel> with message <data>
         ('KICK',        0x25),
      
-        # channel modes
+        # <source> changed modes on <channel> with modestring <data>
         ('MODE',        0x26),
         
         ## user status
-        # nick-change
+        # <source> changed nickname to <target>
         ('NICK',        0x31),
 
-        # quit
+        # <source> quit the network with quit-message <data>
         ('QUIT',        0x32),
 
         ## general channel status
-        # topic changed
+        # <source> changed the topic of <channel> to <data>
+        # data may be None if the topic was unset
         ('TOPIC',       0x41),
 
         ## our own actions
+        # we (<source>) sent a notice with message <data> to <channel>
         ('SELF_NOTICE', 0x51),
+
+        # we (<source>) changed nickname to <target>
         ('SELF_NICK',   0x52),
     ]
     
@@ -108,10 +112,10 @@
     # the UTC timestamp of the event
     timestamp = None
 
-    # the event source, this should be a 
+    # the source, this should be a (nickname, username, hostname, chanflags) tuple
     source = None
 
-    # possible event target, for certain types (kick, nick)
+    # possible target nickname for certain types (kick, nick)
     target = None
 
     # associated data (message, etc)
@@ -139,7 +143,9 @@
 
     def format_source (self) :
         """
-            Formats source as [<chanflags>][<nickname>][!<username>][@<hostname>], omitting those parts that are missing
+            Formats source as [<chanflags>][<nickname>][!<username>][@<hostname>], omitting those parts that are missing.
+
+            If all parts are None, this returns the empty string
         """
 
         nick, user, host, flags = self.source
@@ -150,6 +156,17 @@
             '!' + user if user else '',
             '@' + host if host else ''
         )
+   
+    def __str__ (self) :
+        return '\t'.join((
+            self.channel.name,
+            str(self.offset),
+            self.format_type(),
+            str(self.timestamp),
+            self.format_source(),
+            str(self.target),
+            str(self.data)
+        ))
 
     def __repr__ (self) :
         return "LogLine(%r, %s, %-12s, %s, %-35s, %-10s, %r)" % (