add some user-preferences support (e.g. timezone, time formats)
"""
Our list of LogChannels
"""
import pytz
# for relpath
import os.path
from log_channel import LogChannel
from log_source import LogDirectory
from log_parser import IrssiParser
relpath = lambda path : os.path.join(os.path.dirname(__file__), path)
class ChannelList (object) :
"""
The list of channels, and related methods
"""
# timezone to use
TIMEZONE = pytz.timezone('Europe/Helsinki')
# the parser that we use
PARSER = IrssiParser(TIMEZONE, "%H:%M:%S")
# the statically defined channel list
CHANNELS = {
'tycoon': LogChannel('tycoon', "OFTC", "#tycoon",
LogDirectory(relpath('logs/tycoon'), TIMEZONE, PARSER)
),
'openttd': LogChannel('openttd', "OFTC", "#openttd",
LogDirectory(relpath('logs/openttd'), TIMEZONE, PARSER)
),
}
def __init__ (self, channels) :
"""
Initialize with the given channel dict
"""
self.channels = channels
def lookup (self, channel_name) :
"""
Looks up the LogChannel for the given name
"""
return self.channels[channel_name]
def dict (self) :
"""
Returns a { name: LogChannel } dict
"""
return self.channels
def __iter__ (self) :
"""
Iterate over our defined LogChannel objects
"""
return self.channels.itervalues()
# the global singletone ChannelList...
channel_list = ChannelList(ChannelList.CHANNELS)