fix Config error, add get()/set()
This commit is contained in:
parent
3c6703771d
commit
ec8eb3b140
@ -7,10 +7,16 @@ class Config:
|
||||
self.vars = {}
|
||||
if os.path.isfile(filename):
|
||||
f = open(filename, 'r')
|
||||
eval(f, self.vars)
|
||||
exec(f.read(), self.vars)
|
||||
|
||||
def write(self):
|
||||
f = open(self.filename, 'w')
|
||||
for var in self.vars:
|
||||
f.write("%s = %s\n" % (var, repr(self.vars[var])))
|
||||
f.close()
|
||||
|
||||
def get(self, var):
|
||||
return self.vars[var] if var in self.vars else None
|
||||
|
||||
def set(self, var, val):
|
||||
self.vars[var] = val
|
||||
|
Loading…
x
Reference in New Issue
Block a user