channels.py
author Tero Marttila <terom@fixme.fi>
Mon, 09 Feb 2009 23:49:57 +0200
changeset 73 5a7188bf2894
parent 51 07ca28f3a9f2
permissions -rw-r--r--
split defined configuration constants into config, and implement search result pagination
41
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     1
"""
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     2
    Our list of LogChannels
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     3
"""
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     4
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     5
class ChannelList (object) :
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     6
    """
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     7
        The list of channels, and related methods
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     8
    """
50
f13cf27a360b implement more LogSource features (logs for date, cleanup last_logs), implement irssi parser, formatter, other misc. stuff
Tero Marttila <terom@fixme.fi>
parents: 46
diff changeset
     9
f13cf27a360b implement more LogSource features (logs for date, cleanup last_logs), implement irssi parser, formatter, other misc. stuff
Tero Marttila <terom@fixme.fi>
parents: 46
diff changeset
    10
73
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents: 51
diff changeset
    11
    def __init__ (self, channel_list) :
41
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    12
        """
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    13
            Initialize with the given channel dict
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    14
        """
73
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents: 51
diff changeset
    15
        
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents: 51
diff changeset
    16
        self.channel_list = channel_list
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents: 51
diff changeset
    17
        self.channel_dict = dict((channel.id, channel) for channel in channel_list)
41
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    18
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    19
    def lookup (self, channel_name) :
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    20
        """
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    21
            Looks up the LogChannel for the given name
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    22
        """
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    23
73
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents: 51
diff changeset
    24
        return self.channel_dict[channel_name]
51
07ca28f3a9f2 use improved URLConfig/URLType
Tero Marttila <terom@fixme.fi>
parents: 50
diff changeset
    25
    
07ca28f3a9f2 use improved URLConfig/URLType
Tero Marttila <terom@fixme.fi>
parents: 50
diff changeset
    26
    def dict (self) :
07ca28f3a9f2 use improved URLConfig/URLType
Tero Marttila <terom@fixme.fi>
parents: 50
diff changeset
    27
        """
07ca28f3a9f2 use improved URLConfig/URLType
Tero Marttila <terom@fixme.fi>
parents: 50
diff changeset
    28
            Returns a { name: LogChannel } dict
07ca28f3a9f2 use improved URLConfig/URLType
Tero Marttila <terom@fixme.fi>
parents: 50
diff changeset
    29
        """
73
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents: 51
diff changeset
    30
        return self.channel_dict
41
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    31
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    32
    def __iter__ (self) :
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    33
        """
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    34
            Iterate over our defined LogChannel objects
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    35
        """
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    36
73
5a7188bf2894 split defined configuration constants into config, and implement search result pagination
Tero Marttila <terom@fixme.fi>
parents: 51
diff changeset
    37
        return iter(self.channel_list)
41
9585441a4bfb working basic logs stuff
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    38