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

Function _elements_to_dict

bson/__init__.py:598–618  ·  view source on GitHub ↗

Decode a BSON document into result.

(
    data: Any,
    view: Any,
    position: int,
    obj_end: int,
    opts: CodecOptions[Any],
    result: Any = None,
    raw_array: bool = False,
)

Source from the content-addressed store, hash-verified

596
597
598def _elements_to_dict(
599 data: Any,
600 view: Any,
601 position: int,
602 obj_end: int,
603 opts: CodecOptions[Any],
604 result: Any = None,
605 raw_array: bool = False,
606) -> Any:
607 """Decode a BSON document into result."""
608 if result is None:
609 result = opts.document_class()
610 end = obj_end - 1
611 while position < end:
612 key, value, position = _element_to_dict(
613 data, view, position, obj_end, opts, raw_array=raw_array
614 )
615 result[key] = value
616 if position != obj_end:
617 raise InvalidBSON("bad object or element length")
618 return result
619
620
621def _bson_to_dict(data: Any, opts: CodecOptions[_DocumentType]) -> _DocumentType:

Callers 4

_get_objectFunction · 0.85
_raw_to_dictFunction · 0.85
_bson_to_dictFunction · 0.85
_decode_allFunction · 0.85

Calls 2

InvalidBSONClass · 0.90
_element_to_dictFunction · 0.85

Tested by

no test coverage detected