mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00

This commit introduces salt.utils.msgpack modifies all places in the code that either use json or msgpack to use salt.utils.json or salt.utils.msgpack respectively. While this change itself does not have any effect, it is important to allow for centrally dealing with objects that cannot be directly serialied via json or msgpack.
29 lines
622 B
Python
29 lines
622 B
Python
# -*- coding: utf-8 -*-
|
|
'''
|
|
Simple script to dump the contents of msgpack files to the terminal
|
|
'''
|
|
# pylint: disable=resource-leakage
|
|
# Import python libs
|
|
from __future__ import absolute_import, print_function
|
|
import os
|
|
import sys
|
|
import pprint
|
|
|
|
# Import Salt libs
|
|
import salt.utils.msgpack
|
|
|
|
|
|
def dump(path):
|
|
'''
|
|
Read in a path and dump the contents to the screen
|
|
'''
|
|
if not os.path.isfile(path):
|
|
print('Not a file')
|
|
return
|
|
with open(path, 'rb') as fp_:
|
|
data = salt.utils.msgpack.loads(fp_.read())
|
|
pprint.pprint(data)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
dump(sys.argv[1])
|