1
0

packdump.py 622 B

1234567891011121314151617181920212223242526272829
  1. # -*- coding: utf-8 -*-
  2. '''
  3. Simple script to dump the contents of msgpack files to the terminal
  4. '''
  5. # pylint: disable=resource-leakage
  6. # Import python libs
  7. from __future__ import absolute_import, print_function
  8. import os
  9. import sys
  10. import pprint
  11. # Import Salt libs
  12. import salt.utils.msgpack
  13. def dump(path):
  14. '''
  15. Read in a path and dump the contents to the screen
  16. '''
  17. if not os.path.isfile(path):
  18. print('Not a file')
  19. return
  20. with open(path, 'rb') as fp_:
  21. data = salt.utils.msgpack.loads(fp_.read())
  22. pprint.pprint(data)
  23. if __name__ == '__main__':
  24. dump(sys.argv[1])