def compact(self): data = [] count = 0 f = open(self.data_path + "/compact/%i" % (self.revision), 'w') for i in self.transactions: if Transaction.exists(self.data_path, i): i = Transaction.load(self.data_path, i) f.write("begin %s\n" % i.path()) for j in i.statements: f.write(j.as_json() + '\n') os.remove(self.data_path + "/transaction/%s" % i.path()) f.close() f = open(self.data_path + "/checkpoints/%i" % self.revision, 'w') for i in self: for j in i: f.write( json.dumps([j.key, j.get_data()]) + "\n") subdir = j.hashed_key()[:2] all_revs = self.get_all_parent_revs(j) for rev in all_revs: if os.path.exists(self.data_path + "/data/%s/%s_%s" % (subdir, j.hashed_key(), rev)): os.remove(self.data_path + "/data/%s/%s_%s" % (subdir, j.hashed_key(), rev)) f.close()