[XML-SIG] Improvement pulldom and minidom
Martin v. Loewis
martin@loewis.home.cs.tu-berlin.de
Sun, 29 Oct 2000 17:46:06 +0100
> I would like to have the two methods hasAttribute and hasAttributeNS
> of DOM2's Element in minidom included.
[...]
> Additonally I propose to replace
These patches look good to me, so I have installed them. Please try to
produce context or unified diffs the next time (e.g. like the ones I
have attached below), either using diff or cvs diff.
Regards,
Martin
Index: minidom.py
===================================================================
RCS file: /cvsroot/pyxml/xml/xml/dom/minidom.py,v
retrieving revision 1.6
diff -u -r1.6 minidom.py
--- minidom.py 2000/10/20 17:19:59 1.6
+++ minidom.py 2000/10/29 16:33:45
@@ -346,6 +346,12 @@
node.unlink()
del self._attrs[node.name]
del self._attrsNS[(node.namespaceURI, node.localName)]
+
+ def hasAttribute(self, name):
+ return self._attrs.has_key(name)
+
+ def hasAttributeNS(self, namespaceURI, localName):
+ return self._attrsNS.has_key((namespaceURI, localName))
def getElementsByTagName(self, name):
return _getElementsByTagNameHelper(self, name, [])
Index: pulldom.py
===================================================================
RCS file: /cvsroot/pyxml/xml/xml/dom/pulldom.py,v
retrieving revision 1.5
diff -u -r1.5 pulldom.py
--- pulldom.py 2000/10/20 16:59:42 1.5
+++ pulldom.py 2000/10/29 16:42:20
@@ -1,6 +1,12 @@
import minidom
import xml.sax,xml.sax.handler
+import types
+try:
+ _StringTypes = [types.StringType, types.UnicodeType]
+except AttributeError:
+ _StringTypes = [types.StringType]
+
START_ELEMENT = "START_ELEMENT"
END_ELEMENT = "END_ELEMENT"
COMMENT = "COMMENT"
@@ -217,7 +223,7 @@
default_bufsize = (2 ** 14) - 20
def parse(stream_or_string, parser=None, bufsize=default_bufsize):
- if type(stream_or_string) is type(""):
+ if type(stream_or_string) in _StringTypes:
stream = open(stream_or_string)
else:
stream = stream_or_string