2024-11-25 20:46:35 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
2024-12-06 08:50:49 +00:00
|
|
|
"""
|
2024-11-26 16:58:47 +00:00
|
|
|
This utility reads a knowledge core in msgpack format and outputs its
|
|
|
|
|
contents in JSON form to standard output. This is useful only as a
|
|
|
|
|
diagnostic utility.
|
|
|
|
|
"""
|
|
|
|
|
|
2024-11-25 20:46:35 +00:00
|
|
|
import msgpack
|
|
|
|
|
import sys
|
|
|
|
|
import argparse
|
|
|
|
|
|
|
|
|
|
def run(input_file):
|
|
|
|
|
|
|
|
|
|
with open(input_file, 'rb') as f:
|
|
|
|
|
|
|
|
|
|
unpacker = msgpack.Unpacker(f, raw=False)
|
|
|
|
|
|
|
|
|
|
for unpacked in unpacker:
|
|
|
|
|
print(unpacked)
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(
|
2024-11-26 16:58:47 +00:00
|
|
|
prog='tg-dump-msgpack',
|
2024-11-25 20:46:35 +00:00
|
|
|
description=__doc__,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
parser.add_argument(
|
|
|
|
|
'-i', '--input-file',
|
|
|
|
|
required=True,
|
|
|
|
|
help=f'Input file'
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
|
|
run(**vars(args))
|
|
|
|
|
|
|
|
|
|
main()
|
|
|
|
|
|