HEX
Server: Apache
System: Linux sg241.singhost.net 2.6.32-896.16.1.lve1.4.51.el6.x86_64 #1 SMP Wed Jan 17 13:19:23 EST 2018 x86_64
User: honghock (909)
PHP: 8.0.30
Disabled: passthru,system,shell_exec,show_source,exec,popen,proc_open
Upload Files
File: //usr/lib/python2.7/site-packages/salt/output/pprint_out.py
# -*- coding: utf-8 -*-
'''
Python pretty-print (pprint)
============================

The python pretty-print system was once the default outputter. It simply
passes the return data through to ``pprint.pformat`` and prints the results.

CLI Example:

.. code-block:: bash

    salt '*' foo.bar --out=pprint

Example output:

.. code-block:: python

    {'saltmine': {'foo': {'bar': 'baz',
                          'dictionary': {'abc': 123, 'def': 456},
                          'list': ['Hello', 'World']}}}
'''
from __future__ import absolute_import, print_function, unicode_literals

# Import python libs
import pprint

# Import 3rd-party libs
from salt.ext import six

# Define the module's virtual name
__virtualname__ = 'pprint'


def __virtual__():
    '''
    Change the name to pprint
    '''
    return __virtualname__


def output(data, **kwargs):  # pylint: disable=unused-argument
    '''
    Print out via pretty print
    '''
    if isinstance(data, Exception):
        data = six.text_type(data)
    if 'output_indent' in __opts__ and __opts__['output_indent'] >= 0:
        return pprint.pformat(data, indent=__opts__['output_indent'])
    return pprint.pformat(data)