sites/irclogs.qmsk.net/channels.py
author Tero Marttila <terom@fixme.fi>
Sun, 08 Feb 2009 02:55:53 +0200
branchsites
changeset 43 fc11c4e86a82
parent 42 5a72c00c4ae4
permissions -rw-r--r--
implement channel_view count, the query stuff, css, layout all need some cleanup :(
"""
    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)