(doc: Any, json_options: JSONOptions)
| 571 | |
| 572 | |
| 573 | def _parse_legacy_binary(doc: Any, json_options: JSONOptions) -> Union[Binary, uuid.UUID]: |
| 574 | if isinstance(doc["$type"], int): |
| 575 | doc["$type"] = "%02x" % doc["$type"] |
| 576 | subtype = int(doc["$type"], 16) |
| 577 | if subtype >= 0xFFFFFF80: # Handle mongoexport values |
| 578 | subtype = int(doc["$type"][6:], 16) |
| 579 | data = base64.b64decode(doc["$binary"].encode()) |
| 580 | return _binary_or_uuid(data, subtype, json_options) |
| 581 | |
| 582 | |
| 583 | def _parse_canonical_binary(doc: Any, json_options: JSONOptions) -> Union[Binary, uuid.UUID]: |
no test coverage detected