[Uludag-commits] r15244 - branches/pisi-db/pisi/db

uludag-commits at pardus.org.tr uludag-commits at pardus.org.tr
1 Eyl 2007 Cmt 16:59:23 EEST


Author: faik
Date: Sat Sep  1 16:59:23 2007
New Revision: 15244

Modified:
   branches/pisi-db/pisi/db/filesdb.py
Log:
use __check_filesdb

Use check_filesdb in __init__ and add functions


Modified: branches/pisi-db/pisi/db/filesdb.py
=================================================================
--- branches/pisi-db/pisi/db/filesdb.py	(original)
+++ branches/pisi-db/pisi/db/filesdb.py	Sat Sep  1 16:59:23 2007
@@ -29,16 +29,7 @@
 
     def __init__(self):
         self.filesdb = {}
-        
-        files_db = os.path.join(ctx.config.lib_dir(), ctx.const.info_dir, ctx.const.files_db)
-        if os.path.exists(files_db):
-
-            if os.access(files_db, os.W_OK):
-                flag = ""
-            else:
-                flag = "r"
-
-            self.filesdb = shelve.open(files_db, flag)
+        self.__check_filesdb()
     
     def has_file(self, path):
         return self.filesdb.has_key(path)
@@ -71,5 +62,13 @@
             os.makedirs(info_dir)
 
         files_db = os.path.join(ctx.config.lib_dir(), ctx.const.info_dir, ctx.const.files_db)
+
         if not os.path.exists(files_db):
-            self.filesdb = shelve.open(files_db)
+            flag = "c"
+        elif os.access(files_db, os.W_OK):
+            flag = "w"
+        else:
+            flag = "r"
+
+        self.filesdb = shelve.open(files_db, flag)
+        


Uludag-commits mesaj listesiyle ilgili daha fazla bilgi