sites/irclogs.qmsk.net/channels.py
branchsites
changeset 41 9585441a4bfb
child 42 5a72c00c4ae4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sites/irclogs.qmsk.net/channels.py	Sun Feb 08 00:29:36 2009 +0200
@@ -0,0 +1,50 @@
+"""
+    Our list of LogChannels
+"""
+
+import pytz
+
+# for relpath
+import os.path
+
+from log_channel import LogChannel
+from log_source import LogDirectory
+
+relpath = lambda path : os.path.join(os.path.dirname(__file__), path)
+
+class ChannelList (object) :
+    """
+        The list of channels, and related methods
+    """
+    
+    # the statically defined channel list
+    CHANNELS = {
+        'tycoon':   LogChannel('tycoon', "OFTC", "#tycoon", 
+            LogDirectory(relpath('logs/tycoon'), pytz.timezone('Europe/Helsinki'))
+        ),
+    }
+
+    def __init__ (self, channels) :
+        """
+            Initialize with the given channel dict
+        """
+
+        self.channels = channels
+
+    def lookup (self, channel_name) :
+        """
+            Looks up the LogChannel for the given name
+        """
+
+        return self.channels[channel_name]
+
+    def __iter__ (self) :
+        """
+            Iterate over our defined LogChannel objects
+        """
+
+        return self.channels.itervalues()
+
+# the global singletone ChannelList...
+channel_list = ChannelList(ChannelList.CHANNELS)
+