Sh3ll
OdayForums


Server : LiteSpeed
System : Linux premium84.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
User : claqxcrl ( 523)
PHP Version : 8.1.32
Disable Function : NONE
Directory :  /opt/hc_python/lib64/python3.12/site-packages/dict2xml/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //opt/hc_python/lib64/python3.12/site-packages/dict2xml/__pycache__/logic.cpython-312.pyc
�

���gd'����ddlZddlZddlZdjd�dD��Zej
dj
e��Zej
d�ZGd�d�Z	Gd	�d
e
�ZGd�de
�Zy)
�N�|c#�>K�|]}dj|����y�w)z[{0}]N)�format)�.0�rs  �=/opt/hc_python/lib/python3.12/site-packages/dict2xml/logic.py�	<genexpr>r	s%��������N�N�1���s�)uÀ-ÖuØ-öuø-˿uͰ-ͽuͿ-῿u‌-‍u⁰-↏uⰀ-⿯u、-퟿u豈-﷏uﷰ-�z(:|[A-Z]|_|[a-z]|{0})z2(\-|\.|[0-9]|\xB7|[\u0300-\u036F]|[\u203F-\u2040])c�>�eZdZdZd�ZGd�d�ZGd�d�Zy)�
DataSorterz;
    Used to sort a map of data depending on it's type
    c�T�|}t|tj�st|�}|S�N)�
isinstance�collections�OrderedDict�sorted)�self�data�sorted_datas   r�	keys_fromzDataSorter.keys_from#s&�����$�� 7� 7�8� ��,�K���c��eZdZd�Zy)�DataSorter.alwaysc��t|�Sr
)r�rrs  rrzDataSorter.always.keys_from*s���$�<�rN��__name__�
__module__�__qualname__r�rr�alwaysr)s��	 rr c��eZdZd�Zy)�DataSorter.neverc��|Sr
rrs  rrzDataSorter.never.keys_from.s���KrNrrrr�neverr"-s��	rr$N)rrr�__doc__rr r$rrrrrs ���� � ��rrc�N�eZdZdZgd�Z						d	d�Zd�Zd�Zd�Ze	d��Z
y)
�Nodea�
    Represents each tag in the tree

    Each node has _either_ a single value or one or more children
    If it has a value:
        The serialized result is <%(tag)s>%(value)s</%(tag)s>

    If it has children:
        The serialized result is
            <%(wrap)s>
                %(children)s
            </%(wrap)s>

    Which one it is depends on the implementation of self.convert
    ))�&z&amp;)�<z&lt;)�>z&gt;Nc��|j|�|_|j|�|_||_|j	�|_|�|n	t
