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

Method from_msgpack

box/box_list.py:712–729  ·  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

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

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected