1 class SimpleConfig:
2 def __init__(self):
3 self.confile =''
4 self.props={}
5
6 def load(self,file):
7 try:
8 f = open(file,'r')
9 lines = f.readlines()
10 f.close()
11 self.props={}
12 for line in lines:
13 line = line.strip()
14 if not line or line[0]=='#':
15 continue
16 line = line.split('#')[0]
17 pp = line.split('=')
18 if len(pp)!=2:
19 continue
20 k,v = pp[0].strip(),pp[1].strip()
21 self.props[k] = v
22 except:
23 traceback.print_exc()
24 self.props ={}
25 return True
26
27 def get(self,key,default=None):
28 return self.props.get(key,default)