]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Inline "for val in [ref]" statements
authorCedric Brandily <zzelle@gmail.com>
Tue, 26 Aug 2014 18:10:15 +0000 (20:10 +0200)
committerCedric Brandily <zzelle@gmail.com>
Tue, 26 Aug 2014 21:01:22 +0000 (23:01 +0200)
This change increases readibility by inlining "for val in [ref]":

 for val in [ref]:
   f(val)

becomes:

 f(ref)

Change-Id: I8e1f95bd7eb99a25c6460beb2ac3230c53740181

neutron/plugins/cisco/db/n1kv_db_v2.py
neutron/services/loadbalancer/drivers/radware/driver.py
neutron/tests/unit/db/vpn/test_db_vpnaas.py

index 602931a8db0d27b5dfcacc460b983021ea6e1f24..691fabd54bfd9086b92c15fd685693c8a6a806de 100644 (file)
@@ -1294,7 +1294,7 @@ class NetworkProfile_db_mixin(object):
 
         :param net_p: network profile object
         """
-        if any(net_p[arg] == "" for arg in ["segment_type"]):
+        if net_p["segment_type"] == "":
             msg = _("Arguments segment_type missing"
                     " for network profile")
             LOG.error(msg)
index e480c2f690d61041f97dc8252fad8255e9919707..a04b8cfd0ac6022e45b55bda0c9b493f80554a41 100644 (file)
@@ -1109,8 +1109,7 @@ def _translate_vip_object_graph(extended_vip, plugin, context):
                           _trans_prop_name(hm_property))].append(value)
     ids = get_ids(extended_vip)
     trans_vip['__ids__'] = ids
-    for key in ['pip_address']:
-        if key in extended_vip:
-            trans_vip[key] = extended_vip[key]
+    if 'pip_address' in extended_vip:
+        trans_vip['pip_address'] = extended_vip['pip_address']
     LOG.debug('Translated Vip graph: ' + str(trans_vip))
     return trans_vip
index a12a61335af1cfcb2aee1e1eaca4fbd4242145c1..cb87c37d571f25d14b6b8eedeba45e0c9d550f92 100644 (file)
@@ -85,9 +85,8 @@ class VPNTestMixin(object):
                 'pfs': pfs,
                 'tenant_id': self._tenant_id
                 }}
-        for arg in ['description']:
-            if arg in kwargs and kwargs[arg] is not None:
-                data['ikepolicy'][arg] = kwargs[arg]
+        if kwargs.get('description') is not None:
+            data['ikepolicy']['description'] = kwargs['description']
 
         ikepolicy_req = self.new_create_request('ikepolicies', data, fmt)
         ikepolicy_res = ikepolicy_req.get_response(self.ext_api)
@@ -148,9 +147,8 @@ class VPNTestMixin(object):
                                              'value': lifetime_value},
                                 'pfs': pfs,
                                 'tenant_id': self._tenant_id}}
-        for arg in ['description']:
-            if arg in kwargs and kwargs[arg] is not None:
-                data['ipsecpolicy'][arg] = kwargs[arg]
+        if kwargs.get('description') is not None:
+            data['ipsecpolicy']['description'] = kwargs['description']
         ipsecpolicy_req = self.new_create_request('ipsecpolicies', data, fmt)
         ipsecpolicy_res = ipsecpolicy_req.get_response(self.ext_api)
         if expected_res_status:
@@ -198,9 +196,8 @@ class VPNTestMixin(object):
                                'router_id': router_id,
                                'admin_state_up': admin_state_up,
                                'tenant_id': tenant_id}}
-        for arg in ['description']:
-            if arg in kwargs and kwargs[arg] is not None:
-                data['vpnservice'][arg] = kwargs[arg]
+        if kwargs.get('description') is not None:
+            data['vpnservice']['description'] = kwargs['description']
         vpnservice_req = self.new_create_request('vpnservices', data, fmt)
         if (kwargs.get('set_context') and
                 'tenant_id' in kwargs):
@@ -309,9 +306,9 @@ class VPNTestMixin(object):
                                       'admin_state_up': admin_state_up,
                                       'tenant_id': self._tenant_id}
         }
-        for arg in ['description']:
-            if arg in kwargs and kwargs[arg] is not None:
-                data['ipsec_site_connection'][arg] = kwargs[arg]
+        if kwargs.get('description') is not None:
+            data['ipsec_site_connection'][
+                'description'] = kwargs['description']
 
         ipsec_site_connection_req = self.new_create_request(
             'ipsec-site-connections', data, fmt