Check if the data contains binary components.
(cls, data)
| 168 | |
| 169 | @classmethod |
| 170 | def data_is_binary(cls, data): |
| 171 | """Check if the data contains binary components.""" |
| 172 | if isinstance(data, (bytes, bytearray)): |
| 173 | return True |
| 174 | elif isinstance(data, list): |
| 175 | return functools.reduce( |
| 176 | lambda a, b: a or b, [cls.data_is_binary(item) |
| 177 | for item in data], False) |
| 178 | elif isinstance(data, dict): |
| 179 | return functools.reduce( |
| 180 | lambda a, b: a or b, [cls.data_is_binary(item) |
| 181 | for item in data.values()], |
| 182 | False) |
| 183 | else: |
| 184 | return False |
| 185 | |
| 186 | def _to_dict(self): |
| 187 | d = { |
no outgoing calls