applied the except and raise fixers to the master branch to close the gap with py3
[nepi.git] / src / nepi / util / netgraph.py
index 744a95b..49a194b 100644 (file)
@@ -72,14 +72,14 @@ class NetGraph(object):
             :param assign_st: Select source and target nodes on the graph.
             :type assign_st: bool
 
-           :param sources_targets: dictionary with the list of sources (key =
+            :param sources_targets: dictionary with the list of sources (key =
             "sources") and list of targets (key = "targets") if defined, ignore
             assign_st
-           :type sources_targets: dictionary of lists
+            :type sources_targets: dictionary of lists
 
-           :param leaf_source: if True, random sources will be selected only 
+            :param leaf_source: if True, random sources will be selected only 
             from leaf nodes.
-           :type leaf_source: bool
+            :type leaf_source: bool
 
         NOTE: Only point-to-point like network topologies are supported for now.
                 (Wireless and Ethernet networks were several nodes share the same
@@ -107,11 +107,11 @@ class NetGraph(object):
             self.assign_p2p_ips(network = network, prefix = prefix, 
                     version = version)
 
-       sources_targets = kwargs.get("sources_targets")
-       if sources_targets:
+        sources_targets = kwargs.get("sources_targets")
+        if sources_targets:
             [self.set_source(n) for n in sources_targets["sources"]]
-           [self.set_target(n) for n in sources_targets["targets"]]
-       elif kwargs.get("assign_st"):
+            [self.set_target(n) for n in sources_targets["targets"]]
+        elif kwargs.get("assign_st"):
             self.select_target_zero()
             self.select_random_source(is_leaf = kwargs.get("leaf_source"))
 
@@ -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():