Code Duplication    Length = 27-27 lines in 2 locations

pyof/v0x04/controller2switch/packet_out.py 1 location

@@ 89-115 (lines=27) @@
86
                                                       type(self).__name__)
87
            raise PackException(msg)
88
89
    def unpack(self, buff, offset=0):
90
        """Unpack a binary message into this object's attributes.
91
92
        Unpack the binary value *buff* and update this object attributes based
93
        on the results. It is an inplace method and it receives the binary data
94
        of the message **without the header**.
95
96
        This class' unpack method is like the :meth:`.GenericMessage.unpack`
97
        one, except for the ``actions`` attribute which has a length determined
98
        by the ``actions_len`` attribute.
99
100
        Args:
101
            buff (bytes): Binary data package to be unpacked, without the
102
                header.
103
            offset (int): Where to begin unpacking.
104
        """
105
        begin = offset
106
        for attribute_name, class_attribute in self.get_class_attributes():
107
            if type(class_attribute).__name__ != "Header":
108
                attribute = deepcopy(class_attribute)
109
                if attribute_name == 'actions':
110
                    length = self.actions_len.value
111
                    attribute.unpack(buff[begin:begin+length])
112
                else:
113
                    attribute.unpack(buff, begin)
114
                setattr(self, attribute_name, attribute)
115
                begin += attribute.get_size()
116
117
    def _update_actions_len(self):
118
        """Update the actions_len field based on actions value."""

pyof/v0x01/controller2switch/packet_out.py 1 location

@@ 79-105 (lines=27) @@
76
                                                       type(self).__name__)
77
            raise PackException(msg)
78
79
    def unpack(self, buff, offset=0):
80
        """Unpack a binary message into this object's attributes.
81
82
        Unpack the binary value *buff* and update this object attributes based
83
        on the results. It is an inplace method and it receives the binary data
84
        of the message **without the header**.
85
86
        This class' unpack method is like the :meth:`.GenericMessage.unpack`
87
        one, except for the ``actions`` attribute which has a length determined
88
        by the ``actions_len`` attribute.
89
90
        Args:
91
            buff (bytes): Binary data package to be unpacked, without the
92
                header.
93
            offset (int): Where to begin unpacking.
94
        """
95
        begin = offset
96
        for attribute_name, class_attribute in self.get_class_attributes():
97
            if type(class_attribute).__name__ != "Header":
98
                attribute = deepcopy(class_attribute)
99
                if attribute_name == 'actions':
100
                    length = self.actions_len.value
101
                    attribute.unpack(buff[begin:begin+length])
102
                else:
103
                    attribute.unpack(buff, begin)
104
                setattr(self, attribute_name, attribute)
105
                begin += attribute.get_size()
106
107
    def _update_actions_len(self):
108
        """Update the actions_len field based on actions value."""