MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / _parse_legacy_binary

Function _parse_legacy_binary

bson/json_util.py:573–580  ·  view source on GitHub ↗
(doc: Any, json_options: JSONOptions)

Source from the content-addressed store, hash-verified

571
572
573def _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
583def _parse_canonical_binary(doc: Any, json_options: JSONOptions) -> Union[Binary, uuid.UUID]:

Callers 1

_parse_binaryFunction · 0.85

Calls 2

_binary_or_uuidFunction · 0.85
encodeMethod · 0.80

Tested by

no test coverage detected