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/renderers/msgpack.py
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals

# Import salt libs
import salt.utils.msgpack
from salt.ext import six


def render(msgpack_data, saltenv='base', sls='', **kws):
    '''
    Accepts a message pack string or a file object, renders said data back to
    a python dict.

    .. note:
        This renderer is NOT intended for use in creating sls files by hand,
        but exists to allow for data backends to serialize the highdata
        structure in an easily transportable way. This is to allow for more
        fluid fileserver backends that rely on pure data sources.

    :rtype: A Python data structure
    '''
    if not isinstance(msgpack_data, six.string_types):
        msgpack_data = msgpack_data.read()

    if msgpack_data.startswith('#!'):
        msgpack_data = msgpack_data[(msgpack_data.find('\n') + 1):]
    if not msgpack_data.strip():
        return {}
    return salt.utils.msgpack.loads(msgpack_data)