@@ 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 | buff = self.body |
|
81 | if not value: |
|
82 | value = self.body |
|
83 | ||
84 | if value: |
|
85 | if isinstance(value, (list, FixedTypeList)): |
|
86 | obj = self._get_body_instance() |
|
87 | obj.extend(value) |
|
88 | elif hasattr(value, 'pack'): |
|
89 | obj = value |
|
90 | ||
91 | self.body = obj.pack() |
|
92 | ||
93 | multiparty_packed = super().pack() |
|
94 | self.body = buff |
|
95 | ||
96 | return multiparty_packed |
|
97 | ||
98 | def unpack(self, buff, offset=0): |
@@ 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 | buff = self.body |
|
96 | if not value: |
|
97 | value = self.body |
|
98 | ||
99 | if value: |
|
100 | if isinstance(value, (list, FixedTypeList)): |
|
101 | obj = self._get_body_instance() |
|
102 | obj.extend(value) |
|
103 | elif hasattr(value, 'pack'): |
|
104 | obj = value |
|
105 | ||
106 | self.body = obj.pack() |
|
107 | ||
108 | multiparty_packed = super().pack() |
|
109 | self.body = buff |
|
110 | ||
111 | return multiparty_packed |
|
112 | ||
113 | def unpack(self, buff, offset=0): |
|
114 | """Unpack a binary message into this object's attributes. |