%PDF- %PDF-
Direktori : /lib/python2.7/site-packages/salt/utils/ |
Current File : //lib/python2.7/site-packages/salt/utils/json.pyc |
� ���^c @@ s� d Z d d l m Z m Z d d l Z d d l Z d d l Z d d l Z d d l m Z e j e � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z d S( u Functions to work with JSON i ( t absolute_importt unicode_literalsN( t sixc C@ s | j � S( u� Performs a splitlines on the string. This function exists to make mocking possible in unit tests, since the member functions of the str/unicode builtins cannot be mocked. ( t splitlines( t raw( ( s3 /usr/lib/python2.7/site-packages/salt/utils/json.pyt __split s c C@ s� i } t | � } x� t | � D]� \ } } y d j | | � } Wn3 t k rw d j t j j j | | � � } n Xy t j | � } Wn t k r� q n X| r | Sq W| s� t � n d S( u� Pass in a raw string and load the json when it starts. This allows for a string to start with garbage and end with json but be cleanly loaded u N( R t enumeratet joint UnicodeDecodeErrort saltt utilst datat decodet jsont loadst ValueError( R t rett linest indt _t working( ( s3 /usr/lib/python2.7/site-packages/salt/utils/json.pyt find_json s & c C@ sP xI d D]A } y$ t | � } t j d | � | SWq t k rG q q Xq Wd S( uU Import a json module, starting with the quick ones and going down the list) u ujsonu yajlu jsonu loaded %s json libN( u ujsonu yajlu json( t __import__t logt tracet ImportError( t fast_jsont mod( ( s3 /usr/lib/python2.7/site-packages/salt/utils/json.pyt import_json7 s c K@ s | j d t � j | | � S( u� .. versionadded:: 2018.3.0 Wraps json.load You can pass an alternate json module (loaded via import_json() above) using the _json_module argument) u _json_module( t popR t load( t fpt kwargs( ( s3 /usr/lib/python2.7/site-packages/salt/utils/json.pyR D s c K@ s} | j d t � } y | j | | � SWnP t k rx } t j ro t | t � ro | j t j j j | � | � S| � n Xd S( u) .. versionadded:: 2018.3.0 Wraps json.loads and prevents a traceback in the event that a bytestring is passed to the function. (Python < 3.6 cannot load bytestrings) You can pass an alternate json module (loaded via import_json() above) using the _json_module argument) u _json_moduleN( R R R t TypeErrorR t PY3t isinstancet bytesR R t stringutilst to_unicode( t sR t json_modulet exc( ( s3 /usr/lib/python2.7/site-packages/salt/utils/json.pyR P s c K@ s_ | j d t � } d | k r+ t | d <n t j rL t j j j | � } n | j | | | � S( u .. versionadded:: 2018.3.0 Wraps json.dump, and assumes that ensure_ascii is False (unless explicitly passed as True) for unicode compatibility. Note that setting it to True will mess up any unicode characters, as they will be dumped as the string literal version of the unicode code point. On Python 2, encodes the result to a str since json.dump does not want unicode types. You can pass an alternate json module (loaded via import_json() above) using the _json_module argument) u _json_moduleu ensure_ascii( R R t FalseR t PY2R R R t encodet dump( t objR R R( ( ( s3 /usr/lib/python2.7/site-packages/salt/utils/json.pyR- e s c K@ sh d d l } | j d t � } d | k r7 t | d <n t j rX t j j j | � } n | j | | � S( u .. versionadded:: 2018.3.0 Wraps json.dumps, and assumes that ensure_ascii is False (unless explicitly passed as True) for unicode compatibility. Note that setting it to True will mess up any unicode characters, as they will be dumped as the string literal version of the unicode code point. On Python 2, encodes the result to a str since json.dumps does not want unicode types. You can pass an alternate json module (loaded via import_json() above) using the _json_module argument) i Nu _json_moduleu ensure_ascii( t sysR R R* R R+ R R R R, t dumps( R. R R/ R( ( ( s3 /usr/lib/python2.7/site-packages/salt/utils/json.pyR0 | s ( t __doc__t __future__R R R t loggingt salt.utils.dataR t salt.utils.stringutilst salt.extR t getLoggert __name__R R R R R R R- R0 ( ( ( s3 /usr/lib/python2.7/site-packages/salt/utils/json.pyt <module> s