equal
deleted
inserted
replaced
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 'openttd': LogChannel('openttd', "OFTC", "#openttd", |
|
26 LogDirectory(relpath('logs/openttd'), pytz.timezone('Europe/Helsinki')) |
|
27 ), |
|
28 } |
|
29 |
|
30 def __init__ (self, channels) : |
|
31 """ |
|
32 Initialize with the given channel dict |
|
33 """ |
|
34 |
|
35 self.channels = channels |
|
36 |
|
37 def lookup (self, channel_name) : |
|
38 """ |
|
39 Looks up the LogChannel for the given name |
|
40 """ |
|
41 |
|
42 return self.channels[channel_name] |
|
43 |
|
44 def __iter__ (self) : |
|
45 """ |
|
46 Iterate over our defined LogChannel objects |
|
47 """ |
|
48 |
|
49 return self.channels.itervalues() |
|
50 |
|
51 # the global singletone ChannelList... |
|
52 channel_list = ChannelList(ChannelList.CHANNELS) |
|
53 |
|