Config class writes out its values
This commit is contained in:
parent
f56791b2dd
commit
08128f5be0
10
Config.py
10
Config.py
@ -1,6 +1,14 @@
|
|||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
def __init__(self, filename):
|
def __init__(self, filename):
|
||||||
|
self.filename = filename
|
||||||
|
self.vars = {}
|
||||||
if os.path.isfile(filename):
|
if os.path.isfile(filename):
|
||||||
f = open(filename, 'r')
|
f = open(filename, 'r')
|
||||||
eval(f, self)
|
eval(f, 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()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user