blind review on list-operations added by 2to3:
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Wed, 14 Oct 2015 08:54:20 +0000 (10:54 +0200)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Wed, 14 Oct 2015 09:04:12 +0000 (11:04 +0200)
* some calls to list() were not needed
* some where linked to map() and replaced by [ for ]
* some constructions like for i in range(len(myiter)): were replaced by for item in myiter (and in rare cases together with enumerate)
* sometimes for k in d.keys() -> for k in d:
the plan is to will leave items() and values() and keys() in the code for both py2 and py3 ultimately, so no changes there in this commit

31 files changed:
examples/ccn_emu_live/dce.py
examples/ccn_emu_live/dce_4_nodes_linear.py
examples/ccn_emu_live/planetlab.py
examples/ccn_emu_live/planetlab_4_nodes_linear.py
examples/linux/testing/ccncat_extended_ring_topo.py
examples/omf/testing/nepi_omf5_nitos_ccnring.py
examples/omf/testing/nepi_omf5_plexus_ccncat_linear.py
examples/openvswitch/ovs_ping_3_switches.py
examples/planetlab/update_fedora_repo.py
src/nepi/data/processing/ccn/parser.py
src/nepi/resources/linux/application.py
src/nepi/resources/linux/node.py
src/nepi/resources/linux/scripts/tunchannel.py
src/nepi/resources/netns/netnswrapper.py
src/nepi/resources/netns/netnswrapper_debug.py
src/nepi/resources/ns3/ns3base.py
src/nepi/resources/ns3/ns3server.py
src/nepi/resources/ns3/ns3wifimac.py
src/nepi/resources/ns3/ns3wrapper.py
src/nepi/resources/ns3/ns3wrapper_debug.py
src/nepi/resources/omf/messages_6.py
src/nepi/resources/omf/omf6_parser.py
src/nepi/resources/omf/wilabt_node.py
src/nepi/resources/planetlab/plcapi.py
src/nepi/resources/planetlab/sfa_node.py
src/nepi/util/environ.py
src/nepi/util/execfuncs.py
src/nepi/util/parsers/xml_parser.py
src/nepi/util/sfaapi.py
src/nepi/util/sfarspec_proc.py
src/nepi/util/sshfuncs.py

index b996ea4..326a33b 100644 (file)
@@ -162,7 +162,7 @@ def avg_interests(ec, run):
 
     ### Compute metric: Avg number of Interests seen per content name
     ###                 normalized by the number of nodes in the shortest path
-    content_name_count = len(list(content_names.values()))
+    content_name_count = len(content_names)
     nodes_in_shortest_path = len(shortest_path) - 1
     metric = interest_count / (float(content_name_count) * float(nodes_in_shortest_path))
 
index 3a7221d..799e4e4 100644 (file)
@@ -46,7 +46,7 @@ def avg_interest_rtt(ec, run):
 
     # statistics on RTT
     rtts = [content_names[content_name]["rtt"] \
-            for content_name in list(content_names.keys())]
+            for content_name in content_names]
 
     # sample mean and standard deviation
     sample = numpy.array(rtts)
@@ -78,7 +78,7 @@ def post_process(ec, runs):
     low = numpy.array([float(m[1]) for m in metrics])
     high = numpy.array([float(m[2]) for m in metrics])
     error = [y - low, high - y]
-    x = list(range(1,runs + 1))
+    x = range(1,runs + 1)
 
     # plot average RTT and confidence interval for each iteration
     pyplot.errorbar(x, y, yerr = error, fmt='o')
index 4c8a4a3..643f33c 100644 (file)
@@ -166,7 +166,7 @@ def avg_interests(ec, run):
 
     ### Compute metric: Avg number of Interests seen per content name
     ###                 normalized by the number of nodes in the shortest path
-    content_name_count = len(list(content_names.values()))
+    content_name_count = len(content_names)
     nodes_in_shortest_path = len(shortest_path) - 1
     metric = interest_count / (float(content_name_count) * float(nodes_in_shortest_path))
 
index d2d9f4c..12f81c1 100644 (file)
@@ -74,7 +74,7 @@ def avg_interest_rtt(ec, run):
 
     # statistics on RTT
     rtts = [content_names[content_name]["rtt"] \
-            for content_name in list(content_names.keys())]
+            for content_name in content_names]
 
     # sample mean and standard deviation
     sample = numpy.array(rtts)
