Add example about os.path.walk , which may used to implete --recursive option
[xmailer.git] / test / configfile.py
bloba4a97d2f7a5bacb63fdde024525268d8299357f0
1 import ConfigParser
3 def ReadConfig(filename):
4 """ read param from config file: filename """
5 rc=ConfigParser.ConfigParser()
6 rc.read(filename)
7 maxlen=rc.getint('global','maillen')
8 smtpcount=rc.getint('global','smtp')
9 defaultsmtp=rc.get('global','default')
10 param=[]
11 param.append([maxlen,smtpcount])
12 smpts={}
13 for i in xrange(1,smtpcount+1):
14 sname='smtp'+'%d'%i
15 key=rc.get(sname,'name')
16 addr=rc.get(sname,'addr')
17 port=rc.getint(sname,'port')
18 ssl=rc.getint(sname,'ssl')
19 username=rc.get(sname,'user')
20 password=rc.get(sname,'pass')
21 smpts[key]=[addr,port,ssl,username,password]
22 param.append(smpts)
24 return param
27 cf=ConfigParser.ConfigParser()
28 cf.read('/home/rui/.xmailrc')
29 cf.get("global","maillen")
30 cf.getint('smtp1','ssl')
31 cf.getboolean('smtp1','ssl')
32 cf.getfloat('global','maillen')
33 print cf.getint('global','smtp')
35 print ReadConfig('/home/rui/.xmailrc')