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

Method from_msgpack

box/box.py:1565–1587  ·  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

1563
1564 @classmethod
1565 def from_msgpack(
1566 cls,
1567 msgpack_bytes: bytes | None = None,
1568 filename: str | PathLike | None = None,
1569 **kwargs,
1570 ) -> Box:
1571 """
1572 Transforms msgpack bytes or file into a Box object
1573
1574 :param msgpack_bytes: string to pass to `msgpack.unpackb`
1575 :param filename: filename to open and pass to `msgpack.unpack`
1576 :param kwargs: parameters to pass to `Box()`
1577 :return: Box object
1578 """
1579 box_args = {}
1580 for arg in kwargs.copy():
1581 if arg in BOX_PARAMETERS:
1582 box_args[arg] = kwargs.pop(arg)
1583
1584 data = _from_msgpack(msgpack_bytes=msgpack_bytes, filename=filename, **kwargs)
1585 if not isinstance(data, dict):
1586 raise BoxError(f"msgpack data not returned as a dictionary but rather a {type(data).__name__}")
1587 return cls(data, **box_args)
1588
1589 else:
1590

Calls 4

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