-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
50 lines (44 loc) · 1.29 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import ConfigParser
def reader( filenames, defaults ):
p = ConfigParser.SafeConfigParser( defaults )
p.read( filenames )
data = {}
for section in p.sections():
data[ section ] = dict( p.items( section ) )
return data
def servers( filenames=['servers.conf'] ):
defaults = {
'server' : '',
'port' : '6667',
'nickname' : 'Jimino',
'username' : '%(nickname)s',
'realname' : '%(nickname)s',
'password' : '',
'ipv6' : '0',
'use_ssl' : '0',
'localaddress' : '',
'localport' : '0'
}
return reader( filenames, defaults )
def channels( filenames=['channels.conf'] ):
defaults = {
'autojoin' : '0',
'password' : '',
}
data = reader( filenames, defaults )
networks = {}
for section in data:
network, channel = section.split(':', 1)
if not network in networks:
networks[ network ] = {}
networks[ channel ] = data[section]
return networks
def settings( filenames=['irc.conf'] ):
defaults = {
'debug' : '0',
'timeout' : '0',
}
data = reader( filenames, defaults )
if 'irc' in data:
return data['irc']
return defaults