+# For environment settings
+class Config:
+ def asDict(self):
+ return self.__dict__.copy()
+
+ def write(self, filename="config", outfile=None):
+ if outfile is None:
+ f = file(filename, "w")
+ else:
+ f = outfile
+ for k, v in self.__dict__.items():
+ f.write('%s="%s"\n' % (k, v))
+
+ def read(self, filename="config"):
+ myfile = open(filename, "r")
+ for line in myfile.readlines():
+ line = line.strip()
+ if len(line) > 0 and line[0] == "#":
+ continue # it's a comment, move on
+ data = line.split("=")
+ if len(data) == 2:
+ self.__dict__[data[0].strip()] = data[1].strip()
+ myfile.close()