author | Tero Marttila <terom@fixme.fi> |
Mon, 09 Feb 2009 01:11:05 +0200 | |
changeset 51 | 07ca28f3a9f2 |
parent 50 | f13cf27a360b |
child 73 | 5a7188bf2894 |
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 |
|
50
f13cf27a360b
implement more LogSource features (logs for date, cleanup last_logs), implement irssi parser, formatter, other misc. stuff
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
12 |
from log_parser import IrssiParser |
41 | 13 |
|
14 |
relpath = lambda path : os.path.join(os.path.dirname(__file__), path) |
|
15 |
||
16 |
class ChannelList (object) : |
|
17 |
""" |
|
18 |
The list of channels, and related methods |
|
19 |
""" |
|
50
f13cf27a360b
implement more LogSource features (logs for date, cleanup last_logs), implement irssi parser, formatter, other misc. stuff
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
20 |
|
f13cf27a360b
implement more LogSource features (logs for date, cleanup last_logs), implement irssi parser, formatter, other misc. stuff
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
21 |
# timezone to use |
f13cf27a360b
implement more LogSource features (logs for date, cleanup last_logs), implement irssi parser, formatter, other misc. stuff
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
22 |
TIMEZONE = pytz.timezone('Europe/Helsinki') |
f13cf27a360b
implement more LogSource features (logs for date, cleanup last_logs), implement irssi parser, formatter, other misc. stuff
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
23 |
|
f13cf27a360b
implement more LogSource features (logs for date, cleanup last_logs), implement irssi parser, formatter, other misc. stuff
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
24 |
# the parser that we use |
f13cf27a360b
implement more LogSource features (logs for date, cleanup last_logs), implement irssi parser, formatter, other misc. stuff
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
25 |
PARSER = IrssiParser(TIMEZONE, "%H:%M:%S") |
41 | 26 |
|
27 |
# the statically defined channel list |
|
28 |
CHANNELS = { |
|
29 |
'tycoon': LogChannel('tycoon', "OFTC", "#tycoon", |
|
50
f13cf27a360b
implement more LogSource features (logs for date, cleanup last_logs), implement irssi parser, formatter, other misc. stuff
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
30 |
LogDirectory(relpath('logs/tycoon'), TIMEZONE, PARSER) |
41 | 31 |
), |
42
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
32 |
'openttd': LogChannel('openttd', "OFTC", "#openttd", |
50
f13cf27a360b
implement more LogSource features (logs for date, cleanup last_logs), implement irssi parser, formatter, other misc. stuff
Tero Marttila <terom@fixme.fi>
parents:
46
diff
changeset
|
33 |
LogDirectory(relpath('logs/openttd'), TIMEZONE, PARSER) |
42
5a72c00c4ae4
more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents:
41
diff
changeset
|
34 |
), |
41 | 35 |
} |
36 |
||
37 |
def __init__ (self, channels) : |
|
38 |
""" |
|
39 |
Initialize with the given channel dict |
|
40 |
""" |
|
41 |
||
42 |
self.channels = channels |
|
43 |
||
44 |
def lookup (self, channel_name) : |
|
45 |
""" |
|
46 |
Looks up the LogChannel for the given name |
|
47 |
""" |
|
48 |
||
49 |
return self.channels[channel_name] |
|
51
07ca28f3a9f2
use improved URLConfig/URLType
Tero Marttila <terom@fixme.fi>
parents:
50
diff
changeset
|
50 |
|
07ca28f3a9f2
use improved URLConfig/URLType
Tero Marttila <terom@fixme.fi>
parents:
50
diff
changeset
|
51 |
def dict (self) : |
07ca28f3a9f2
use improved URLConfig/URLType
Tero Marttila <terom@fixme.fi>
parents:
50
diff
changeset
|
52 |
""" |
07ca28f3a9f2
use improved URLConfig/URLType
Tero Marttila <terom@fixme.fi>
parents:
50
diff
changeset
|
53 |
Returns a { name: LogChannel } dict |
07ca28f3a9f2
use improved URLConfig/URLType
Tero Marttila <terom@fixme.fi>
parents:
50
diff
changeset
|
54 |
""" |
07ca28f3a9f2
use improved URLConfig/URLType
Tero Marttila <terom@fixme.fi>
parents:
50
diff
changeset
|
55 |
return self.channels |
41 | 56 |
|
57 |
def __iter__ (self) : |
|
58 |
""" |
|
59 |
Iterate over our defined LogChannel objects |
|
60 |
""" |
|
61 |
||
62 |
return self.channels.itervalues() |
|
63 |
||
64 |
# the global singletone ChannelList... |
|
65 |
channel_list = ChannelList(ChannelList.CHANNELS) |
|
66 |