�|_||_||_	|j
dk(rQt|jt�r6|jD]&\}}|jj||�|_�(yyy)N�flat)�sanitize_element�tag�wrapr�determine_type�typer�data_sorter�closed_tags_for�iterables_repeat_wrapr�str�entities�replace)	rr/r.rr4r3r2�entity�replacements	         r�__init__z
Node.__init__Fs����(�(��-����)�)�$�/��	���	��'�'�)��	�*5�*A�;�z�|���.���%:��"��9�9���:�d�i�i��#=�'+�}�}�#��� �I�I�-�-�f�k�B��	�(5�$>�rc�
��|j}d\}}|r"dj|�}dj|�}|jr3|j|jvrdj|j�S|j	�\}}d}|r�|j
dk7r��fd�|D�|�}n�|jrqg}|D]a}	|	j��}|	j
dk(r|j|��5�|gd	�}|jdj|||f���c�|d
�Sg}|D]"}	|j|	j����$dj|�|d	�|g�Sdj||||f�S)z,Returns the Node serialized as an xml string)�r<z</{0}>z<{0}>z<{0}/>r<�iterablec3�@�K�|]}|j�����y�wr
)�	serialize)r�c�indenters  �rr	z!Node.serialize.<locals>.<genexpr>ps�����#L�8�a�A�K�K��$9�8�s�r,TF)
r/rr3r�convertr1r4r?�append�join)
rrAr/�end�start�value�children�content�resultr@s
 `        rr?zNode.serialize\sp����y�y���
��U���/�/�$�'�C��N�N�4�(�E����D�I�I��1E�1E�$E��?�?�4�9�9�-�-��,�,�.���x�����y�y�J�&�"�#L�8�#L�d�S���-�-��F�%��"#�+�+�h�"7���6�6�V�+�"�M�M�'�2�'/��y�$�&?�G�"�M�M�"�'�'�5�'�3�2G�*H�I�&�$�F�E�2�2��F�%���
�
�a�k�k�(�&;�<�&��7�7�E�8�F�D�+A�3�#G�H�H�
�w�w��u�g�s�3�4�4rc���|j}t|t�ryt|tjj
�ryt|tjj�ryy)a
        Return the type of the data on this node as an identifying string

        * Iterable : Supports "for item in data"
        * Mapping : Supports "for key in data: value = data[key]"
        * flat : A string or something that isn't iterable or a mapping
        r,�mappingr=)rrr5r�abc�Mapping�Iterablers  rr0zNode.determine_type�sK���y�y���d�C� ��
��k�o�o�5�5�
6��
��k�o�o�6�6�
7��rc�J�d}|j}|j}g}|dk(ri|jj|�}|D]E}||}|j	t|d||j|j|j����G||fS|dk(rS|D]J}|j	td|j||j|j|j����L||fSt|�}|jr'dj|j||j�}||fS)a�
        Convert data on this node into a (value, children) tuple depending on the type of the data
        If the type is :
            * flat : Use self.tag to surround the value. <tag>value</tag>
            * mapping : Return a list of tags where the key for each child is the wrap for that node
            * iterable : Return a list of Nodes where self.wrap is the tag for that node
        r<rL)r4r3r2r=z<{0}>{1}</{2}>)r1rr2rrCr'r4r3r/r5r.r)r�val�typrrH�sorted_keys�key�items        rrBzNode.convert�s)�����i�i���y�y�����)���*�*�4�4�T�:�K�"���C�y���������.2�.H�.H�(,�(<�(<�$(�$4�$4�
�	�#�>�H�}��%�J�
���������	�	��.2�.H�.H�(,�(<�(<�$(�$4�$4�
�	��"�H�}��	�d�)�C��x�x�&�-�-�d�h�h��T�X�X�F���H�}�rc	�H�|r�t|t�r�|j�jd�rd|z}dj	t
j
|�sdndg|D�cgc]0}t
j
|�stj
|�sdn|��2c}z�S|Scc}w)a�
        Convert `wrap` into a valid tag name applying the XML Naming Rules.

            * Names can contain letters, numbers, and other characters
            * Names cannot start with a number or punctuation character
            * Names cannot start with the letters xml (or XML, or Xml, etc)
            * Names cannot contain spaces
            * Any name can be used, no words are reserved.

        :ref: http://www.w3.org/TR/REC-xml/#NT-NameChar
        �xml�_r<)rr5�lower�
startswithrD�
NameStartChar�match�NameChar)r/r@s  rr-zNode.sanitize_element�s����J�t�S�)��z�z�|�&�&�u�-��T�z���7�7�)�/�/��5��2�>�\`�a�\`�WX�}�2�2�1�5�����9J�3�QR�R�\`�a�b��
�
�K��bs�5B
)r<r<NTNN)rrrr%r6r:r?r0rB�staticmethodr-rrrr'r'2sM���">�H���
�"���C�,.5�`�$/�b���rr'c�&�eZdZdZdd�Zd�Zdd�Zy)�	ConverterzFLogic for creating a Node tree and serialising that tree into a stringNc�.�||_||_||_y)aI
        wrap: The tag that the everything else will be contained within
        indent: The string that is multiplied at the start of each new line, to represent each level of nesting
        newlines: A boolean specifying whether we want each tag on a new line.

        Note that indent only works if newlines is True
        N)r/�indent�newlines)rr/rbrcs    rr:zConverter.__init__�s����	���� ��
rc�b���|j�|j}|sd�}|S�sd�d����fd�}|S)zdReturns a function that given a list of strings, will return that list as a single, indented, stringc�$�dj|�S)Nr<)rD)�nodes�wrappeds  r�<lambda>z*Converter._make_indenter.<locals>.<lambda>s������rr<c3�NK�|D]}|jd�D]}|����y�w)zYield each line in each node�
N)�split)rf�node�lines   r�eachlinez*Converter._make_indenter.<locals>.eachlines(����!�D� $�
�
�4� 0��"�
�!1�"�s�#%c���|r#dj��}dj��}nd}d}|j|j�|���S)a"
                Indent nodes depending on value of wrapped and indent
                If not wrapped, then don't indent
                Otherwise,
                    Seperate each child by a newline
                    and indent each line in the child by one indent unit
                z
{0}z

{0}{{0}}
rjz{0})rrD)rfrg�	seperator�surroundingrnrbs    ��r�retz%Converter._make_indenter.<locals>.ret
sN���� '���v� 6�I�"0�"7�"7��"?�K� $�I�"'�K�"�)�)�)�.�.��%��*I�J�Jr)rbrc)rrcrrrnrbs   @@r�_make_indenterzConverter._make_indenter�s@��������=�=���7�C�6�
�3���
#�
K� �
rc�t�|j�}t|j||||��j|�S)zICreate a Node tree from the data and return it as a serialized xml string)r/rr4r3r2)rsr'r/r?)rrr4r3r2rAs      r�buildzConverter.builds<���&�&�(�������"7�+�#�
��)�H�
�
	r)Nz  T)TNN)rrrr%r:rsrurrrr`r`�s��P�
!�"�H	rr`)
r�collections.abc�rerD�start_ranges�compilerr[r]r�objectr'r`rrr�<module>r{s����	��x�x������"��
�
�3�:�:�<�H�I�
��2�:�:�K�L����(r�6�r�t<��<r

ZeroDay Forums Mini