%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/reportlab/lib/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/reportlab/lib/__pycache__/rparsexml.cpython-312.pyc

�

׸�e�G�	��dZdZ	dZddlZd�Zej
ddddedd��Zdddifd�ZGd�d	�Z	e	�Z	d
Z
dZdZdZ
ee
�ZdZgd
�Zd�Zddefd�ZereZd�ZdZd�Zddefd�Zd�Zdd�Zdd�Zedk(r�ed��ddlZddlZddlmZddlZe�Z dZ!ejDddD]jZ#ejHjKe#�s	e&d��'e'e#�5Z(e(jS�Z*ddd�e&de#�dee*����ee*d��e!dz
Z!�le!re&de�e z
d�d��yyy#e$rdZY��wxYw#1swY�VxYw) atVery simple and fast XML parser, used for intra-paragraph text.

Devised by Aaron Watters in the bad old days before Python had fast
parsers available.  Constructs the lightest possible in-memory
representation; parses most files we have seen in pure python very
quickly.

The output structure is the same as the one produced by pyRXP,
our validating C-based parser, which was written later.  It will
use pyRXP if available.

This is used to parse intra-paragraph markup.

Example parse::

    <this type="xml">text <b>in</b> xml</this>

    ( "this",
      {"type": "xml"},
      [ "text ",
        ("b", None, ["in"], None),
        " xml"
        ]
       None )

    { 0: "this"
      "type": "xml"
      1: ["text ",
          {0: "b", 1:["in"]},
          " xml"]
    }

Ie, xml tag translates to a tuple:
 (name, dictofattributes, contentlist, miscellaneousinfo)

where miscellaneousinfo can be anything, (but defaults to None)
(with the intention of adding, eg, line number information)

special cases: name of "" means "top level, no containing tag".
Top level parse always looks like this::

    ("", list, None, None)

 contained text of None means <simple_tag/>

In order to support stuff like::

    <this></this><one></one>

AT THE MOMENT &amp; ETCETERA ARE IGNORED. THEY MUST BE PROCESSED
IN A POST-PROCESSING STEP.

PROLOGUES ARE NOT UNDERSTOOD.  OTHER STUFF IS PROBABLY MISSING.
�Nc��t|�y)N)�print)�ss �9/usr/lib/python3/dist-packages/reportlab/lib/rparsexml.py�warnCBr>s	��
�a���zstring input)�ErrorOnValidityErrors�NoNoDTDWarning�ExpandCharacterEntities�ExpandGeneralEntitiesr�srcName�
ReturnUTF8c�b�|t_tj|fi|��}|xr|xsdd|gdfS)N�)�pyRXP_parser�eoCB�parse)�xmlText�oneOutermostTagr�entityReplacer�	parseOpts�ps      r�parsexmlrIs:�� ������w�3��3���$�1�:��D�!��T�(:�:rc��eZdZed��Zy)�smartDecodec�b��ddl��fd�}t|�tj_||�S)Nrc�r��t|t�r|S�j|�}|j|d�S)N�encoding)�
isinstance�str�detect�decode)r�cdd�chardets  �r�__call__z&smartDecode.__call__.<locals>.__call__Us2����!�C� ��(��.�.��#�C��8�8�C�
�O�,�,r)r%�staticmethodr�	__class__r&)rr&r%s  @rr&zsmartDecode.__call__Qs,���	�	-�
*6�h�)?����&����rN)�__name__�
__module__�__qualname__r'r&�rrrrPs���	��	rrr�	<![CDATA[z]]>))z&lt;�<)z&gt;�>)z&amp;�&c��g}|D]7}d|vr tD]\}}|j||�}�|j|��9|S)Nr0)�replacelist�replace�append)�contentList�result�e�old�news     r�unEscapeContentListr:fsS��
�F�
����!�8�)�
(�
��c��I�I�c�3�'��
(��
�
�a��	�
�Mrc�\�trtd��t||��\}}|r|ddS|S)z.official interface: discard unused cursor infoz)pyRXP not found, fallback parser disabled)r�r)�RequirePyRXP�ImportError�	parsexml0)�xmltextrrrr6�cursors      r�parsexmlSimplerBos8����E�F�F� ���G��V�V���a�y��|���
rc�L�t|d�j�}t|�S)N�r)�open�readr)�filename�raws  r�	parseFilerI|s!��
�x��
�
"�
"�
$�C��C�=�rc��d}d}|�r|jd|�}|dkr	|S|dz}d}|D]E}t|�}||||z|k(s�d}|jd|�}|dkrtd|z��|dz}�G|�d}|��r|S)zBskip any prologue found after cursor, return index of rest of text)z!DOCTYPEz?xmlz!--Nr.rr	r/zcan't close prologue %r)�find�len�
ValueError)	�textrA�prologue_elements�done�openbracket�past�foundr7�les	         r�
skip_prologuerU�s���4���D�
�,��i�i��V�,���q�=�%��M��1�}����"�	"�A��Q��B��D��b��!�1�$������3��-���!�8�$�%>��%B�C�C�����	"��=��D��,�"�Mrc��t|�}t}dx}x}}|�|j�}|}|jd|�}	||	dz|	dz}
d}|	dkr@|�!||dg}|r||�}||||ft	|�fStdt
|||dz�z��g}|�tx}}
t||�}�nU|	dkrtdt
|dd	�z��|
d
k(rj||	|	dzdk(r_|	dz}|jt|�}|dkrtd
t
|||dz�z��t}|||g}|t	t�z}d}�n�|
dk(rs||	|	dzdk(rh|jd|	dz�}||	krtdt
|||dz�z��|dz}||dk7rtdt
|||dz�z��d|dzfS|jd|	�}|dk}|dz}|	dz}|||}d|vr%|ddk(r|dd}d}|j�}
|
}|}�nd|vrpd}|s t	|dzjd��dzrd}|�H|jd|�}|dz}|dk}|||}|s t	|dzjd��dzrd}|��H|rtdt
||	|	dz�z��|}||dz
dk(r|dz
}|dd}d}|j�}|jd�}|d}|j�}|d}
|
}|d}|ddz|d<ix}}d}t	|�}||kr�||}|dz}|j�}|ddk7rtdt
|�z��d|ddvr5||kDrtdt
|�z��||} |dz}|�d| ��}d|ddvr�5|j�}|j�}!|!d}"|dt	|"�}#|#j�}#	|#d}$|#d}%|$|%cxk(rdk(sn|$|%cxk(rd k(rnn|#dd}#|#||<|"}||kr��|�|}|���|jd|�}&|&|krQ
tk(r(d}||d}'t	|�}|'�rj|j|'��nWtd!|
�d"t
|||dz�����||&dzdk(r�|jd|&�}(|(|&krtd#t
||&|&dz�z��||&dz|(})|)j�}*|*d}+
|+k7ry|d|},t	|,jd$��}-|d|},t	|,jd$��}.td%|.�d&|-�d't
|
��d&t
|+��d(t
|||d)z���
��|||&}'|'r|j|'�|(dz}d}n=|||&}'|'r|j|'�t||&d|�*�\}/}|/r|j|/�|����|r
|r||�}||||f}0|0|fS#tdt
|#||!f�z��xYw)+z�simple recursive descent xml parser...
       return (dictionary, endcharacter)
       special case: comment returns (None, endcharacter)Nr.r	�rzno tags at non-toplevel %s�z.non top level entry should be at start tag: %s�
