normalize str() outputs so that tests like str(msg1) == str(msg2)
more likely succeed.

Signed-off-by: YAMAMOTO Takashi <yamam...@valinux.co.jp>
---
 ryu/ofproto/ofproto_v1_2_parser.py | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/ryu/ofproto/ofproto_v1_2_parser.py 
b/ryu/ofproto/ofproto_v1_2_parser.py
index 570a815..244fd3d 100644
--- a/ryu/ofproto/ofproto_v1_2_parser.py
+++ b/ryu/ofproto/ofproto_v1_2_parser.py
@@ -2154,8 +2154,6 @@ class OFPMatchField(StringifyMixin):
         del v['header']
         del v['length']
         del v['n_bytes']
-        if 'mask' in v and v['mask'] is None:
-            del v['mask']
         return d
 
     @classmethod
@@ -2164,6 +2162,19 @@ class OFPMatchField(StringifyMixin):
         # it will be converted by OFPMatch.__init__().
         return {cls.__name__: dict_}
 
+    def stringify_attrs(self):
+        f = super(OFPMatchField, self).stringify_attrs
+        if not ofproto_v1_2.oxm_tlv_header_extract_hasmask(self.header):
+            # something like the following, but yield two values (k,v)
+            # return itertools.ifilter(lambda k, v: k != 'mask', iter())
+            def g():
+                for k, v in f():
+                    if k != 'mask':
+                        yield (k, v)
+            return g()
+        else:
+            return f()
+
 
 @OFPMatchField.register_field_header([ofproto_v1_2.OXM_OF_IN_PORT])
 class MTInPort(OFPMatchField):
-- 
1.8.1.5


------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to