use rspec.xml.root instead of rspec.xml
authorTony Mack <tmack@paris.CS.Princeton.EDU>
Tue, 4 Oct 2011 18:43:59 +0000 (14:43 -0400)
committerTony Mack <tmack@paris.CS.Princeton.EDU>
Tue, 4 Oct 2011 18:43:59 +0000 (14:43 -0400)
sfa/rspecs/versions/pgv2.py
sfa/rspecs/versions/sfav1.py

index e2303d1..8286fa4 100644 (file)
@@ -118,7 +118,7 @@ class PGv2(BaseVersion):
                 # node already exists
                 continue
 
-            node_tag = etree.SubElement(self.xml, 'node', exclusive='false')
+            node_tag = etree.SubElement(self.xml.root, 'node', exclusive='false')
             if 'network_urn' in node:
                 node_tag.set('component_manager_id', node['network_urn'])
             if 'urn' in node:
@@ -147,7 +147,7 @@ class PGv2(BaseVersion):
 
     def merge_node(self, source_node_tag):
         # this is untested
-        self.xml.append(deepcopy(source_node_tag))
+        self.xml.root.append(deepcopy(source_node_tag))
 
     def add_slivers(self, slivers, sliver_urn=None, no_dupes=False):
 
@@ -217,7 +217,7 @@ class PGv2(BaseVersion):
         tree = etree.parse(StringIO(in_rspec))
         root = tree.getroot()
         for child in root.getchildren():
-            self.xml.append(child)
+            self.xml.root.append(child)
 
     def cleanup(self):
         # remove unncecessary elements, attributes
index 5eeb51f..d3b1c54 100644 (file)
@@ -188,7 +188,7 @@ class SFAv1(BaseVersion):
     def add_network(self, network):
         network_tags = self.xml.xpath('//network[@name="%s"]' % network)
         if not network_tags:
-            network_tag = etree.SubElement(self.xml, 'network', name=network)
+            network_tag = etree.SubElement(self.xml.root, 'network', name=network)
         else:
             network_tag = network_tags[0]
         return network_tag
@@ -202,7 +202,7 @@ class SFAv1(BaseVersion):
                 # node already exists
                 continue
 
-            network_tag = self.xml
+            network_tag = self.xml.root
             if 'network' in node:
                 network = node['network']
                 network_tag = self.add_network(network)
@@ -348,7 +348,7 @@ class SFAv1(BaseVersion):
         for network in networks:
             current_network = network.get('name')
             if current_network and current_network not in current_networks:
-                self.xml.append(network)
+                self.xml.root.append(network)
                 current_networks.append(current_network)
 
 if __name__ == '__main__':