Code Duplication    Length = 26-28 lines in 2 locations

pyof/v0x04/controller2switch/multipart_request.py 1 location

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

pyof/v0x04/controller2switch/multipart_reply.py 1 location

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