[Python-checkins] CVS: python/dist/src/Doc/tools/sgmlconv docfixer.py,1.32,1.33

Fred L. Drake fdrake@users.sourceforge.net
2001年9月28日 22:05:27 -0700


Update of /cvsroot/python/python/dist/src/Doc/tools/sgmlconv
In directory usw-pr-cvs1:/tmp/cvs-serv24152
Modified Files:
	docfixer.py 
Log Message:
Fix up whitespace in <args> elements; reduce sequences of consecutive
whitespace characters to a single space.
Small changes elsewhere, mostly to clean up the code a little.
Index: docfixer.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/tools/sgmlconv/docfixer.py,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** docfixer.py	2001年09月28日 17:14:35	1.32
--- docfixer.py	2001年09月29日 05:05:25	1.33
***************
*** 390,407 ****
 d[gi] = gi
 rewrite_element = d.has_key
! queue = []
! for node in doc.childNodes:
! if node.nodeType == ELEMENT:
! queue.append(node)
 while queue:
 node = queue[0]
 del queue[0]
 if rewrite_element(node.tagName):
! children = node.childNodes
! if len(children) == 1 \
! and children[0].nodeType == TEXT:
! data = children[0].data
! if data[-2:] == "()":
! children[0].data = data[:-2]
 else:
 for child in node.childNodes:
--- 390,403 ----
 d[gi] = gi
 rewrite_element = d.has_key
! queue = [node for node in doc.childNodes if node.nodeType == ELEMENT]
 while queue:
 node = queue[0]
 del queue[0]
 if rewrite_element(node.tagName):
! lastchild = node.lastChild
! if lastchild and lastchild.nodeType == TEXT:
! data = lastchild.data
! if data.endswith("()"):
! lastchild.data = data[:-2]
 else:
 for child in node.childNodes:
***************
*** 774,784 ****
 args = child.getElementsByTagName("args")
 for arg in args:
! fixup_args(doc, arg)
! arg.normalize()
 args = child.getElementsByTagName("constructor-args")
 for arg in args:
! fixup_args(doc, arg)
! arg.normalize()
 
 
 def fixup_args(doc, arglist):
--- 770,784 ----
 args = child.getElementsByTagName("args")
 for arg in args:
! rewrite_args(doc, arg)
 args = child.getElementsByTagName("constructor-args")
 for arg in args:
! rewrite_args(doc, arg)
 
+ def rewrite_args(doc, arglist):
+ fixup_args(doc, arglist)
+ arglist.normalize()
+ if arglist.childNodes.length == 1 and arglist.firstChild.nodeType == TEXT:
+ node = arglist.firstChild
+ node.data = ' '.join(node.data.split())
 
 def fixup_args(doc, arglist):
***************
*** 789,795 ****
 optkids = child.childNodes
 while optkids:
! k = optkids[0]
! child.removeChild(k)
! arglist.insertBefore(k, child)
 arglist.insertBefore(doc.createTextNode("]"), child)
 arglist.removeChild(child)
--- 789,793 ----
 optkids = child.childNodes
 while optkids:
! arglist.insertBefore(child.firstChild, child)
 arglist.insertBefore(doc.createTextNode("]"), child)
 arglist.removeChild(child)

AltStyle によって変換されたページ (->オリジナル) /