terom@41: """ terom@41: Our list of LogChannels terom@41: """ terom@41: terom@41: import pytz terom@41: terom@41: # for relpath terom@41: import os.path terom@41: terom@41: from log_channel import LogChannel terom@41: from log_source import LogDirectory terom@41: terom@41: relpath = lambda path : os.path.join(os.path.dirname(__file__), path) terom@41: terom@41: class ChannelList (object) : terom@41: """ terom@41: The list of channels, and related methods terom@41: """ terom@41: terom@41: # the statically defined channel list terom@41: CHANNELS = { terom@41: 'tycoon': LogChannel('tycoon', "OFTC", "#tycoon", terom@41: LogDirectory(relpath('logs/tycoon'), pytz.timezone('Europe/Helsinki')) terom@41: ), terom@41: } terom@41: terom@41: def __init__ (self, channels) : terom@41: """ terom@41: Initialize with the given channel dict terom@41: """ terom@41: terom@41: self.channels = channels terom@41: terom@41: def lookup (self, channel_name) : terom@41: """ terom@41: Looks up the LogChannel for the given name terom@41: """ terom@41: terom@41: return self.channels[channel_name] terom@41: terom@41: def __iter__ (self) : terom@41: """ terom@41: Iterate over our defined LogChannel objects terom@41: """ terom@41: terom@41: return self.channels.itervalues() terom@41: terom@41: # the global singletone ChannelList... terom@41: channel_list = ChannelList(ChannelList.CHANNELS) terom@41: