%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/utils/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/utils/dicttrim.pyc

�
���^c@@sYddlmZmZmZddlZddlZd�Zdddeed�Z	dS(i(tabsolute_importtprint_functiontunicode_literalsNcC@sex^|D]V}t||t�r7t||||�qtj||�|kr|||<qqWdS(u�
    Takes a dictionary, max_val_size and replace_with
    and recursively loops through and replaces any values
    that are greater than max_val_size.
    N(t
isinstancetdictt_trim_dict_in_dicttsyst	getsizeof(tdatatmax_val_sizetreplace_withtkey((s7/usr/lib/python2.7/site-packages/salt/utils/dicttrim.pyR	s


gI@i
u
VALUE_TRIMMEDc
C@stjjidd6�}|r1tj|�}ntj|j|��}||kr�|r�|ry|j|dd�}q�|j|�}nx7tr�t|�}t||d�}	y�x^|D]V}
t	||
t
�r�t||
|	|�q�tj||
�|	kr�|||
<q�q�W||}t||d�}	|rT|j|dt�}n|j|�}tj|�}||kr�|r�|S|Sn|	dkr�|r�|S|SnWq�tk
r�q�Xq�W|r�|r�|j|dt�S|j|�Sq�|Sn|SdS(	u�
    Takes a dictionary and iterates over its keys, looking for
    large values and replacing them with a trimmed string.

    If after the first pass over dictionary keys, the dictionary
    is not sufficiently small, the stepper_size will be increased
    and the dictionary will be rescanned. This allows for progressive
    scanning, removing large items first and only making additional
    passes for smaller items if necessary.

    This function uses msgpack to calculate the size of the dictionary
    in question. While this might seem like unnecessary overhead, a
    data structure in python must be serialized in order for sys.getsizeof()
    to accurately return the items referenced in the structure.

    Ex:
    >>> salt.utils.trim_dict({'a': 'b', 'c': 'x' * 10000}, 100)
    {'a': 'b', 'c': 'VALUE_TRIMMED'}

    To improve performance, it is adviseable to pass in msgpacked
    data structures instead of raw dictionaries. If a msgpack
    structure is passed in, it will not be unserialized unless
    necessary.

    If a msgpack is passed in, it will be repacked if necessary
    before being returned.

    :param use_bin_type: Set this to true if "is_msgpacked=True"
                         and the msgpack data has been encoded
                         with "use_bin_type=True". This also means
                         that the msgpack data should be decoded with
                         "encoding='utf-8'".
    umsgpackuserialtencodinguutf-8idtuse_bin_typeiN(
tsalttpayloadtSerialRRtdumpstloadstTruetfloatRRRt
ValueError(
Rtmax_dict_bytestpercenttstepper_sizeR
tis_msgpackedR
t
serializert	dict_sizeR	Rt	dump_datat
cur_dict_size((s7/usr/lib/python2.7/site-packages/salt/utils/dicttrim.pyt	trim_dictsT)	




(
t
__future__RRRRtsalt.payloadRRtFalseR(((s7/usr/lib/python2.7/site-packages/salt/utils/dicttrim.pyt<module>s	

Zerion Mini Shell 1.0