still making both branches closer
[nepi.git] / src / nepi / util / netgraph.py
index 8a36d15..7a681ec 100644 (file)
@@ -155,9 +155,9 @@ class NetGraph(object):
             nodesinbranch = (node_count - 1)/ BRANCHES
             c = 1
 
-            for i in xrange(BRANCHES):
+            for i in range(BRANCHES):
                 prev = 0
-                for n in xrange(1, nodesinbranch + 1):
+                for n in range(1, nodesinbranch + 1):
                     graph.add_node(c)
                     graph.add_edge(prev, c)
                     prev = c
@@ -188,7 +188,7 @@ class NetGraph(object):
     def annotate_node(self, nid, name, value):
         if not isinstance(value, str) and not isinstance(value, int) and \
                 not isinstance(value, float) and not isinstance(value, bool):
-            raise RuntimeError, "Non-serializable annotation"
+            raise RuntimeError("Non-serializable annotation")
 
         self.topology.node[nid][name] = value
     
@@ -204,7 +204,7 @@ class NetGraph(object):
     def annotate_edge(self, nid1, nid2, name, value):
         if not isinstance(value, str) and not isinstance(value, int) and \
                 not isinstance(value, float) and not isinstance(value, bool):
-            raise RuntimeError, "Non-serializable annotation"
+            raise RuntimeError("Non-serializable annotation")
 
         self.topology.edge[nid1][nid2][name] = value
    
@@ -256,7 +256,7 @@ class NetGraph(object):
             net = ipaddr.IPv6Network(netblock)
             new_prefix = 30
         else:
-            raise RuntimeError, "Invalid IP version %d" % version
+            raise RuntimeError("Invalid IP version %d" % version)
         
         ## Clear all previusly assigned IPs
         for nid in self.topology.nodes():
@@ -333,7 +333,7 @@ class NetGraph(object):
             source = leaves.pop(random.randint(0, len(leaves) - 1))
         else:
             # options must not be already sources or targets
-            options = [ k for k,v in self.topology.degree().iteritems() \
+            options = [ k for k,v in self.topology.degree().items() \
                     if (not kwargs.get("is_leaf") or v == 1)  \
                         and not self.topology.node[k].get("source") \
                         and not self.topology.node[k].get("target")]