Repository: kytos/python-openflow

Issue:
Attribute with builtin name
In `/v0x04/common/queue.py`, `class QueuePropHeader` has an attribute called `property`, which is a Python builtin name. Is this needed somehow?

Comments:

Patch:
diff --git a/pyof/v0x01/common/queue.py b/pyof/v0x01/common/queue.py
index 8bb6fd0..b33d776 100644
--- a/pyof/v0x01/common/queue.py
+++ b/pyof/v0x01/common/queue.py
@@ -49,21 +49,21 @@ class ListOfProperties(FixedTypeList):
 class QueuePropHeader(GenericStruct):
     """Describe the header of each queue property."""
 
-    property = UBInt16(enum_ref=QueueProperties)
-    len = UBInt16()
+    queue_property = UBInt16(enum_ref=QueueProperties)
+    length = UBInt16()
     #: 64-bit alignment
     pad = Pad(4)
 
-    def __init__(self, prop=None, length=None):
+    def __init__(self, queue_property=None, length=None):
         """The contructor takes the paremeters below.
 
         Args:
-            property (QueueProperties): The queue property.
-            len (int): Length of property, including this header.
+            queue_property (QueueProperties): The queue property.
+            length (int): Length of property, including this header.
         """
         super().__init__()
-        self.property = prop
-        self.len = length
+        self.queue_property = queue_property
+        self.length = length
 
 
 class PacketQueue(GenericStruct):
@@ -93,8 +93,8 @@ class PacketQueue(GenericStruct):
 class QueuePropMinRate(GenericStruct):
     """Define the minimum-rate type queue."""
 
-    prop_header = QueuePropHeader(prop=QueueProperties.OFPQT_MIN_RATE,
-                                  length=16)
+    prop_header = QueuePropHeader(
+        queue_property=QueueProperties.OFPQT_MIN_RATE, length=16)
     rate = UBInt16()
     #: 64-bit alignmet.
     pad = Pad(6)
diff --git a/pyof/v0x04/common/queue.py b/pyof/v0x04/common/queue.py
index 56b3f37..c48f592 100644
--- a/pyof/v0x04/common/queue.py
+++ b/pyof/v0x04/common/queue.py
@@ -35,22 +35,22 @@ class QueuePropHeader(GenericStruct):
     """Describe the header of each queue property."""
 
     #: One of OFPQT_*
-    property = UBInt16(enum_ref=QueueProperties)
+    queue_property = UBInt16(enum_ref=QueueProperties)
     #: Length of property, including this header
     length = UBInt16()
     #: 64-bit alignment
     pad = Pad(4)
 
     # pylint: disable=redefined-builtin
-    def __init__(self, property=None, length=None):
+    def __init__(self, queue_property=None, length=None):
         """The contructor takes the paremeters below.
 
         Args:
-            property (QueueProperties): The queue property.
-            len (int): Length of property, including this header.
+            queue_property (QueueProperties): The queue property.
+            length (int): Length of property, including this header.
         """
         super().__init__()
-        self.property = property
+        self.queue_property = queue_property
         self.length = length
 
 
@@ -124,8 +124,8 @@ class ListOfQueues(FixedTypeList):
 class QueuePropExperimenter(GenericStruct):
     """Experimenter queue property uses the following structure and fields."""
 
-    prop_header = QueuePropHeader(property=QueueProperties.OFPQT_EXPERIMENTER,
-                                  length=16)
+    prop_header = QueuePropHeader(
+        queue_property=QueueProperties.OFPQT_EXPERIMENTER, length=16)
     #: Experimenter ID which takes the same form as in struct
     #:     ofp_experimenter_header
     experimenter = UBInt32()
@@ -150,8 +150,8 @@ class QueuePropExperimenter(GenericStruct):
 class QueuePropMaxRate(GenericStruct):
     """Maximum-rate queue property uses the following structure and fields."""
 
-    prop_header = QueuePropHeader(property=QueueProperties.OFPQT_MAX_RATE,
-                                  length=16)
+    prop_header = QueuePropHeader(
+        queue_property=QueueProperties.OFPQT_MAX_RATE, length=16)
     #: In 1/10 of a percent; >1000 -> disabled.
     rate = UBInt16()
     #: 64-bit alignmet.
@@ -170,8 +170,8 @@ class QueuePropMaxRate(GenericStruct):
 class QueuePropMinRate(GenericStruct):
     """Minimum-rate queue property uses the following structure and fields."""
 
-    prop_header = QueuePropHeader(property=QueueProperties.OFPQT_MIN_RATE,
-                                  length=16)
+    prop_header = QueuePropHeader(
+        queue_property=QueueProperties.OFPQT_MIN_RATE, length=16)
     #: In 1/10 of a percent; >1000 -> disabled.
     rate = UBInt16()
     #: 64-bit alignmet.


Test patch:
diff --git a/tests/v0x01/test_common/test_queue.py b/tests/v0x01/test_common/test_queue.py
index 89ae5ed..6054e5b 100644
--- a/tests/v0x01/test_common/test_queue.py
+++ b/tests/v0x01/test_common/test_queue.py
@@ -10,8 +10,8 @@ class TestQueuePropHeader(unittest.TestCase):
     def setUp(self):
         """Basic setup for test."""
         self.message = queue.QueuePropHeader()
-        self.message.property = queue.QueueProperties.OFPQT_MIN_RATE
-        self.message.len = 12
+        self.message.queue_property = queue.QueueProperties.OFPQT_MIN_RATE
+        self.message.length = 12
 
     def test_get_size(self):
         """[Common/QueuePropHeader] - size 8."""
diff --git a/tests/v0x01/test_controller2switch/test_queue_get_config_reply.py b/tests/v0x01/test_controller2switch/test_queue_get_config_reply.py
index 1d7ad38..46db67f 100644
--- a/tests/v0x01/test_controller2switch/test_queue_get_config_reply.py
+++ b/tests/v0x01/test_controller2switch/test_queue_get_config_reply.py
@@ -32,6 +32,6 @@ def _get_packet_queue():
 def _get_queue_properties():
     """Function used to return a list of queue properties."""
     properties = []
-    properties.append(QueuePropHeader(prop=QueueProperties.OFPQT_MIN_RATE,
-                                      length=12))
+    properties.append(QueuePropHeader(
+        queue_property=QueueProperties.OFPQT_MIN_RATE, length=12))
     return properties