Add modular output directory

This commit is contained in:
Thomas S Hatch 2012-10-24 12:45:57 -06:00
parent 8c01f7e566
commit 90f234578a
2 changed files with 35 additions and 0 deletions

17
salt/output/__init__.py Normal file
View File

@ -0,0 +1,17 @@
'''
Used to manage the outputter system. This package is the modular system used
for managing outputters.
'''
import salt.loader
def display_output(data, out, opts=None):
'''
Print the passed data using the desired output
'''
if opts is None:
opts = {}
outputters = salt.loader.outputters(opts)
if not out in outputters:
outputters['pprint'](data)
outputters[out](data)

18
salt/output/pprint_out.py Normal file
View File

@ -0,0 +1,18 @@
'''
The default outputter, just fall back to python pretty print
'''
# Import python libs
import pprint
def __virtual__():
'''
Change the name to pprint
'''
return 'pprint'
def output(data):
'''
Print out via pretty print
'''
pprint.pprint(data)