[Zope-Checkins] CVS: Zope/lib/python/StructuredText - STDOM.py:1.7.4.2

Chris McDonough chrism@zope.com
Tue, 8 Oct 2002 14:41:43 -0400


Update of /cvs-repository/Zope/lib/python/StructuredText
In directory cvs.zope.org:/tmp/cvs-serv20268/lib/python/StructuredText

Modified Files:
      Tag: chrism-install-branch
	STDOM.py 
Log Message:
Merging HEAD into chrism-install-branch.


=== Zope/lib/python/StructuredText/STDOM.py 1.7.4.1 => 1.7.4.2 ===
--- Zope/lib/python/StructuredText/STDOM.py:1.7.4.1	Sat Sep 28 21:40:35 2002
+++ Zope/lib/python/StructuredText/STDOM.py	Tue Oct  8 14:41:12 2002
@@ -16,9 +16,6 @@
 All standard Zope objects support DOM to a limited extent.
 """
 
-from types import StringType, UnicodeType
-StringTypes = (StringType, UnicodeType)
-
 # Node type codes
 # ---------------
 
@@ -84,7 +81,7 @@
     the child access methods of the DOM.
     """
 
-    def getChildNodes(self, type=type, sts=StringTypes):
+    def getChildNodes(self, type=type, st=type('')):
         """
         Returns a NodeList that contains all children of this node.
         If there are no children, this is a empty NodeList
@@ -92,12 +89,12 @@
 
         r=[]
         for n in self.getChildren():
-            if type(n) in sts: n=TextNode(n)
+            if type(n) is st: n=TextNode(n)
             r.append(n.__of__(self))
 
         return  NodeList(r)
 
-    def getFirstChild(self, type=type, sts=StringTypes):
+    def getFirstChild(self, type=type, st=type('')):
         """
         The first child of this node. If there is no such node
         this returns None
@@ -109,12 +106,12 @@
 
         n=children[0]
 
-        if type(n) in sts:
+        if type(n) is st:
             n=TextNode(n)
 
         return n.__of__(self)
 
-    def getLastChild(self, type=type, sts=StringTypes):
+    def getLastChild(self, type=type, st=type('')):
         """
         The last child of this node.  If there is no such node
         this returns None.
@@ -122,21 +119,21 @@
         children = self.getChildren()
         if not children: return None
         n=chidren[-1]
-        if type(n) in sts: n=TextNode(n)
+        if type(n) is st: n=TextNode(n)
         return n.__of__(self)
 
     """
     create aliases for all above functions in the pythony way.
     """
 
-    def _get_ChildNodes(self, type=type, sts=StringTypes):
-        return self.getChildNodes(type,sts)
+    def _get_ChildNodes(self, type=type, st=type('')):
+        return self.getChildNodes(type,st)
 
-    def _get_FirstChild(self, type=type, sts=StringTypes):
-        return self.getFirstChild(type,sts)
+    def _get_FirstChild(self, type=type, st=type('')):
+        return self.getFirstChild(type,st)
 
-    def _get_LastChild(self, type=type, sts=StringTypes):
-        return self.getLastChild(type,sts)
+    def _get_LastChild(self, type=type, st=type('')):
+        return self.getLastChild(type,st)
 
 class NodeWrapper(ParentNode):
     """
@@ -170,7 +167,7 @@
 
     def getPreviousSibling(self,
                            type=type,
-                           sts=StringTypes,
+                           st=type(''),
                            getattr=getattr,
                            None=None):
 
@@ -193,13 +190,13 @@
         try: n=children[index]
         except IndexError: return None
         else:
-            if type(n) in sts:
+            if type(n) is st:
                 n=TextNode(n)
             n._DOMIndex=index
             return n.__of__(self)
 
 
-    def getNextSibling(self, type=type, sts=StringTypes):
+    def getNextSibling(self, type=type, st=type('')):
         """
         The node immediately preceding this node.  If
         there is no such node, this returns None.
@@ -219,7 +216,7 @@
         except IndexError:
             return None
         else:
-            if type(n) in sts:
+            if type(n) is st:
                 n=TextNode(n)
             n._DOMIndex=index
             return n.__of__(self)
@@ -242,14 +239,14 @@
 
     def _get_PreviousSibling(self,
                            type=type,
-                           sts=StringTypes,
+                           st=type(''),
                            getattr=getattr,
                            None=None):
 
-        return self.getPreviousSibling(type,sts,getattr,None)
+        return self.getPreviousSibling(type,st,getattr,None)
 
-    def _get_NextSibling(self, type=type, sts=StringTypes):
-        return self.getNextSibling(type,sts)
+    def _get_NextSibling(self, type=type, st=type('')):
+        return self.getNextSibling(type,st)
 
     def _get_OwnerDocument(self):
         return self.getOwnerDocument()
@@ -291,7 +288,7 @@
 
     def getPreviousSibling(self,
                            type=type,
-                           sts=StringTypes,
+                           st=type(''),
                            getattr=getattr,
                            None=None):
         """
@@ -299,7 +296,7 @@
         there is no such node, this returns None.
         """
 
-    def getNextSibling(self, type=type, sts=StringTypes):
+    def getNextSibling(self, type=type, st=type('')):
         """
         The node immediately preceding this node.  If
         there is no such node, this returns None.
@@ -345,13 +342,13 @@
 
     def _get_PreviousSibling(self,
                            type=type,
-                           sts=StringTypes,
+                           st=type(''),
                            getattr=getattr,
                            None=None):
 
-        return self.getPreviousSibling(type,sts,getattr,None)
+        return self.getPreviousSibling(type,st,getattr,None)
 
-    def _get_NextSibling(self, type=type, sts=StringTypes):
+    def _get_NextSibling(self, type=type, st=type('')):
         return self.getNextSibling()
 
     def _get_Attributes(self):
@@ -410,10 +407,10 @@
         """A code representing the type of the node."""
         return ELEMENT_NODE
 
-    def getNodeValue(self, type=type, sts=StringTypes):
+    def getNodeValue(self, type=type, st=type('')):
         r=[]
         for c in self.getChildren():
-            if type(c) not in sts:
+            if type(c) is not st:
                 c=c.getNodeValue()
             r.append(c)
         return ''.join(r)
@@ -483,8 +480,8 @@
     def _get_NodeType(self):
         return self.getNodeType()
 
-    def _get_NodeValue(self, type=type, sts=StringTypes):
-        return self.getNodeValue(type,sts)
+    def _get_NodeValue(self, type=type, st=type('')):
+        return self.getNodeValue(type,st)
 
     def _get_ParentNode(self):
         return self.getParentNode()
@@ -520,7 +517,7 @@
     def __init__(self,list=None):
         self._data = list or []
 
-    def __getitem__(self, index, type=type, sts=StringTypes):
+    def __getitem__(self, index, type=type, st=type('')):
         return self._data[index]
 
     def __getslice__(self, i, j):