salt/tests/packdump.py

30 lines
607 B
Python
Raw Normal View History

# -*- coding: utf-8 -*-
'''
Simple script to dump the contents of msgpack files to the terminal
'''
2017-04-04 12:11:54 +00:00
# pylint: disable=resource-leakage
# Import python libs
2014-11-24 03:03:48 +00:00
from __future__ import absolute_import, print_function
import os
import sys
import pprint
# Import third party libs
import msgpack
def dump(path):
'''
Read in a path and dump the contents to the screen
'''
if not os.path.isfile(path):
2014-11-24 03:03:48 +00:00
print('Not a file')
return
with open(path, 'rb') as fp_:
data = msgpack.loads(fp_.read())
pprint.pprint(data)
if __name__ == '__main__':
dump(sys.argv[1])