summaryrefslogtreecommitdiffstats
path: root/Doc/tools
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>1999-01-29 21:31:12 (GMT)
committerFred Drake <fdrake@acm.org>1999-01-29 21:31:12 (GMT)
commit3a7ff998aca0301659bb906d3631a4e02326615d (patch)
treee593232396bcb9627234fa4acddfaa8b2814903a /Doc/tools
parent3d05b1a0ae8ad4acf733f03b45cf9c51bf3ff47c (diff)
downloadcpython-3a7ff998aca0301659bb906d3631a4e02326615d.zip
cpython-3a7ff998aca0301659bb906d3631a4e02326615d.tar.gz
cpython-3a7ff998aca0301659bb906d3631a4e02326615d.tar.bz2
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.
Diffstat (limited to 'Doc/tools')
-rwxr-xr-xDoc/tools/sgmlconv/docfixer.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/Doc/tools/sgmlconv/docfixer.py b/Doc/tools/sgmlconv/docfixer.py
index 0b73126..68fd4a3 100755
--- a/Doc/tools/sgmlconv/docfixer.py
+++ b/Doc/tools/sgmlconv/docfixer.py
@@ -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):
#