PK APOCALYPSE V1

APOCALYPSE V1

Current Path : /opt/hc_python/lib/python3.12/site-packages/pyone/__pycache__/
Upload File :
Current File : //opt/hc_python/lib/python3.12/site-packages/pyone/__pycache__/util.cpython-312.pyc

�

���g����ddlZddlZddlmZddlmZddlmZgej_	dgZ
d�Zd�Zd�Z
d	�Zd
�Zd�Zd�ZGd
�de�Zy)�N)�tostring)�OrderedDict)�IntEnum�SNAPSHOTc��t|t�r|D�cgc]
}t|���c}St|t�r-|j	�D��cic]\}}|t|���c}}Sdt|��d�Scc}wcc}}w)zV
    recursively traverse nested dict and add xml
    CDATA element to the leaves
    z	<![CDATA[z]]>)�
isinstance�list�	add_cdata�dict�items�str)�d�x�k�vs    �9/opt/hc_python/lib/python3.12/site-packages/pyone/util.pyr
r
sw���!�T��'(�*�q�!��1��q�*�*�	�A�t�	�./�g�g�i�8�i�U�a���I�a�L��i�8�8��3�q�6�(�#�&�&��
+��9s�A6�
A;c��d�}t|t�r|jSt|t�r�t	|d�r|j
}t
|�rkt|j��d}||�r!tjt|�dd��Sd}|j�D]\}}|�|�d|�d�}�|Std	��|S)
ae
    This function will cast parameters to make them nebula friendly
    flat dictionaries will be turned into attribute=value vectors
    dictionaries with root dictionary will be serialized as XML
    Structures will be turned into strings before being submitted.

    :param param: the parameter to make nebula friendly
    :return: casted parameter
    c�R�|j�D]}t|t�s�yy)NTF)�valuesrr)�
dictionary�vals  r�is_nested_dictz cast2one.<locals>.is_nested_dict8s'���$�$�&�C��#�t�$��'���_rootr�F)�indent�newlinesz="z"
zCannot cast empty dictionary)
rr�valuer�hasattrr�boolr	r�dict2xmlr
r�	Exception)�paramr�root�retrrs      r�cast2oner&-s�����%��!��{�{���%����5�'�"��K�K�E���;������'��*�D��e�$��(�(��5�)9�/1�E�C�C���#�k�k�m�F�Q��03�Q��:�C�,��
��:�;�;��rc��|jS)aW
    This function returns a dictionary from an anyType binding element
    The dictionary can then be used later as imput for an udpate
    This is now deprecated, included for backward compatibility.

    :param element: anyType element to be converted such as TEMLATE or USER_TEMPLATE
    :return: a dictionary representing the element
    )r)�elements r�one2dictr)Ys���=�=�rc��|j�D].\}}t|�tk(rt|��$|dk(s�*d||<�0y)Nr)r�typer�
none2emptystr)rrrs   rr,r,fs:���w�w�y���!���7�k�!��!��
�$�Y��A�a�D�	rc��|dk(rEt|dd�r5|d}tD]&}||vs�t||�tk7s�||g||<�(yyy)N�TEMPLATE�__iter__)r�TEMPLATE_ALWAYS_LIST_ELEMr+r	)r�tag�tmpl�elems    r�fix_dictr4ns[��
�j��W�Q�z�]�J�?���}��.�D��t�|��T�$�Z� 0�D� 8�#�D�z�^��T�
�.�	@�rc��t|�}tj|d��}t||j�d|jvr%|jjd�d}||d=n|j}||dk(r
t
�||<t|�t||t�s$t||t�rt
||�||<|||_
||S)zv
    Creates a dictionary from the documentTree obtained from a binding Element.
    :param element:
    :return:
    F)�strip_whitespace�}�z@xmlnsN)r�	xmltodict�parser4r1�splitrr,rrr)r(�xmlr%�tagNames    r�
child2dictr>xs����7�
�C�
�/�/�#��
6�C�
�S�'�+�+���g�k�k���+�+�#�#�C�(��+����L��"��+�+���7�|�t��"�}��G���#���c�'�l�K�0�Z��G��d�5S�"�3�w�<�0��G���C��L���w�<�rc�\�|dk(rt|�|_y|dk(rt|�|_yy)z�
    Utility function to build an anyType element that can be accessed as a dictionary
    :param obj:
    :param nodeName:
    :param child:
    :return:
    r.T�
USER_TEMPLATEF)r>r.r@)�obj�nodeName�childs   r�build_template_noderD�s6���:��!�%�(����	�_�	$�&�u�-����rc�*��eZdZdZd�Zd�fd�	Z�xZS)�
TemplatedTypez,
    Mixin class for Templated bindings
    c�2�t|�t|�d<y)N�custom_attrs)r�vars)�self�node�attrs�already_processeds    r�_buildAttributeszTemplatedType._buildAttributes�s��%)�%�[��T�
�>�"rc�P��t|||�stt|�|||||�yy)N)rD�superrF�_buildChildren)rJ�child_rK�	nodeName_�
fromsubclass_�gds_collector_�	__class__s      �rrQzTemplatedType._buildChildren�s,���"�4��F�;��-��5�f�T�)�M�Zh�i�<r)FN)�__name__�
__module__�__qualname__�__doc__rNrQ�
__classcell__)rVs@rrFrF�s����1�j�jrrF)r!r9�
lxml.etreer�collectionsr�enumr�Node�entitiesr0r
r&r)r,r4r>rD�objectrF�rr�<module>rcs_��"���#����
�
��'�L��
'� )�X
��,� �F�$	j�F�	jr

if you don't want to be vaporized in a nuclear explosion, i simply have to become nuclear myself… i am atomic