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@50: from log_parser import IrssiParser 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@50: terom@50: # timezone to use terom@50: TIMEZONE = pytz.timezone('Europe/Helsinki') terom@50: terom@50: # the parser that we use terom@50: PARSER = IrssiParser(TIMEZONE, "%H:%M:%S") terom@41: terom@41: # the statically defined channel list terom@41: CHANNELS = { terom@41: 'tycoon': LogChannel('tycoon', "OFTC", "#tycoon", terom@50: LogDirectory(relpath('logs/tycoon'), TIMEZONE, PARSER) terom@41: ), terom@42: 'openttd': LogChannel('openttd', "OFTC", "#openttd", terom@50: LogDirectory(relpath('logs/openttd'), TIMEZONE, PARSER) terom@42: ), 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@51: terom@51: def dict (self) : terom@51: """ terom@51: Returns a { name: LogChannel } dict terom@51: """ terom@51: return self.channels 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: