Пример #1
0
 def __init__(self, path, mode="r"):
     self.dir = path
     if mode not in ["r", "w", "a"]:
         raise Exception
     if mode == "a":
         self.mode = "w"
     else:
         self.mode = mode
     if mode == "w":
         for tc in glob.glob("%s/inverse_*.btc" % path):
             os.remove(tc)
         if not os.path.isdir(path):
             os.makedirs(path)
         self.store = index.tokyoCabinetData("%s/store" % path, mode)
         self.store.vanish()
         self.cpt = 0
     else:
         self.store = index.tokyoCabinetData("%s/store" % path, self.mode)
         self.cpt = int(self.store.rnum())
     self.cache = RAMCache("%s/cache" % path)
     self.oups = 0
     self.inverse = {}
Пример #2
0
 def __init__(self, path):
     self.cache = index.tokyoCabinetData(path, "w")