Exemple #1
0
 def test_to_msgpack(self):
     m_file = os.path.join(tmp_dir, "movie_data")
     msg_data = _to_msgpack(movie_data)
     assert b"Rick Moranis" in msg_data
     _to_msgpack(movie_data, filename=m_file)
     assert b"Rick Moranis" in open(m_file, "rb").read()
     assert msgpack.unpack(open(m_file, "rb")) == msgpack.unpackb(msg_data)
Exemple #2
0
        def to_msgpack(self, filename: Union[str, PathLike] = None, **kwargs):
            """
            Transform the BoxList object into a toml string.

            :param filename: File to write toml object too
            :return: string of TOML (if no filename provided)
            """
            return _to_msgpack(self.to_list(), filename=filename, **kwargs)
Exemple #3
0
        def to_msgpack(self, filename: Union[str, PathLike] = None, **kwargs):
            """
            Transform the Box object into a msgpack string.

            :param filename: File to write msgpack object too
            :param kwargs: parameters to pass to `msgpack.pack`
            :return: bytes of msgpack (if no filename provided)
            """
            return _to_msgpack(self.to_dict(), filename=filename, **kwargs)