summaryrefslogtreecommitdiffstats
path: root/Lib/xml/dom
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/xml/dom')
-rw-r--r--Lib/xml/dom/minidom.py17
-rw-r--r--Lib/xml/dom/pulldom.py24
2 files changed, 20 insertions, 21 deletions
diff --git a/Lib/xml/dom/minidom.py b/Lib/xml/dom/minidom.py
index 00bd4ca..6a72684 100644
--- a/Lib/xml/dom/minidom.py
+++ b/Lib/xml/dom/minidom.py
@@ -40,7 +40,7 @@ class Node:
def __init__(self):
self.childNodes = []
- if Node._debug:
+ if Node._debug:
index = repr(id(self)) + repr(self.__class__)
Node.allnodes[index] = repr(self.__dict__)
if Node.debug is None:
@@ -52,16 +52,16 @@ class Node:
if key[0:2] == "__":
raise AttributeError
# getattr should never call getattr!
- if self.__dict__.has_key("inGetAttr"):
+ if self.__dict__.has_key("inGetAttr"):
del self.inGetAttr
raise AttributeError, key
prefix, attrname = key[:5], key[5:]
if prefix == "_get_":
self.inGetAttr = 1
- if hasattr(self, attrname):
+ if hasattr(self, attrname):
del self.inGetAttr
- return (lambda self=self, attrname=attrname:
+ return (lambda self=self, attrname=attrname:
getattr(self, attrname))
else:
del self.inGetAttr
@@ -213,7 +213,7 @@ class AttributeList:
def itemsNS(self):
return map(lambda node: ((node.URI, node.localName), node.value),
self._attrs.values())
-
+
def keys(self):
return self._attrs.keys()
@@ -229,7 +229,7 @@ class AttributeList:
def __cmp__(self, other):
if self._attrs is getattr(other, "_attrs", None):
return 0
- else:
+ else:
return cmp(id(self), id(other))
#FIXME: is it appropriate to return .value?
@@ -324,7 +324,7 @@ class Element(Node):
node.unlink()
del self._attrs[node.name]
del self._attrsNS[(node.namespaceURI, node.localName)]
-
+
def getElementsByTagName(self, name):
return _getElementsByTagNameHelper(self, name, [])
@@ -337,7 +337,7 @@ class Element(Node):
# undocumented
def writexml(self, writer):
writer.write("<" + self.tagName)
-
+
a_names = self._get_attributes().keys()
a_names.sort()
@@ -473,4 +473,3 @@ def parse(*args, **kwargs):
def parseString(*args, **kwargs):
"Parse a file into a DOM from a string"
return _doparse(pulldom.parseString, args, kwargs)
-
diff --git a/Lib/xml/dom/pulldom.py b/Lib/xml/dom/pulldom.py
index 7374069..063f7e8 100644
--- a/Lib/xml/dom/pulldom.py
+++ b/Lib/xml/dom/pulldom.py
@@ -49,7 +49,7 @@ class PullDOM(xml.sax.ContentHandler):
attr = self.document.createAttribute(a_localname)
attr.value = value
node.setAttributeNode(attr)
-
+
parent = self.curNode
node.parentNode = parent
self.curNode = node
@@ -72,7 +72,7 @@ class PullDOM(xml.sax.ContentHandler):
attr = self.document.createAttribute(aname)
attr.value = value
node.setAttributeNode(attr)
-
+
parent = self.curNode
node.parentNode = parent
self.curNode = node
@@ -87,7 +87,7 @@ class PullDOM(xml.sax.ContentHandler):
self.lastEvent = self.lastEvent[1]
#self.events.append((END_ELEMENT, node))
self.curNode = node.parentNode
-
+
def comment(self, s):
node = self.document.createComment(s)
parent = self.curNode
@@ -98,7 +98,7 @@ class PullDOM(xml.sax.ContentHandler):
def processingInstruction(self, target, data):
node = self.document.createProcessingInstruction(target, data)
-
+
parent = self.curNode
node.parentNode = parent
self.lastEvent[1] = [(PROCESSING_INSTRUCTION, node), None]
@@ -142,9 +142,9 @@ class ErrorHandler:
def warning(self, exception):
print exception
def error(self, exception):
- raise exception
+ raise exception
def fatalError(self, exception):
- raise exception
+ raise exception
class DOMEventStream:
def __init__(self, stream, parser, bufsize):
@@ -202,18 +202,18 @@ class SAX2DOM(PullDOM):
def processingInstruction(self, target, data):
PullDOM.processingInstruction(self, target, data)
node = self.lastEvent[0][1]
- node.parentNode.appendChild(node)
+ node.parentNode.appendChild(node)
def ignorableWhitespace(self, chars):
PullDOM.ignorableWhitespace(self, chars)
node = self.lastEvent[0][1]
- node.parentNode.appendChild(node)
+ node.parentNode.appendChild(node)
def characters(self, chars):
PullDOM.characters(self, chars)
node = self.lastEvent[0][1]
- node.parentNode.appendChild(node)
-
+ node.parentNode.appendChild(node)
+
default_bufsize = (2 ** 14) - 20
def parse(stream_or_string, parser=None, bufsize=default_bufsize):
@@ -221,7 +221,7 @@ def parse(stream_or_string, parser=None, bufsize=default_bufsize):
stream = open(stream_or_string)
else:
stream = stream_or_string
- if not parser:
+ if not parser:
parser = xml.sax.make_parser()
return DOMEventStream(stream, parser, bufsize)
@@ -230,7 +230,7 @@ def parseString(string, parser=None):
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
-
+
bufsize = len(string)
buf = StringIO(string)
if not parser: