diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-08-05 12:38:49 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-08-05 12:38:49 +0200 |
commit | 3ff84e841db60c275df2df4256505a26b8c2ee08 (patch) | |
tree | 349e8723c964b0de4c64769ae2f9ab532661bdba /module/ConfigParser.py | |
parent | single file abort (diff) | |
download | pyload-3ff84e841db60c275df2df4256505a26b8c2ee08.tar.xz |
file version check, delete old configs!
Diffstat (limited to 'module/ConfigParser.py')
-rw-r--r-- | module/ConfigParser.py | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/module/ConfigParser.py b/module/ConfigParser.py index e3d1e038e..49401416b 100644 --- a/module/ConfigParser.py +++ b/module/ConfigParser.py @@ -5,8 +5,11 @@ from pprint import pprint from os.path import exists from os.path import join from shutil import copy +from os import remove +CONF_VERSION = 1 + ######################################################################## class ConfigParser: """ @@ -53,9 +56,29 @@ class ConfigParser: if not exists("plugin.conf"): f = open("plugin.conf", "wb") + f.write("version: "+str(CONF_VERSION)) f.close() - #@TODO: testing conf file version + f = open("pyload.conf", "rb") + v = f.readline() + f.close() + v = v[v.find(":")+1:].strip() + + if int(v) < CONF_VERSION: + copy(join(pypath,"module", "config", "default.conf"), "pyload.conf") + print "Old version of config was replaced" + + f = open("plugin.conf", "rb") + v = f.readline() + f.close() + v = v[v.find(":")+1:].strip() + + if int(v) < CONF_VERSION: + f = open("plugin.conf", "wb") + f.write("version: "+str(CONF_VERSION)) + f.close() + print "Old version of config was replaced" + #---------------------------------------------------------------------- def readConfig(self): @@ -87,7 +110,7 @@ class ConfigParser: config = f.read() - config = config.split("\n") + config = config.split("\n")[1:] conf = {} @@ -192,7 +215,7 @@ class ConfigParser: def saveConfig(self, config, filename): """saves config to filename""" with open(filename, "wb") as f: - + f.write("config: %i \n" % CONF_VERSION) for section in config.iterkeys(): f.write('\n%s - "%s":\n' % (section, config[section]["desc"])) |