]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
fixup_descriptors(): Change the way we look for descriptor nodes;
authorFred Drake <fdrake@acm.org>
Fri, 29 Jan 1999 21:31:12 +0000 (21:31 +0000)
committerFred Drake <fdrake@acm.org>
Fri, 29 Jan 1999 21:31:12 +0000 (21:31 +0000)
this takes 5 minutes off the conversion of the whole tree by
reducing the number of tree-traversals from 14 to 1.

Doc/tools/sgmlconv/docfixer.py

index 0b73126551600d08ca8bd837529a2c519524d330..68fd4a3731178c750a9f21b3f61a7527674bfce8 100755 (executable)
@@ -131,10 +131,21 @@ DESCRIPTOR_ELEMENTS = (
     )
 
 def fixup_descriptors(doc):
-    for tagName in DESCRIPTOR_ELEMENTS:
-        nodes = find_all_elements(doc, tagName)
-        for node in nodes:
-            rewrite_descriptor(doc, node)
+    sections = find_all_elements(doc, "section")
+    for section in sections:
+        find_and_fix_descriptors(doc, section)
+
+
+def find_and_fix_descriptors(doc, container):
+    children = container.childNodes
+    for child in children:
+        if child.nodeType == xml.dom.core.ELEMENT:
+            tagName = child.tagName
+            if tagName in DESCRIPTOR_ELEMENTS:
+                rewrite_descriptor(doc, child)
+            elif tagName == "subsection":
+                find_and_fix_descriptors(doc, child)
+
 
 def rewrite_descriptor(doc, descriptor):
     #