index d16143a..2e5cce8 100644 (file)
@@ -213,7 +213,7 @@ if __name__ == '__main__':
 
     # Register a collector to automatically collect traces
     collector = add_collector(ec, "stderr")
-    for ccnd in list(ccnds.values()):
+    for ccnd in ccnds:
         ec.register_connection(collector, ccnd)
 
     # deploy all ResourceManagers
index 7b9e09b..680b2a7 100644 (file)
@@ -176,23 +176,23 @@ if __name__ == '__main__':
     nodes = dict()
 
     chann = add_channel(ec, channel, xmpp_slice, xmpp_host)
-    for i in range(len(all_hosts)):
-        node = add_node(ec,all_hosts[i], xmpp_slice, xmpp_host)
+    for i, host in enumerate(all_hosts):
+        node = add_node(ec ,host, xmpp_slice, xmpp_host)
         iface = add_interface(ec, all_ip[i], xmpp_slice, xmpp_host)
         ec.register_connection(node, iface)
         ec.register_connection(iface, chann)
-        nodes[all_hosts[i]] = node
+        nodes[host] = node
 
 # CCN setup for the node
     ccnds = dict()
     ccnrs = dict()
-    for i in range(len(all_hosts)):
-        ccndstart = add_app(ec, nodes[all_hosts[i]],  "#ccndstart", "ccndstart &", 
+    for i, host in enumerate(all_hosts):
+        ccndstart = add_app(ec, nodes[host],  "#ccndstart", "ccndstart &", 
                               env, xmpp_slice, xmpp_host)
-        ccnr = add_app(ec, nodes[all_hosts[i]],  "#ccnr", "ccnr &", 
+        ccnr = add_app(ec, nodes[host],  "#ccnr", "ccnr &", 
                              env, xmpp_slice, xmpp_host)
-        ccnds[all_hosts[i]] = ccndstart
-        ccnrs[all_hosts[i]] = ccnr
+        ccnds[host] = ccndstart
+        ccnrs[host] = ccnr
         ec.register_condition(ccnr, ResourceAction.START, ccndstart, ResourceState.STARTED, "1s")
 
 # CCNDC setup 
@@ -226,9 +226,9 @@ if __name__ == '__main__':
     link = [l1u, l1d, l2u, l2d, l3u, l3d, l4u, l4d, l5u, l5d, b1u, b1d, b2u, b2d]
 
 # List of condition
-    for i in range(len(all_hosts)):
-         ec.register_condition(ccnrs[all_hosts[i]], ResourceAction.START, ccnds[all_hosts[i]], ResourceState.STARTED, "1s")
-         ec.register_condition(link, ResourceAction.START, ccnrs[all_hosts[i]], ResourceState.STARTED, "1s")
+    for host in all_hosts:
+         ec.register_condition(ccnrs[host], ResourceAction.START, ccnds[host], ResourceState.STARTED, "1s")
+         ec.register_condition(link, ResourceAction.START, ccnrs[host], ResourceState.STARTED, "1s")
 
 # Streaming Server
     pub = add_publish(ec, nodes[host5], movie, xmpp_slice, xmpp_host)
index 2c2b411..bb812ef 100644 (file)
@@ -166,12 +166,12 @@ if __name__ == '__main__':
     nodes = dict()
 
     chann = add_channel(ec, channel, xmpp_slice, xmpp_host)
-    for i in range(len(all_hosts)):
-        node = add_node(ec,all_hosts[i], xmpp_slice, xmpp_host)
+    for i, host in enumerate(all_hosts):
+        node = add_node(ec,host, xmpp_slice, xmpp_host)
         iface = add_interface(ec, all_ip[i], xmpp_slice, xmpp_host)
         ec.register_connection(node, iface)
         ec.register_connection(iface, chann)
-        nodes[all_hosts[i]] = node
+        nodes[host] = node
 
 #### CCN setup for the node
 ###    ccnds = dict()
@@ -213,28 +213,28 @@ if __name__ == '__main__':
 # Do the iperf
     iperfserv = dict()
     iperfclient = dict()
-    for i in range(len(all_hosts)):
-        perfserv = add_app(ec, nodes[all_hosts[i]],  "#perfserv", "iperf -s > /opt/iperfserv.txt", 
+    for i, host in enumerate(all_hosts):
+        perfserv = add_app(ec, nodes[host],  "#perfserv", "iperf -s > /opt/iperfserv.txt", 
                               env, xmpp_slice, xmpp_host)
-        iperfclient[all_hosts[i]] = []
+        iperfclient[host] = []
         if i > 0:
             cmd = "iperf -c " + all_ip[i-1] + " > /opt/iperclient1.txt"
-            perfclient1 = add_app(ec, nodes[all_hosts[i]],  "#perfclient1", cmd, 
+            perfclient1 = add_app(ec, nodes[host],  "#perfclient1", cmd, 
                             env, xmpp_slice, xmpp_host)
-            iperfclient[all_hosts[i]].append(perfclient1)
+            iperfclient[host].append(perfclient1)
 
         if i < (len(all_hosts)-1):
             cmd = "iperf -c " + all_ip[i+1] + " > /opt/iperclient2.txt"
-            perfclient2 = add_app(ec, nodes[all_hosts[i]],  "#perfclient2", cmd, 
+            perfclient2 = add_app(ec, nodes[host],  "#perfclient2", cmd, 
                             env, xmpp_slice, xmpp_host)
-            iperfclient[all_hosts[i]].append(perfclient2)
+            iperfclient[host].append(perfclient2)
 
-        iperfserv[all_hosts[i]] = perfserv
+        iperfserv[host] = perfserv
 
-    for i in range(len(all_hosts)):
-         #ec.register_condition(iperfserv[all_hosts[i]], ResourceAction.START, link, ResourceState.STARTED, "2s")
-         for elt in iperfclient[all_hosts[i]]:
-             ec.register_condition(elt, ResourceAction.START, iperfserv[all_hosts[i]], ResourceState.STARTED, "3s")
+    for host in all_hosts:
+         #ec.register_condition(iperfserv[host], ResourceAction.START, link, ResourceState.STARTED, "2s")
+         for elt in iperfclient[host]:
+             ec.register_condition(elt, ResourceAction.START, iperfserv[host], ResourceState.STARTED, "3s")
 
 
 ## Streaming Server
@@ -257,18 +257,18 @@ if __name__ == '__main__':
 ##        ccndstop = add_app(ec, nodes[all_hosts[i]], "#ccndstop", "ccndstop", env, xmpp_slice, xmpp_host)
 ##        ccndstops.append(ccndstop)
     perfkill = dict()
-    for i in range(len(all_hosts)):
-        kill = add_app(ec, nodes[all_hosts[i]], "#kill", "killall iperf", "", xmpp_slice, xmpp_host)
-        perfkill[all_hosts[i]] = kill
+    for host in all_hosts:
+        kill = add_app(ec, nodes[host], "#kill", "killall iperf", "", xmpp_slice, xmpp_host)
+        perfkill[host] = kill
 
 
 # Condition to stop and clean the experiment
     apps = []
-    for i in range(len(all_hosts)):
-#        apps.append(ccnds[all_hosts[i]])
-#        apps.append(ccnrs[all_hosts[i]])
-        apps.append(iperfserv[all_hosts[i]])
-        for elt in iperfclient[all_hosts[i]]:
+    for host in all_hosts:
+#        apps.append(ccnds[host])
+#        apps.append(ccnrs[host])
+        apps.append(iperfserv[host])
+        for elt in iperfclient[host]:
             apps.append(elt)
 #    apps += link
     #apps.append(pub)
@@ -280,8 +280,8 @@ if __name__ == '__main__':
 #    ec.register_condition(ccndstops + [killall], ResourceAction.STOP, ccndstops, ResourceState.STARTED, "1s")
 
     killall = []
-    for i in range(len(all_hosts)):
-        killall.append(perfkill[all_hosts[i]])
+    for host in all_hosts:
+        killall.append(perfkill[host])
 
     ec.register_condition(killall, ResourceAction.START, apps, ResourceState.STOPPED, "1s")
     ec.register_condition(killall, ResourceAction.STOP, killall, ResourceState.STARTED, "1s")
index ee22e1c..510c9e6 100644 (file)
@@ -236,7 +236,9 @@ for r1, (n1, ip1) in r2ip.items():
 
 ec.deploy()
 
-ec.wait_finished(list(apps.values()))
+# py3: no need to transform into a list
+# as wait_finished (wait in fact) will do it anyway
+ec.wait_finished(apps.values())
 
 # collect results
 for key, app in apps.items():
index 6bd9986..f4929fb 100644 (file)
@@ -67,7 +67,7 @@ pl_user = options.pl_user
 pl_password = options.pl_password
 hosts = options.hosts
 
-hosts = list(map(str.strip, hosts.split(",")))
+hosts = [host.strip() for host in hosts.split(",")]
 apps = []
 
 ## Create the experiment controller
index 582b8dd..ae2e18c 100644 (file)
@@ -281,7 +281,7 @@ def process_content_history(graph):
         fname = graph.node[nid]["history"]
         history = load_content_history(fname)
 
-        for content_name in list(history.keys()):
+        for content_name in history:
             hist = history[content_name]
 
             for (timestamp, message_type, nid1, nid2, nonce, size, line) in hist:
@@ -334,7 +334,7 @@ def process_content_history(graph):
 
     # Compute the time elapsed between the time an interest is sent
     # in the consumer node and when the content is received back
-    for content_name in list(content_names.keys()):
+    for content_name in content_names:
         # order content and interest messages by timestamp
         content_names[content_name]["content"] = sorted(
               content_names[content_name]["content"])
index 2dcde66..a496159 100644 (file)
@@ -398,7 +398,7 @@ class LinuxApplication(ResourceManager):
         if sources:
             self.info("Uploading sources ")
 
-            sources = list(map(str.strip, sources.split(";")))
+            sources = [str.strip(source) for source in sources.split(";")]
 
             # Separate sources that should be downloaded from 
             # the web, from sources that should be uploaded from
index 7558475..c10bc58 100644 (file)
@@ -489,7 +489,8 @@ class LinuxNode(ResourceManager):
                     # adding the avoided pids filtered above (avoid_kill) to allow users keep process
                     # alive when using besides ssh connections  
                     kill_pids = set(pids_temp.items()) - set(pids.items())
-                    kill_pids = ' '.join(list(dict(kill_pids).keys()))
+                    # py2/py3 : keep it simple
+                    kill_pids = ' '.join(kill_pids)
 
                     # removing pids from beside connections and its process
                     kill_pids = kill_pids.split(' ')
@@ -773,9 +774,9 @@ class LinuxNode(ResourceManager):
             src = f.name
 
         # If dst files should not be overwritten, check that the files do not
-        # exits already
+        # exist already
         if isinstance(src, str):
-            src = list(map(str.strip, src.split(";")))
+            src = [s.strip() for s in src.split(";")]
     
         if overwrite == False:
             src = self.filter_existing_files(src, dst)
@@ -1178,19 +1179,20 @@ class LinuxNode(ResourceManager):
                 if len(src) > 1 else {dst: src[0]}
 
         command = []
-        for d in list(dests.keys()):
+        for d in dests:
             command.append(" [ -f {dst} ] && echo '{dst}' ".format(dst=d) )
 
         command = ";".join(command)
 
         (out, err), proc = self.execute(command, retry = 1, with_lock = True)
         
-        for d in list(dests.keys()):
+        for d in dests:
             if out.find(d) > -1:
                 del dests[d]
 
         if not dests:
             return []
 
+        # list(..) here added by 2to3 - leaving for safety
         return list(dests.values())
 
index 11c68af..cca5205 100644 (file)
@@ -37,8 +37,7 @@ import ctypes
 import time
 
 def ipfmt(ip):
-    ipbytes = list(map(ord,ip.decode("hex")))
-    return '.'.join(map(str,ipbytes))
+    return '.'.join(str(ord(x)) for x in ip.decode("hex"))
 
 tagtype = {
     '0806' : 'arp',
index b7847ef..f1fe4cd 100644 (file)
@@ -112,6 +112,7 @@ class NetNSWrapper(object):
         # If the result is an object (not a base value),
         # then keep track of the object a return the object
         # reference (newuuid)
+        # xxx the two instances of `int` are from 2to3
         if not (result is None or type(result) in [
                 bool, float, int, str, int]):
             self._objects[newuuid] = result
index 83a33cd..4ebdc0f 100644 (file)
@@ -147,11 +147,10 @@ wrapper = NS3Wrapper()
         return pprint.pformat(value)
 
     def format_args(self, args):
-        fargs = list(map(self.format_value, args))
-        return "[%s]" % ",".join(fargs)
+        return "[%s]" % ",".join(self.format_value(arg) for arg in args)
 
     def format_kwargs(self, kwargs):
-        fkwargs = ["%s: %s" % (self.format_value(k_w[0]), self.format_value(k_w[1])) for k_w in iter(kwargs.items())]
+        fkwargs = ["%s: %s" % (self.format_value(k), self.format_value(v)) for (k, v) in kwargs.items()]
         
         return  "dict({%s})" % ",".join(fkwargs)
         
index 4794849..26632e0 100644 (file)
@@ -81,7 +81,7 @@ class NS3Base(ResourceManager):
             return 
 
         kwargs = dict()
-        for attr in list(self._attrs.values()):
+        for attr in self._attrs.values():
             if not ( attr.has_flag(Flags.Construct) and attr.has_changed ):
                 continue
 
index ce6c895..589e3d4 100644 (file)
@@ -138,7 +138,7 @@ def recv_msg(conn):
         item = base64.b64decode(item).rstrip()
         return pickle.loads(item)
 
-    decoded = list(map(decode, msg.split("|")))
+    decoded = [ decode(x) for x in msg.split("|") ]
 
     # decoded message
     dmsg_type = decoded.pop(0)
index 04bd83a..f3dd5cd 100644 (file)
@@ -29,6 +29,7 @@ class NS3BaseWifiMac(NS3Base):
     def _register_attributes(cls):
         standard = Attribute("Standard", "Wireless standard",
                 default = "WIFI_PHY_STANDARD_80211a",
+                # staying safe with 2to3's generated list
                 allowed = list(WIFI_STANDARDS.keys()),
                 type = Types.Enumerate,
                 flags = Flags.Design)
index cea3afb..dcaadeb 100644 (file)
@@ -326,6 +326,7 @@ class NS3Wrapper(object):
             # If the result is an object (not a base value),
             # then keep track of the object a return the object
             # reference (newuuid)
+            # xxx the two instances of `int` are from 2to3
             if not (result is None or type(result) in [
                     bool, float, int, str, int]):
                 self._objects[newuuid] = result
index 75df9bc..51f1fc7 100644 (file)
@@ -167,11 +167,10 @@ wrapper = NS3Wrapper()
         return pprint.pformat(value)
 
     def format_args(self, args):
-        fargs = list(map(self.format_value, args))
-        return "[%s]" % ",".join(fargs)
+        return "[%s]" % ",".join(self.format_value(arg) for arg in args)
 
     def format_kwargs(self, kwargs):
-        fkwargs = ["%s: %s" % (self.format_value(k_w[0]), self.format_value(k_w[1])) for k_w in iter(kwargs.items())]
+        fkwargs = ["%s: %s" % (self.format_value(k), self.format_value(v)) for (k, v) in kwargs.items()]
         
         return  "dict({%s})" % ",".join(fkwargs)
         
index 49c9e9c..b7f3044 100644 (file)
@@ -114,17 +114,17 @@ class MessageHandler():
             else:
                 properties = self._attr_element(payload,"props","")
 
-            for prop in list(props.keys()):
+            for prop in props:
                 if isinstance(props[prop],str):
                     self._attr_element(properties,prop,props[prop],type_key="type", type_value = "string")
                 elif isinstance(props[prop],dict):
                     key = self._attr_element(properties,prop,"",type_key="type", type_value = "hash")
-                    for comp in list(props[prop].keys()):
+                    for comp in props[prop]:
                         self._attr_element(key,comp,props[prop][comp],type_key="type", type_value = "string")
 
         if guards :
             guardians = self._attr_element(payload,"guard","")
-            for guard in list(guards.keys()):
+            for guard in guards:
                 self._attr_element(guardians,guard,guards[guard],type_key="type", type_value = "string")
 
         return payload
@@ -149,12 +149,12 @@ class MessageHandler():
 
         if props :
             properties = self._attr_element(payload,"props","")
-            for prop in list(props.keys()):
+            for prop in props:
                 self._attr_element(properties,prop,props[prop],type_key="type", type_value = "symbol")
            
         if guards :
             guardians = self._attr_element(payload,"guard","")
-            for guard in list(guards.keys()):
+            for guard in guards:
                 self._attr_element(guardians,guard,guards[guard],type_key="type", type_value = "string")
 
         return payload
index 4ddd60e..85aa394 100644 (file)
@@ -175,7 +175,7 @@ class OMF6Parser(Logger):
         event = self._check_for_tag(root, namespaces, "event")
 
         log = "STATUS -- "
-        for elt in list(props.keys()):
+        for elt in props:
             ns, tag = elt.split('}')
             if tag == "it":
                 log = log + "membership : " + props[elt]+" -- "
index 4513949..8ce3e21 100644 (file)
@@ -407,7 +407,7 @@ class WilabtSfaNode(OMFNode):
         slice_nodes = self.sfaapi.get_slice_resources(slicename)['resource']
         if slice_nodes:
             if len(slice_nodes[0]['services']) != 0:
-                slice_nodes_hrn = list(self.sfaapi.get_resources_hrn(slice_nodes).values())
+                slice_nodes_hrn = self.sfaapi.get_resources_hrn(slice_nodes).values()
         else: slice_nodes_hrn = []
         nodes_inslice = list(set(hosts_hrn) & set(slice_nodes_hrn))
         return nodes_inslice
index 23a898f..6188967 100644 (file)
@@ -343,7 +343,7 @@ class PLCAPI(object):
                                     filters = filters, peer=None, **kw)
                          )
                     else:
-                        peer_filter = list(map(name_to_id, peer))
+                        peer_filter = [name_to_id(x) for x in peer]
 
                 elif peer is None or peer == self._local_peer:
                     peer_filter = None
index 9ca3181..4a8659d 100644 (file)
@@ -260,7 +260,7 @@ class PlanetlabSfaNode(LinuxNode):
             super(PlanetlabSfaNode, self).do_discover()
 
         else:
-            hosts_hrn = list(nodes.values())
+            hosts_hrn = nodes.values()
             nodes_inslice = self._check_if_in_slice(hosts_hrn)
             nodes_not_inslice = list(set(hosts_hrn) - set(nodes_inslice))
             host_hrn = None
@@ -597,7 +597,7 @@ class PlanetlabSfaNode(LinuxNode):
         slicename = 'ple.' + slicename
         slice_nodes = self.sfaapi.get_slice_resources(slicename)['resource']
         if slice_nodes:
-            slice_nodes_hrn = list(self.sfaapi.get_resources_hrn(slice_nodes).values())
+            slice_nodes_hrn = self.sfaapi.get_resources_hrn(slice_nodes).values()
         else: slice_nodes_hrn = []
         nodes_inslice = list(set(hosts_hrn) & set(slice_nodes_hrn))
         return nodes_inslice
index 101ad19..f8ec9cd 100644 (file)
@@ -164,7 +164,7 @@ def gen_sshd_config(filename, port, server_key, auth_keys):
 def gen_auth_keys(pubkey, output, environ):
     #opts = ['from="127.0.0.1/32"'] # fails in stupid yans setup
     opts = []
-    for k, v in list(environ.items()):
+    for k, v in environ.items():
         opts.append('environment="%s=%s"' % (k, v))
 
     lines = file(pubkey).readlines()
index 1cc4e05..1f7b6b9 100644 (file)
@@ -179,7 +179,7 @@ def lgetpid(pidfile):
     
     if out:
         try:
-            return list(map(int,out.strip().split(' ',1)))
+            return [ int(x) for x in out.strip().split(' ',1))]
         except:
             # Ignore, many ways to fail that don't matter that much
             return None
index 7a23736..b42d39b 100644 (file)
@@ -198,7 +198,7 @@ class ECXMLParser(object):
         anode = doc.createElement("attributes")
         attributes = False
 
-        for attr in list(rm._attrs.values()):
+        for attr in rm._attrs.values():
             if attr.has_changed:
                 attributes = True
                 aanode = doc.createElement("attribute")
@@ -241,7 +241,7 @@ class ECXMLParser(object):
         tnode = doc.createElement("traces")
         traces = False
 
-        for trace in list(rm._trcs.values()):
+        for trace in rm._trcs.values():
             if trace.enabled:
                 traces = True
                 ttnode = doc.createElement("trace")
index 345e9f1..2f81c10 100644 (file)
@@ -303,6 +303,7 @@ class SFAAPI(object):
         slice_res = self.get_slice_resources(slicename)['resource']
         if slice_res:
             if len(slice_res[0]['services']) != 0:
+                # 2to3 added list() and it is useful
                 slice_res_hrn = list(self.get_resources_hrn(slice_res).values())
                 if self._compare_lists(slice_res_hrn, resources_hrn):
                     return True
index d5e0735..27dbbc0 100644 (file)
@@ -43,7 +43,7 @@ class SfaRSpecProcessing(object):
             return objcopy
         # We thus suppose we have a child of dict
         objcopy = {}
-        for k, v in list(obj.items()):
+        for k, v in obj.items():
             objcopy[k] = self.make_dict_rec(v)
         return objcopy
 
index 34d19a2..f33b9c6 100644 (file)
@@ -556,7 +556,7 @@ def rgetpid(pidfile,
     
     if out:
         try:
-            return list(map(int,out.strip().split(' ',1)))
+            return [ int(x) for x in out.strip().split(' ',1)) ]
         except:
             # Ignore, many ways to fail that don't matter that much
             return None