z![�	r-zunclosed CDATA %sz!-�z<!--z--zunterminated comment %sr<r/z*invalid comment: contains double dashes %s�=����/�"�.zunclosed start tag %sz fz-attribute value must start with double quoteszunclosed value zattvalue,attentry,attlist=�'zno close bracket for z
 found after zunclosed close tag %s�
z	at lines z...z close tag name doesn't match � �d)�
startingat�toplevelr)
r�NONAME�striprKrLrM�reprrU�CDATAENDMARKER�CDATAMARKER�splitr4r?)1r@rerfr�
NameString�ContentList�AttDict�
ExtraStuffrA�firstbracket�afterbracket2char�
docontents�L�name�
startcdata�endcdata�endcommentdashes�
endcomment�closebracket�noclose�startsearch�pastfirstbracket�
tagcontent�stop�taglist�taglist0�taglist0list�
attributename�D�taglistindex�lasttaglistindex�attentry�nextattentry�attlist�nextattname�attvalue�first�last�nextopenbracket�	remainder�nextclosebracket�closetagcontents�closetaglist�	closename�prefix�
endlinenum�linenum�	parsetree�ts1                                                 rr?r?�s����'�"�G��J�)-�-�K�-�'�J����-�-�/��
�F��<�<��V�,�L���Q��|�A�~�>��
�J��A�~��#�&�v�w�/�0��!���1L�;�"�G�[�*�E�s�7�|�S�S� �!=��W�V�TZ�[]�T]�E^�@_�!_�`�`�
�A�
�� &�&�J��"�7�F�3�F�	�a���M�PT�U\�]`�^`�Ua�Pb�b�c�c�	�D�	 �W�\�,�q�.�%I�;�%V�&�a��J��|�|�N�J�?�H���z� �!4�t�G�F�6�RT�9�<U�7V�!V�W�W�$�J�"�:�x�8�9�K��c�.�1�1�F��J�	�D�	 �W�\�,�q�.�%I�6�%Q�&�|�|�D�,�q�.�A����,� �!:�T�'�&�QW�XZ�QZ�B[�=\�!\�]�]�)�!�+�J��z�"�C�'� �!M�PT�U\�]c�dj�km�dm�Un�Po�!o�p�p��*�Q�,�'�'�
#�<�<��\�:�L�"�1�n�G�&�q�.�K�+�A�~�� �!1�,�?�J��*�$��b�>�3�&�",�C�R��J�!%�J�!�'�'�)��!�
�$���*�$��D��#�z�#�~�&<�&<�S�&A�"B�A�"E����,�'.�|�|�C��'E��&2�1�n��".�q�.��%,�-=�l�%K�
�"�c�:�c�>�*@�*@��*E�&F��&I�!"�D��,��$�%<�t�G�L�Ye�fh�Yh�Di�?j�%j�k�k�$���<��>�*�C�/�#/��>�L�!+�C�R��J�!%�J�'�-�-�/�
�$�*�*�3�/��#�1�:��'�~�~�/��$�A���!�
� ,�R� 0�
�%�b�k�$�.���� � ��!� ��#&�w�<� �"�#3�3�&�|�4�H�#/��>�L�'�~�~�/�H���{�C�'�(�)X�[_�`h�[i�)i�j�j��X�a�b�\�1�'�(8�8�",�->��h��-O�"P�P�'.�|�'<��'3�A�~��.6��#E��
�X�a�b�\�1� (�~�~�/�H�&�n�n�.�G�")�"�+�K�'�(:�#�k�*:�):�;�H�'�~�~�/�H�j� (����(�2�,�T��d�'�C�'�5�$�+;��+;�#+�A�b�>��'/�A�m�$�$/�M�7#�#3�3�:����
�
 �%�l�l�3��7�O��v�%���<�#�J� '��� 0�I� ��\�F� �����+�$�QU�VZ�[b�ci�kq�rt�kt�[u�Vv�%w�x�x����*�+�S�0�#*�<�<��_�#E� �#�O�3�$�%<�t�G�O�]l�mo�]o�Dp�?q�%q�r�r�#*�?�1�+<�>N�#O� �/�5�5�7��
)��O�	���?�$�W�f�-�F�!$�V�\�\�$�%7�!8�J�$�[�j�1�F�!�&�,�,�t�"4�5�G�$��
�D��J��Y���g�V\�^d�eh�^h�Ni�Ij�&l�m�m�#�F�?�;�	���H�H�Y�'�)�!�+��!�
�$�F�?�;�	���H�H�Y�'�'0��O�^b�tB�'C�#��F���H�H�Y�'�i�
 �t����)D�;�	�W�k�:�6�A�
�v�;���Qj�(�)E�d�H�V^�_f�Kg�Fh�)h�i�i�s�
V?�?Wc	���t|ttf�r|S|\}}}}|si}g}|j�D]&}||}|j	|�dt|�����(dj
|�}|s
|rtd��|�bttt|��}	dj
|	�}
|s|
S|
jd�}ddj
|�z}
d|�d|�d|
�d	|�d
�	Sd|�d|�d�S)z!pretty printer mainly for testingr\rczname missing with attributes???rbz   z
   r.z>
