sites/irclogs.qmsk.net/channels.py
branchsites
changeset 41 9585441a4bfb
child 42 5a72c00c4ae4
equal deleted inserted replaced
40:71ab68f31a1c 41:9585441a4bfb
       
     1 """
       
     2     Our list of LogChannels
       
     3 """
       
     4 
       
     5 import pytz
       
     6 
       
     7 # for relpath
       
     8 import os.path
       
     9 
       
    10 from log_channel import LogChannel
       
    11 from log_source import LogDirectory
       
    12 
       
    13 relpath = lambda path : os.path.join(os.path.dirname(__file__), path)
       
    14 
       
    15 class ChannelList (object) :
       
    16     """
       
    17         The list of channels, and related methods
       
    18     """
       
    19     
       
    20     # the statically defined channel list
       
    21     CHANNELS = {
       
    22         'tycoon':   LogChannel('tycoon', "OFTC", "#tycoon", 
       
    23             LogDirectory(relpath('logs/tycoon'), pytz.timezone('Europe/Helsinki'))
       
    24         ),
       
    25     }
       
    26 
       
    27     def __init__ (self, channels) :
       
    28         """
       
    29             Initialize with the given channel dict
       
    30         """
       
    31 
       
    32         self.channels = channels
       
    33 
       
    34     def lookup (self, channel_name) :
       
    35         """
       
    36             Looks up the LogChannel for the given name
       
    37         """
       
    38 
       
    39         return self.channels[channel_name]
       
    40 
       
    41     def __iter__ (self) :
       
    42         """
       
    43             Iterate over our defined LogChannel objects
       
    44         """
       
    45 
       
    46         return self.channels.itervalues()
       
    47 
       
    48 # the global singletone ChannelList...
       
    49 channel_list = ChannelList(ChannelList.CHANNELS)
       
    50