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

Method from_msgpack

box/box.py:1548–1570  ·  view source on GitHub ↗

Transforms msgpack bytes or file into a Box object :param msgpack_bytes: string to pass to `msgpack.unpackb` :param filename: filename to open and pass to `msgpack.unpack` :param kwargs: parameters to pass to `Box()` :return: Box object

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

Source from the content-addressed store, hash-verified

1546
1547 @classmethod
1548 def from_msgpack(
1549 cls,
1550 msgpack_bytes: bytes | None = None,
1551 filename: str | PathLike | None = None,
1552 **kwargs,
1553 ) -> Box:
1554 """
1555 Transforms msgpack bytes or file into a Box object
1556
1557 :param msgpack_bytes: string to pass to `msgpack.unpackb`
1558 :param filename: filename to open and pass to `msgpack.unpack`
1559 :param kwargs: parameters to pass to `Box()`
1560 :return: Box object
1561 """
1562 box_args = {}
1563 for arg in kwargs.copy():
1564 if arg in BOX_PARAMETERS:
1565 box_args[arg] = kwargs.pop(arg)
1566
1567 data = _from_msgpack(msgpack_bytes=msgpack_bytes, filename=filename, **kwargs)
1568 if not isinstance(data, dict):
1569 raise BoxError(f"msgpack data not returned as a dictionary but rather a {type(data).__name__}")
1570 return cls(data, **box_args)
1571
1572 else:
1573

Calls 4

_from_msgpackFunction · 0.90
BoxErrorClass · 0.90
copyMethod · 0.80
popMethod · 0.45