channels.py
changeset 73 5a7188bf2894
parent 51 07ca28f3a9f2
--- a/channels.py	Mon Feb 09 22:17:10 2009 +0200
+++ b/channels.py	Mon Feb 09 23:49:57 2009 +0200
@@ -2,65 +2,37 @@
     Our list of LogChannels
 """
 
-import pytz
-
-# for relpath
-import os.path
-
-from log_channel import LogChannel
-from log_source import LogDirectory
-from log_parser import IrssiParser
-
-relpath = lambda path : os.path.join(os.path.dirname(__file__), path)
-
 class ChannelList (object) :
     """
         The list of channels, and related methods
     """
 
-    # timezone to use
-    TIMEZONE = pytz.timezone('Europe/Helsinki')
 
-    # the parser that we use
-    PARSER = IrssiParser(TIMEZONE, "%H:%M:%S")
-    
-    # the statically defined channel list
-    CHANNELS = {
-        'tycoon':   LogChannel('tycoon', "OFTC", "#tycoon", 
-            LogDirectory(relpath('logs/tycoon'), TIMEZONE, PARSER)
-        ),
-        'openttd':   LogChannel('openttd', "OFTC", "#openttd", 
-            LogDirectory(relpath('logs/openttd'), TIMEZONE, PARSER)
-        ),
-    }
-
-    def __init__ (self, channels) :
+    def __init__ (self, channel_list) :
         """
             Initialize with the given channel dict
         """
-
-        self.channels = channels
+        
+        self.channel_list = channel_list
+        self.channel_dict = dict((channel.id, channel) for channel in channel_list)
 
     def lookup (self, channel_name) :
         """
             Looks up the LogChannel for the given name
         """
 
-        return self.channels[channel_name]
+        return self.channel_dict[channel_name]
     
     def dict (self) :
         """
             Returns a { name: LogChannel } dict
         """
-        return self.channels
+        return self.channel_dict
 
     def __iter__ (self) :
         """
             Iterate over our defined LogChannel objects
         """
 
-        return self.channels.itervalues()
+        return iter(self.channel_list)
 
-# the global singletone ChannelList...
-channel_list = ChannelList(ChannelList.CHANNELS)
-