git://git.onelab.eu
/
sfa.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b345d6a
)
Ignore meaningless white space in RSpec
author
Andy Bavier
<acb@cs.princeton.edu>
Wed, 27 Jan 2010 21:31:12 +0000
(21:31 +0000)
committer
Andy Bavier
<acb@cs.princeton.edu>
Wed, 27 Jan 2010 21:31:12 +0000
(21:31 +0000)
sfa/util/rspec.py
patch
|
blob
|
history
diff --git
a/sfa/util/rspec.py
b/sfa/util/rspec.py
index
26ba673
..
f891034
100644
(file)
--- a/
sfa/util/rspec.py
+++ b/
sfa/util/rspec.py
@@
-173,11
+173,19
@@
class RSpec:
return self.rootNode.toprettyxml()
return self.rootNode.toprettyxml()
+ def __removeWhitespaceNodes(self, parent):
+ for child in list(parent.childNodes):
+ if child.nodeType == minidom.Node.TEXT_NODE and child.data.strip() == '':
+ parent.removeChild(child)
+ else:
+ self.__removeWhitespaceNodes(child)
+
def parseFile(self, filename):
"""
read a local xml file and store it as a dom object.
"""
dom = minidom.parse(filename)
def parseFile(self, filename):
"""
read a local xml file and store it as a dom object.
"""
dom = minidom.parse(filename)
+ self.__removeWhitespaceNodes(dom)
self.rootNode = dom.childNodes[0]
self.rootNode = dom.childNodes[0]
@@
-185,8
+193,8
@@
class RSpec:
"""
read an xml string and store it as a dom object.
"""
"""
read an xml string and store it as a dom object.
"""
- xml = xml.replace('\n', '').replace('\t', '').strip()
dom = minidom.parseString(xml)
dom = minidom.parseString(xml)
+ self.__removeWhitespaceNodes(dom)
self.rootNode = dom.childNodes[0]
self.rootNode = dom.childNodes[0]
@@
-209,11
+217,13
@@
class RSpec:
def _parseXSD(self, xsdURI):
"""
def _parseXSD(self, xsdURI):
"""
- Download XSD from URL, or if file, read local xsd file and set schemaDict
+ Download XSD from URL, or if file, read local xsd file and set
+ schemaDict.
+
+ Since the schema definiton is a global namespace shared by and
+ agreed upon by others, this should probably be a URL. Check
+ for URL, download xsd, parse, or if local file, use that.
"""
"""
- # Since the schema definiton is a global namespace shared by and agreed upon by
- # others, this should probably be a URL. Check for URL, download xsd, parse, or
- # if local file, use local file.
schemaDom = None
if xsdURI.startswith("http"):
try:
schemaDom = None
if xsdURI.startswith("http"):
try: