Dict Comprehension is available in Python 2.7+ but Ryu should work
with Python2.6. Currently, It will become syntax error when we try to
operate BGP of Ryu on the platform of Python2.6.

Signed-off-by: Satoshi Kobayashi <[email protected]>
---
 ryu/services/protocols/bgp/operator/command.py                | 5 +++--
 ryu/services/protocols/bgp/operator/commands/show/neighbor.py | 6 +++---
 ryu/services/protocols/bgp/operator/commands/show/vrf.py      | 3 ++-
 ryu/services/protocols/bgp/operator/views/base.py             | 2 +-
 ryu/services/protocols/bgp/peer.py                            | 5 +++--
 ryu/services/protocols/bgp/speaker.py                         | 8 ++++----
 6 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/ryu/services/protocols/bgp/operator/command.py 
b/ryu/services/protocols/bgp/operator/command.py
index 64449ef..8cdb579 100644
--- a/ryu/services/protocols/bgp/operator/command.py
+++ b/ryu/services/protocols/bgp/operator/command.py
@@ -257,8 +257,9 @@ class TextFilter(object):
                 resp = [resp[key] for key, value in enumerate(resp)
                         if key not in remove]
             else:
-                resp = {key: value for key, value in resp.iteritems()
-                        if key not in remove}
+                resp = dict([(key, value)
+                             for key, value in resp.iteritems()
+                             if key not in remove])
 
             return resp
         else:
diff --git a/ryu/services/protocols/bgp/operator/commands/show/neighbor.py 
b/ryu/services/protocols/bgp/operator/commands/show/neighbor.py
index 9f3f5ed..f4d0f11 100644
--- a/ryu/services/protocols/bgp/operator/commands/show/neighbor.py
+++ b/ryu/services/protocols/bgp/operator/commands/show/neighbor.py
@@ -61,10 +61,10 @@ class SentRoutes(Command):
             return WrongParamResp('wrong addr_family name')
 
         ret = self._retrieve_paths(addr_family, rf, ip_addr).encode()
-        ret = {
-            path['nlri']['formatted_nlri']: path
+        ret = dict([
+            (path['nlri']['formatted_nlri'], path)
             for path in ret
-        }
+        ])
 
         return CommandsResponse(STATUS_OK, ret)
 
diff --git a/ryu/services/protocols/bgp/operator/commands/show/vrf.py 
b/ryu/services/protocols/bgp/operator/commands/show/vrf.py
index d1f4b6f..2938e9f 100644
--- a/ryu/services/protocols/bgp/operator/commands/show/vrf.py
+++ b/ryu/services/protocols/bgp/operator/commands/show/vrf.py
@@ -137,7 +137,8 @@ class Summary(Command, CountRoutesMixin):
                     vrf_rf
                 )
 
-            encoded = {str(k): v for k, v in encoded.iteritems()}
+            encoded = dict([(str(k), v)
+                            for k, v in encoded.iteritems()])
             return CommandsResponse(
                 STATUS_OK,
                 encoded
diff --git a/ryu/services/protocols/bgp/operator/views/base.py 
b/ryu/services/protocols/bgp/operator/views/base.py
index bf62732..2916df6 100644
--- a/ryu/services/protocols/bgp/operator/views/base.py
+++ b/ryu/services/protocols/bgp/operator/views/base.py
@@ -49,7 +49,7 @@ class OperatorAbstractView(object):
     def _collect_fields(cls):
         names = [attr for attr in dir(cls)
                  if isinstance(getattr(cls, attr), fields.Field)]
-        return {name: getattr(cls, name) for name in names}
+        return dict([(name, getattr(cls, name)) for name in names])
 
     def combine_related(self, field_name):
         """Combines related views. In case of DetailView it just returns
diff --git a/ryu/services/protocols/bgp/peer.py 
b/ryu/services/protocols/bgp/peer.py
index 16576c2..49c7151 100644
--- a/ryu/services/protocols/bgp/peer.py
+++ b/ryu/services/protocols/bgp/peer.py
@@ -167,8 +167,9 @@ class PeerState(object):
         )
 
     def _remember_last_bgp_error(self, identifier, data):
-        self._last_bgp_error = {k: v for k, v in data.iteritems()
-                                if k != 'peer'}
+        self._last_bgp_error = dict([(k, v)
+                                     for k, v in data.iteritems()
+                                     if k != 'peer'])
 
     @property
     def recv_prefix(self):
diff --git a/ryu/services/protocols/bgp/speaker.py 
b/ryu/services/protocols/bgp/speaker.py
index f66ea41..c206e42 100644
--- a/ryu/services/protocols/bgp/speaker.py
+++ b/ryu/services/protocols/bgp/speaker.py
@@ -233,14 +233,14 @@ class BgpProtocol(Protocol, Activity):
 
         # Check MP_BGP capabilities were advertised.
         if local_mbgp_cap and remote_mbgp_cap:
-            local_families = {
+            local_families = set([
                 (peer_cap.afi, peer_cap.safi)
                 for peer_cap in local_mbgp_cap
-            }
-            remote_families = {
+            ])
+            remote_families = set([
                 (peer_cap.afi, peer_cap.safi)
                 for peer_cap in remote_mbgp_cap
-            }
+            ])
             afi_safi = local_families.intersection(remote_families)
         else:
             afi_safi = set()
-- 
1.8.5.2 (Apple Git-48)


------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to