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:
35bbaa0
)
still needs work, but getting there. tips? ;)
author
Reed Moran
<rmoran@cs.princeton.edu>
Wed, 21 Jan 2009 22:01:11 +0000
(22:01 +0000)
committer
Reed Moran
<rmoran@cs.princeton.edu>
Wed, 21 Jan 2009 22:01:11 +0000
(22:01 +0000)
rspec/parse2.py
patch
|
blob
|
history
diff --git
a/rspec/parse2.py
b/rspec/parse2.py
index
096e802
..
9256f4b
100644
(file)
--- a/
rspec/parse2.py
+++ b/
rspec/parse2.py
@@
-1,13
+1,14
@@
-import xml.dom.minidom
+from xml.dom.minidom import *
+
sample_xml_file = 'sample_rspec.xml'
f = open(sample_xml_file, 'r')
lines = f.readlines()
xml = ""
for line in lines:
sample_xml_file = 'sample_rspec.xml'
f = open(sample_xml_file, 'r')
lines = f.readlines()
xml = ""
for line in lines:
- xml += line.replace('\n', '',).rep
al
ce('\t', '').strip()
+ xml += line.replace('\n', '',).rep
la
ce('\t', '').strip()
-dom =
xml.dom.minidom.
parseString(xml)
+dom = parseString(xml)
def getText(nodelist):
rc = ""
def getText(nodelist):
rc = ""
@@
-19,11
+20,12
@@
def getText(nodelist):
def handleRspec(rspec):
# create rspec dict
rdict = {}
def handleRspec(rspec):
# create rspec dict
rdict = {}
- tempdic
t = {}
+ tempdic
= []
# loop through each network element
for i in rspec.getElementsByTagName("NetSpec"):
# handle networks call
# loop through each network element
for i in rspec.getElementsByTagName("NetSpec"):
# handle networks call
- tempdic[i] = (handleNetworks(rspec.getElementsByTagName("NetSpec")[i]))
+ temp = handleNetworks(i)
+ tempdic.append(temp)
# append the temp dict
rdict['networks'] = tempdic
return rdict
# append the temp dict
rdict['networks'] = tempdic
return rdict
@@
-45,11
+47,11
@@
def handleNodes(node):
for i in node.attributes:
a = node.attributes[i]
nodict[a.name] = a.value
for i in node.attributes:
a = node.attributes[i]
nodict[a.name] = a.value
-
+ tempd = []
# loop through each IF element
for i in node.getElementsByTagName("IfSpec"):
# handle ifs
# loop through each IF element
for i in node.getElementsByTagName("IfSpec"):
# handle ifs
- tempd
[i] = handleIfs(node.getElementByTagName("IfSpec")[i]
)
+ tempd
.append(handleIfs(i)
)
# append temp dict
nodict['ifs'] = tempd
return nodict
# append temp dict
nodict['ifs'] = tempd
return nodict
@@
-57,10
+59,11
@@
def handleNodes(node):
def handleNetworks(network):
# create network dict
ndict = {'name':network.nodeName}
def handleNetworks(network):
# create network dict
ndict = {'name':network.nodeName}
+ tempdict = []
# loop through each node element
# loop through each node element
- for i in network.getElementsByTagName:
+ for i in network.getElementsByTagName
("NodeSpec")
:
# handle nodes
# handle nodes
- tempdict
[i] = handleNodes(network.getElementsByTagName("NodeSpec")[i]
)
+ tempdict
.append(handleNodes(i)
)
# append temp dict
ndict['nodes'] = tempdict
return ndict
# append temp dict
ndict['nodes'] = tempdict
return ndict