channels.py
author Tero Marttila <terom@fixme.fi>
Sun, 15 Feb 2009 23:50:24 +0200
changeset 129 67a30d680f60
parent 73 5a7188bf2894
permissions -rw-r--r--
Autodetect user timezone using Javascript, this makes the Preferences code a bit more complicated in terms of interaction between default/parse/is_default/build/process/etc, but it should work as intended now
"""
    Our list of LogChannels
"""

class ChannelList (object) :
    """
        The list of channels, and related methods
    """


    def __init__ (self, channel_list) :
        """
            Initialize with the given channel dict
        """
        
        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.channel_dict[channel_name]
    
    def dict (self) :
        """
            Returns a { name: LogChannel } dict
        """
        return self.channel_dict

    def __iter__ (self) :
        """
            Iterate over our defined LogChannel objects
        """

        return iter(self.channel_list)