Commits

Steve Borho committed fc3a16d

shlib: deal with settings file extension change

fixes #50 properly

  • Participants
  • Parent commits 2a0b937

Comments (0)

Files changed (1)

 """
 
 import dumbdbm, anydbm
+saved_default = anydbm._defaultmod
 anydbm._defaultmod = dumbdbm
 
 import os
 
     def read(self):
         self._data.clear()
-        if not os.path.exists(self._path):
+        if os.path.exists(self._path):
+            # One-time import of <=0.7 config file
+            anydbm._defaultmod = saved_default
+            dbase = shelve.open(self._path)
+            self._dbappname = dbase['APPNAME']
+            self.version = dbase['VERSION']
+            self._data.update(dbase.get('DATA', {}))
+            dbase.close()
+            anydbm._defaultmod = dumbdbm
+            os.unlink(self._path)
+            return
+        if not os.path.exists(self._path+'.dat'):
             return
 
         dbase = shelve.open(self._path)