mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-04 08:02:34 +03:00
Add methods for python3 iterator
xmlCoreDepthFirstItertor and xmlCoreBreadthFirstItertr only implement a python2-compatible iterator interface. The next() method has been changed to __next__(). An alias has been defined to keep python2 compatibility.
This commit is contained in:
committed by
Daniel Veillard
parent
33f658c969
commit
b3e488b0d9
@ -530,7 +530,7 @@ class xmlCoreDepthFirstItertor:
|
||||
self.parents = []
|
||||
def __iter__(self):
|
||||
return self
|
||||
def next(self):
|
||||
def __next__(self):
|
||||
while 1:
|
||||
if self.node:
|
||||
ret = self.node
|
||||
@ -542,6 +542,7 @@ class xmlCoreDepthFirstItertor:
|
||||
except IndexError:
|
||||
raise StopIteration
|
||||
self.node = parent.next
|
||||
next = __next__
|
||||
|
||||
#
|
||||
# implements the breadth-first iterator for libxml2 DOM tree
|
||||
@ -552,7 +553,7 @@ class xmlCoreBreadthFirstItertor:
|
||||
self.parents = []
|
||||
def __iter__(self):
|
||||
return self
|
||||
def next(self):
|
||||
def __next__(self):
|
||||
while 1:
|
||||
if self.node:
|
||||
ret = self.node
|
||||
@ -564,6 +565,7 @@ class xmlCoreBreadthFirstItertor:
|
||||
except IndexError:
|
||||
raise StopIteration
|
||||
self.node = parent.children
|
||||
next = __next__
|
||||
|
||||
#
|
||||
# converters to present a nicer view of the XPath returns
|
||||
|
Reference in New Issue
Block a user