ppf/new: Fixes to LogParser classes.
authorRazvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Sat, 27 Aug 2011 06:40:53 +0000 (09:40 +0300)
committerRazvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Sat, 27 Aug 2011 06:40:55 +0000 (09:40 +0300)
Use self.method_name() to call local class methods.
LibtorrentLogParser and TriblerLogParser inherit SessionLogParser.

ppf/new/parsing.py

index 55220f4..3177b5c 100644 (file)
@@ -60,7 +60,7 @@ class SessionLogParser(object):
         return self.parsing
 
 
-class LibtorrentLogParser(object):
+class LibtorrentLogParser(SessionLogParser):
     """
     libtorrent-rasterbar log folder parser.
     """
@@ -70,7 +70,7 @@ class LibtorrentLogParser(object):
         If priority == "verbose" parse verbose log files first. Else, parse
         status file first."
         """
-        super(LibtorrrentLogParser, self).__init__(path)
+        super(LibtorrentLogParser, self).__init__(path)
 
         # to_parse: list of files to be parsed
         # have_parsed: list of files that have been parsed
@@ -95,7 +95,7 @@ class LibtorrentLogParser(object):
         else:
             self.to_parse.append(status_file_path)
 
-        open_next_file()
+        self.open_next_file()
 
     def open_next_file(self):
         """
@@ -140,12 +140,12 @@ class LibtorrentLogParser(object):
         of no message line."""
 
         # Check log line type and call appropriate method.
-        if is_status_log_line(line):
-            return parse_status_log_line(line)
-        elif is_peer_status_log_line(line):
-            return parse_peer_status_log_line(line)
-        elif is_verbose_log_line(line):
-            return parse_verbose_log_line(line)
+        if self.is_status_log_line(line):
+            return self.parse_status_log_line(line)
+        elif self.is_peer_status_log_line(line):
+            return self.parse_peer_status_log_line(line)
+        elif self.is_verbose_log_line(line):
+            return self.parse_verbose_log_line(line)
 
         # Return None in case of unknown/non-existent message type line.
         return None
@@ -165,14 +165,14 @@ class LibtorrentLogParser(object):
 
                 # end of file reached
                 try:
-                    open_next_file()
+                    self.open_next_file()
                 except IndexError, e:
                     # In case of no more files, return None.
                     return None
                 else:
                     continue
 
-            msg = parse_log_line(line)
+            msg = self.parse_log_line(line)
 
             # Go around in case line is bogus (msg is None).
             if msg is not None:
@@ -182,7 +182,7 @@ class LibtorrentLogParser(object):
         return msg
 
 
-class TriblerLogParser(object):
+class TriblerLogParser(SessionLogParser):
     """
     Tribler log file parser.
     """