| Conditions | 3 |
| Total Lines | 15 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import json |
||
| 8 | def load(response: flask.Response) -> (int, Union[dict, str]): |
||
| 9 | """Convert a response's binary data (JSON) to a dictionary.""" |
||
| 10 | text = response.data.decode('utf-8') |
||
| 11 | |||
| 12 | if text: |
||
| 13 | try: |
||
| 14 | data = json.loads(text) |
||
| 15 | except json.decoder.JSONDecodeError: |
||
| 16 | data = text |
||
| 17 | else: |
||
| 18 | data = None |
||
| 19 | |||
| 20 | log.debug("Response: %r", data) |
||
| 21 | |||
| 22 | return response.status_code, data |
||
| 23 |