author | Tero Marttila <terom@fixme.fi> |
Sun, 08 Feb 2009 02:29:23 +0200 | |
branch | sites |
changeset 42 | 5a72c00c4ae4 |
parent 41 | 9585441a4bfb |
permissions | -rw-r--r-- |
41 | 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 |
), |
|
42
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
25 |
'openttd': LogChannel('openttd', "OFTC", "#openttd", |
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
26 |
LogDirectory(relpath('logs/openttd'), pytz.timezone('Europe/Helsinki')) |
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
27 |
), |
41 | 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 |