z
</r/z/>)r r!�bytes�keysr4ri�joinrM�list�map�pprettyprintrl)�	parsedxmlru�attdict�textlist�extrar��k�v�
attributes�textlistpprint�
textpprint�nllists            rr�r��s����)�S��K�(���'0�$�T�7�H�e��B�G��G�
�\�\�^�/���A�J�����!�T�!�W�-�.�/����'�"�J��J��:�;�;����c�,��9�:���Y�Y�~�.�
�����!�!�$�'���W�\�\�&�1�2�
�'+�Z��T�J�J���z�*�*rc���ddlm}ddlm}|�}t|d��}td|�|z
�|dzr||�|dzr"td�t	|�}t|�yy)	Nr��time)�pprintr	)r�DONEr[z============== reformatting)r�r�rBrr�)r�dumpr�r��nowr�rs       r�	testparser��s^����
�&�C��q��+�A�	�&�$�&��*���A�v��q�	��A�v�
�+�,���O��
�a��rc��td|��y)Na-<this type="xml">text &lt;&gt;<b>in</b> <funnytag foo="bar"/> xml</this>
                 <!-- comment -->
                 <![CDATA[
                 <this type="xml">text <b>in</b> xml</this> ]]>
                 <tag with="<brackets in values>">just testing brackets feature</tag>
                 �r�)r�r�s r�testr��s��
��
� r�__main__r�r�z!!!!! no file at {f!r}zparsing z |t|=z	timed at z.2fz secs.)r)+�__doc__r=�simpleparse�pyRXPUr�Parserrrr>rrg�NAMEKEY�CONTENTSKEYrkrL�LENCDATAMARKERrjr2r:rBrI�verboserUr?r�r�r�r)�sys�osr��	reportlabr��seen�argv�f�path�isfilerrE�_frFr�r,rr�<module>r�s���5�n����K��� �6�=�=�./�'(�01�./�!'� .�%&��L�+,��T�TV�;����m��	��
�������[�!����<���-.�4�GZ����H�����0#$�a�*�f�P+�4� ��Z���a�L����
�&�C��D�
�X�X�a�b�\����w�w�~�~�a� ��*�+��a��
�B��G�G�I��
��H�Q�E��s�1�v�h�/�0��a�Q���A�I�D���
�	�$�&��*�S�)��0�1��!��K���K���`
�
�s�*D>�&E�>E	�E	�E	

Zerion Mini Shell 1.0