Beispiel #1
0
 def __iter__(self):        
     self.cursor.set(zeros(self.pre))
     self.parentPre, val = self.cursor.current()
     self.parentPost, parent, type, data = pickle.loads(val)
     self.isNext = self.cursor.set(zeros(int(self.parentPre) + 1))
     self.nextPre, self.nextVal = self.cursor.current()
     return self
Beispiel #2
0
 def children(self):
     while self.isNext != None:
         pre = self.nextPre
         post, parent, type, data = pickle.loads(self.nextVal)
         self.isNext = self.cursor.set(zeros(int(post) + 1))
         self.nextPre, self.nextVal = self.cursor.current()
         if self.nodeTest == "*" or (type == "elem" and data == self.nodeTest) or (type == "text" and self.nodeTest == "text()"):
             return XmlNodeTuple(pre, post, parent, type, data)
     raise StopIteration
Beispiel #3
0
 def PrintAll(self):
     cursor = self.database.cursor()
     start_pre = zeros(1)
     cursor.set_range(start_pre)
     x = 0
     while cursor.next():
         pre, val = cursor.current()
         post, parent, type, data = pickle.loads(val)
         print string.join([pre.__repr__(), post.__repr__(), parent.__repr__(), type, data], " ")
         x += 1
     print x
     cursor.close()
Beispiel #4
0
 def Tuple(self, pre):
     cursor = self.database.cursor()
     cursor.set(zeros(pre))
     pre, val = cursor.current()
     post, parent, type, data = pickle.loads(val)
     return XmlNodeTuple(int(pre), post, parent, type, data)
Beispiel #5
0
 def AddTuple(self, pre, post, parent, type, value):
     self.i += 1
     newPre = zeros(pre)
     # newPre = pre
     self.database.put(newPre, pickle.dumps((post, parent, type, value)))