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

Method from_msgpack

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

436
437 @classmethod
438 def from_msgpack(cls, msgpack_bytes: bytes | None = None, filename: str | PathLike | None = None, **kwargs):
439 """
440 Transforms a toml string or file into a BoxList object
441
442 :param msgpack_bytes: string to pass to `msgpack.packb`
443 :param filename: filename to open and pass to `msgpack.pack`
444 :param kwargs: parameters to pass to `Box()`
445 :return:
446 """
447 box_args = {}
448 for arg in list(kwargs.keys()):
449 if arg in BOX_PARAMETERS:
450 box_args[arg] = kwargs.pop(arg)
451
452 data = _from_msgpack(msgpack_bytes=msgpack_bytes, filename=filename, **kwargs)
453 if not isinstance(data, list):
454 raise BoxError(f"msgpack data not returned as a list but rather a {type(data).__name__}")
455 return cls(data, **box_args)
456
457 else:
458

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected