X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=src%2Fnepi%2Futil%2Fnetgraph.py;h=7a681ec3ca405d759a169b91e14b19777342626f;hb=58a2b493f8df1072a1faa653c8abb6a3f9ba21fa;hp=8a36d15f85860425c0ffff2737398cb621c014a1;hpb=3a425e860e6bb734d1adee38ffe3aa9947f26a78;p=nepi.git diff --git a/src/nepi/util/netgraph.py b/src/nepi/util/netgraph.py index 8a36d15f..7a681ec3 100644 --- a/src/nepi/util/netgraph.py +++ b/src/nepi/util/netgraph.py @@ -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")]