MCPcopy Create free account
hub / github.com/cdgriffith/Box / from_msgpack

Method from_msgpack

box/box_list.py:722–739  ·  view source on GitHub ↗

Transforms a toml string or file into a BoxList object :param msgpack_bytes: string to pass to `msgpack.packb` :param filename: filename to open and pass to `msgpack.pack` :param kwargs: parameters to pass to `Box()` :return:

(cls, msgpack_bytes: bytes | None = None, filename: str | PathLike | None = None, **kwargs)

Source from the content-addressed store, hash-verified

720
721 @classmethod
722 def from_msgpack(cls, msgpack_bytes: bytes | None = None, filename: str | PathLike | None = None, **kwargs):
723 """
724 Transforms a toml string or file into a BoxList object
725
726 :param msgpack_bytes: string to pass to `msgpack.packb`
727 :param filename: filename to open and pass to `msgpack.pack`
728 :param kwargs: parameters to pass to `Box()`
729 :return:
730 """
731 box_args = {}
732 for arg in list(kwargs.keys()):
733 if arg in BOX_PARAMETERS:
734 box_args[arg] = kwargs.pop(arg)
735
736 data = _from_msgpack(msgpack_bytes=msgpack_bytes, filename=filename, **kwargs)
737 if not isinstance(data, list):
738 raise BoxError(f"msgpack data not returned as a list but rather a {type(data).__name__}")
739 return cls(data, **box_args)
740
741 else:
742

Callers

nothing calls this directly

Calls 4

_from_msgpackFunction · 0.90
BoxErrorClass · 0.90
keysMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected