Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3a7ff99

Browse files
committed
fixup_descriptors(): Change the way we look for descriptor nodes;
this takes 5 minutes off the conversion of the whole tree by reducing the number of tree-traversals from 14 to 1.
1 parent 3d05b1a commit 3a7ff99

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

Doc/tools/sgmlconv/docfixer.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,21 @@ def cleanup_root_text(doc):
131131
)
132132

133133
def fixup_descriptors(doc):
134-
for tagName in DESCRIPTOR_ELEMENTS:
135-
nodes = find_all_elements(doc, tagName)
136-
for node in nodes:
137-
rewrite_descriptor(doc, node)
134+
sections = find_all_elements(doc, "section")
135+
for section in sections:
136+
find_and_fix_descriptors(doc, section)
137+
138+
139+
def find_and_fix_descriptors(doc, container):
140+
children = container.childNodes
141+
for child in children:
142+
if child.nodeType == xml.dom.core.ELEMENT:
143+
tagName = child.tagName
144+
if tagName in DESCRIPTOR_ELEMENTS:
145+
rewrite_descriptor(doc, child)
146+
elif tagName == "subsection":
147+
find_and_fix_descriptors(doc, child)
148+
138149

139150
def rewrite_descriptor(doc, descriptor):
140151
#

0 commit comments

Comments
 (0)