PK œqhYî¶J‚ßFßF)nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/ $#$#$#

Dir : /proc/self/root/opt/saltstack/salt/lib/python3.10/site-packages/salt/serializers/
Server: Linux ngx353.inmotionhosting.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64
IP: 209.182.202.254
Choose File :

Url:
Dir : //proc/self/root/opt/saltstack/salt/lib/python3.10/site-packages/salt/serializers/python.py

"""
    salt.serializers.python
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~

    .. versionadded:: 2016.3.0

    Implements a Python serializer (via pprint.format)
"""

import pprint

import salt.utils.json

try:
    import simplejson as _json
except ImportError:
    import json as _json  # pylint: disable=blacklisted-import


__all__ = ["serialize", "available"]

available = True


def serialize(obj, **options):
    """
    Serialize Python data to a Python string representation (via pprint.format)

    :param obj: the data structure to serialize
    :param options: options given to pprint.format
    """

    # round-trip this through JSON to avoid OrderedDict types
    # there's probably a more performant way to do this...
    # TODO remove json round-trip when all dataset will use
    # serializers
    return pprint.pformat(
        salt.utils.json.loads(
            salt.utils.json.dumps(obj, _json_module=_json), _json_module=_json
        ),
        **options
    )