Skip to content

Commit

Permalink
[loaders] msgpack #2419
Browse files Browse the repository at this point in the history
  • Loading branch information
saulpw committed Jun 9, 2024
1 parent c01c2b5 commit 321b4bf
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions visidata/loaders/msgpack.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from visidata import vd, VisiData, JsonSheet


@VisiData.api
def open_msgpack(vd, p):
return MsgpackSheet(p.name, source=p)


VisiData.open_msgpackz = VisiData.open_msgpack


class MsgpackSheet(JsonSheet):
def iterload(self):
msgpack = vd.importModule('msgpack')
data = self.source.read_bytes()
if self.source.suffix == '.msgpackz':

This comment has been minimized.

Copy link
@saulpw

saulpw Jun 10, 2024

Author Owner

This should actually check self.options.filetype instead of the source path suffix (so that it works from stdin also).

This comment has been minimized.

Copy link
@maxim-uvarov

maxim-uvarov Jun 10, 2024

Contributor

@saulpw Yes, Saul, I wanted to ask you to make it work with stdin as I need this format for more efficient interaction with nushell.

brotli = vd.importModule('brotli')
data = brotli.decompress(data)
yield from msgpack.unpackb(data, raw=False)

0 comments on commit 321b4bf

Please sign in to comment.