channels.py
author Tero Marttila <terom@fixme.fi>
Sun, 08 Feb 2009 03:23:25 +0200
changeset 46 185504387370
parent 42 sites/irclogs.qmsk.net/channels.py@5a72c00c4ae4
child 50 f13cf27a360b
permissions -rw-r--r--
reduce to irclogs.qmsk.net site
"""
    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'))
        ),
        'openttd':   LogChannel('openttd', "OFTC", "#openttd", 
            LogDirectory(relpath('logs/openttd'), 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)