mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
3cd3ca6acd
commit
0ab0246048
@ -31,7 +31,7 @@ class CNCX(object): # {{{
|
|||||||
def __init__(self, toc, is_periodical):
|
def __init__(self, toc, is_periodical):
|
||||||
self.strings = OrderedDict()
|
self.strings = OrderedDict()
|
||||||
|
|
||||||
for item in toc.iterdescendants():
|
for item in toc.iterdescendants(breadth_first=True):
|
||||||
self.strings[item.title] = 0
|
self.strings[item.title] = 0
|
||||||
if is_periodical:
|
if is_periodical:
|
||||||
self.strings[item.klass] = 0
|
self.strings[item.klass] = 0
|
||||||
|
@ -1680,8 +1680,15 @@ class TOC(object):
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def iterdescendants(self):
|
def iterdescendants(self, breadth_first=False):
|
||||||
"""Iterate over all descendant nodes in depth-first order."""
|
"""Iterate over all descendant nodes in depth-first order."""
|
||||||
|
if breadth_first:
|
||||||
|
for child in self.nodes:
|
||||||
|
yield child
|
||||||
|
for child in self.nodes:
|
||||||
|
for node in child.iterdescendants(breadth_first=True):
|
||||||
|
yield node
|
||||||
|
else:
|
||||||
for child in self.nodes:
|
for child in self.nodes:
|
||||||
for node in child.iter():
|
for node in child.iter():
|
||||||
yield node
|
yield node
|
||||||
|
Loading…
x
Reference in New Issue
Block a user