Code Duplication    Length = 26-28 lines in 2 locations

pyof/v0x04/controller2switch/multipart_request.py 1 location

@@ 68-95 (lines=28) @@
65
        self.body = body
66
67
    def pack(self, value=None):
68
        """Pack a MultipartRequest using the object's attributes.
69
70
        This method will pack the attribute body and multipart_type before pack
71
        the MultipartRequest object, then will return this struct as a
72
        binary data.
73
74
        Args:
75
            value (:class:`~MultipartRequest`): Object to be packed.
76
77
        Returns:
78
            bytes: Binary data with MultipartRequest packed.
79
80
        """
81
        buff = self.body
82
        if not value:
83
            value = self.body
84
85
        if value:
86
            if isinstance(value, (list, FixedTypeList)):
87
                obj = self._get_body_instance()
88
                obj.extend(value)
89
            elif hasattr(value, 'pack'):
90
                obj = value
91
92
            self.body = obj.pack()
93
94
        multiparty_packed = super().pack()
95
        self.body = buff
96
97
        return multiparty_packed
98

pyof/v0x04/controller2switch/multipart_reply.py 1 location

@@ 86-111 (lines=26) @@
83
        self.flags = flags
84
        self.body = body
85
86
    def pack(self, value=None):
87
        """Pack a StatsReply using the object's attributes.
88
89
        This method will pack the attribute body and multipart_type before pack
90
        the StatsReply object, then will return this struct as a binary data.
91
92
        Returns:
93
            stats_reply_packed (bytes): Binary data with StatsReply packed.
94
95
        """
96
        buff = self.body
97
        if not value:
98
            value = self.body
99
100
        if value:
101
            if isinstance(value, (list, FixedTypeList)):
102
                obj = self._get_body_instance()
103
                obj.extend(value)
104
            elif hasattr(value, 'pack'):
105
                obj = value
106
107
            self.body = obj.pack()
108
109
        multiparty_packed = super().pack()
110
        self.body = buff
111
112
        return multiparty_packed
113
114
    def unpack(self, buff, offset=0):