ok

Mini Shell

Direktori : /opt/cloudlinux/venv/lib/python3.11/site-packages/lxml/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/lxml/__pycache__/doctestcompare.cpython-311.pyc

�

�܋f�G��<�dZddlmZddlZddlZddlZ	ddlmZn#e	$r	ddl
mZYnwxYwgd�Z	eZ
n#e$reefZ
YnwxYwejddkZejd��Zejd��Zejd	��ZejZd
�Zd�Zejdd
���Zd�Zejd��Zejd��ZGd�de��Z Gd�de ��Z!dd�Z"dd�Z#Gd�de$��Z%d�Z&ddiZ'e(dkrddlZej)��dSdS) a�
lxml-based doctest output comparison.

Note: normally, you should just import the `lxml.usedoctest` and
`lxml.html.usedoctest` modules from within a doctest, instead of this
one::

    >>> import lxml.usedoctest # for XML output

    >>> import lxml.html.usedoctest # for HTML output

To use this module directly, you must call ``lxmldoctest.install()``,
which will cause doctest to use this in all subsequent calls.

This changes the way output is checked and comparisons are made for
XML or HTML-like content.

XML or HTML content is noticed because the example starts with ``<``
(it's HTML if it starts with ``<html``).  You can also use the
``PARSE_HTML`` and ``PARSE_XML`` flags to force parsing.

Some rough wildcard-like things are allowed.  Whitespace is generally
ignored (except in attributes).  In text (attributes and text in the
body) you can use ``...`` as a wildcard.  In an example it also
matches any trailing tags in the element, though it does not match
leading tags.  You may create a tag ``<any>`` or include an ``any``
attribute in the tag.  An ``any`` tag matches any tag, while the
attribute matches any and all attributes.

When a match fails, the reformatted example and gotten text is
displayed (indented), and a rough diff-like output is given.  Anything
marked with ``+`` is in the output but wasn't supposed to be, and
similarly ``-`` means its in the example but wasn't in the output.

You can disable parsing on one line with ``# doctest:+NOPARSE_MARKUP``
�)�etreeN)�escape)�
PARSE_HTML�	PARSE_XML�NOPARSE_MARKUP�LXMLOutputChecker�LHTMLOutputChecker�install�temp_install�rrrc�2�|�dS|���S�N)�strip��vs �f/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib64/python3.11/site-packages/lxml/doctestcompare.pyrr?s���y��t��w�w�y�y��c�8�t�d|��S)N� )�_norm_whitespace_re�subrs r�norm_whitespacerEs���"�"�3��*�*�*rFT)�recover�remove_blank_textc�6�tj|t��Sr)r�
fromstring�_html_parser��htmls r�html_fromstringr Js����D�,�/�/�/rz^<[^>]+ (at|object) z[ \t\n][ \t\n]+c��eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zdd�Zdd
�Z
dd�Zd�Zd�Zd�Zd�Zd�Zdd�ZdS)r)
�param�img�area�br�basefont�input�base�meta�link�colc��tjSr)r�XML��selfs r�get_default_parserz$LXMLOutputChecker.get_default_parserWs
���y�rc�Z�t|dd��}|�
|j}|}ntj}|�|||��}|s|||||��S	||��}n#t
j$rYdSwxYw	||��}n#t
j$rYdSwxYw|�||��S)N�_temp_override_selfF)�getattr�_temp_call_super_check_output�
OutputChecker�check_output�
get_parserr�XMLSyntaxError�compare_docs)	r/�want�got�optionflags�alt_self�super_method�parser�want_doc�got_docs	         rr6zLXMLOutputChecker.check_outputZs����4�!6��=�=�����=�L��D�D�(�5�L�����s�K�8�8���	.��<��d�C��.�.�
.�	��v�d�|�|�H�H���#�	�	�	��5�5�	����	��f�S�k�k�G�G���#�	�	�	��5�5�	����� � ��7�3�3�3s$�A�A1�0A1�5B�B�Bc��d}t|zrdSt|zrt}n�t|zr
tj}n�|�������d��r/|����d��rt}n>|�	|��r)|�	|��r|�
��}|S)Nz<html)rrr rrr-r�lower�
startswith�_looks_like_markupr0)r/r:r;r<r?s     rr7zLXMLOutputChecker.get_parseros������K�'�	��4���#�		/�$�F�F�
��
$�	/��Y�F�F��j�j�l�l� � �"�"�-�-�g�6�6�	/��)�)�+�+�(�(��1�1�	/�$�F�F��%�%�d�+�+�	/��)�)�#�.�.�	/��,�,�.�.�F��
rc��|���}|�d��ot�|��S)N�<)rrD�_repr_re�search)r/�ss  rrEz$LXMLOutputChecker._looks_like_markups:��
�G�G�I�I�����S�!�!�+� ����*�*�*�	,rc�&�|�|j|j��sdS|�|j|jd��sdS|�|j|jd��sdSd|jvr�t
|j�����}t
|j�����}||krdS|D]2}|�|j||j|d��sdS�3|jdkst|��r|t|��}t|��}|s|rZ|r|sdS|�
d��}|�
d��}	|�||	��sdS|s|jdkrn|�X|�ZdS)NFT�anyz...r)�tag_compare�tag�text_compare�text�tail�attrib�sorted�keys�len�list�popr9)
r/r:r;�	want_keys�got_keys�key�
want_children�got_children�
want_first�	got_firsts
          rr9zLXMLOutputChecker.compare_docs�s��������#�'�2�2�	��5�� � ���C�H�d�;�;�	��5�� � ���C�H�d�;�;�	��5����#�#��t�{�/�/�1�1�2�2�I��c�j�o�o�/�/�0�0�H��H�$�$��u� �
!�
!���(�(���S�)9�3�:�c�?�E�R�R�!� �5�5�!��9�����T���� ��J�J�M���9�9�L��
�<�
�$�!�L�!� �5�*�.�.�q�1�1�
�(�,�,�Q�/�/�	��(�(��Y�?�?�!� �5�#��
��5�(@�(@�� �
�<�
��trc�&�|pd}|pd}|rBt|�����}t|�����}dtj|��z}|�dd��}tj||��rdSdS)N�z^%s$z\.\.\.z.*TF)rr�rer�replacerI)r/r:r;rs    rrOzLXMLOutputChecker.text_compare�s����z�r���i�R���	/�"�4�(�(�.�.�0�0�D�!�#�&�&�,�,�.�.�C���	�$���'���|�|�I�t�,�,��
�9�T�3���	��4��5rc�(�|dkrdSt|t��rt|t��s||kS|pd}|pd}|�d��r8|�d��d|�d��dkS||kS)NrLTr`z{...}�}���)�
isinstance�_basestringrD�split)r/r:r;s   rrMzLXMLOutputChecker.tag_compare�s����5�=�=��4��4��-�-�	��c�;�/�/�	��3�;���z�r���i�R���?�?�7�#�#�	��:�:�c�?�?�2�&�#�)�)�C�.�.��*<�<�<��3�;�rc��|j}|�|||��}g}|��	||��}nF#tj$r4t	j��d}|�d|z��YnwxYw	||��}	nF#tj$r4t	j��d}|�d|z��YnwxYw|�|rKt�||||��}
|r*|�|
��d�	|��S|
S|tu}d|�||d��d|�|	|d��d|�||	|d��g}d�	|��S)	N�zIn example: %szIn actual output: %s�
z	Expected:�zGot:zDiff:)
r:r7rr8�sys�exc_info�appendr5�output_difference�joinr �
format_doc�collect_diff)
r/�exampler;r<r:r?�errorsr@�erA�valuer�
diff_partss
             rrpz#LXMLOutputChecker.output_difference�s����|������s�K�8�8������
4�!�6�$�<�<�����'�
4�
4�
4��L�N�N�1�%���
�
�.��2�3�3�3�3�3�
4����
:� �&��+�+�����'�
:�
:�
:��L�N�N�1�%���
�
�4�q�8�9�9�9�9�9�
:�����>�V�>�!�3�3��g�s�K�1�1�E��
��
�
�e�$�$�$��y�y��(�(�(�����(��!��o�o�h��a�8�8���o�o�g�t�Q�7�7���'�'��'�4��C�C�E�
��y�y��$�$�$s#�0�AA3�2A3�7B�AC�CTc�^�|sdS|j|jvrdS|jst|��rdSdS)NFT)rN�
empty_tagsrPrU)r/�elrs   r�html_empty_tagz LXMLOutputChecker.html_empty_tag�sD���	��5�
�6���(�(��5�
�7�	�c�"�g�g�	��5��trr`c	��g}t|���s?|�d|z��|�|��|�|�|����|�||��sit	|j��r-|�|�|j����|�|�|����t	|j��r-|�|�|j����|�d��d�	|��S|�d|z��|�|��|�|�|����|�||���s
|�d��t	|j��rZ|�d|z��|�|�|j����|�d��|D]/}|�|�
|||dz�����0|�d|z��|�|�|����|�d��t	|j��rZ|�d|z��|�|�|j����|�d��d�	|��S)Nrrkr`rl)rUro�
format_tagr|rrP�format_text�format_end_tagrQrqrr)r/�docr�indent�prefix�partsr{s       rrrzLXMLOutputChecker.format_doc�s������3�x�x�	"��L�L��V��$�$�$��L�L�� � � ��L�L�����-�-�.�.�.��&�&�s�D�1�1�
7����?�?�=��L�L��!1�!1�#�(�!;�!;�<�<�<����T�0�0��5�5�6�6�6��S�X���
9����T�-�-�c�h�7�7�8�8�8��L�L������7�7�5�>�>�!�
���S��Z� � � �
���V����
���T�_�_�S�)�)�*�*�*��"�"�3��-�-�
	��L�L������S�X���
#����S��Z�(�(�(����T�-�-�c�h�7�7�8�8�8����T�"�"�"��
B�
B�����T�_�_�R��v�a�x�@�@�A�A�A�A��L�L��V��$�$�$��L�L��,�,�S�1�1�2�2�2��L�L��������?�?�	��L�L��V��$�$�$��L�L��)�)�#�(�3�3�4�4�4��L�L������w�w�u�~�~�rc�V�|�dS|r|���}t|d��S)Nr`rj)r�html_escape)r/rPrs   rrzLXMLOutputChecker.format_text	s1���<��2��	 ��:�:�<�<�D��4��#�#�#rc	�N�g}t|tj��rdSt|j�����D]4\}}|�|�d|�|d���d����5|s
d|jzSd|j�dd�	|���d�S)	Nz<!--�="F�"�<%s>rGr�>)
rfr�CommentBaserSrR�itemsrorrNrq)r/r{�attrs�namerws     rr~zLXMLOutputChecker.format_tags������b�%�+�,�,�	��6�!�"�)�/�/�"3�"3�4�4�	M�	M�K�D�%��L�L�d�d�d�D�,<�,<�U�E�,J�,J�,J�,J�K�L�L�L�L��	#��B�F�?�"�	#��F�F�F�C�H�H�U�O�O�O�O�4�4rc�N�t|tj��rdSd|jzS)Nz-->�</%s>)rfrr�rN)r/r{s  rr�z LXMLOutputChecker.format_end_tags)���b�%�+�,�,�	��5�����rc	��g}t|���s t|���s|�d|z��|�|�||����|�||��s\|�|�|j|j����|�|�||����|�|�|j|j����|�d��d�|��S|�d|z��|�|�||����|�d��t|j��st|j��r`|�d|z��|�|�|j|j����|�d��t|��}t|��}|s|r�|sB|�|�|�d��||dzd�����H|sB|�|�|�d��||dzd������|�|�
|�d��|�d��||dz����|��|��|�d|z��|�|�||����|�d��t|j��st|j��r`|�d|z��|�|�|j|j����|�d��d�|��S)Nrrkr`rrl�+�-)rUro�collect_diff_tagr|�collect_diff_textrP�collect_diff_end_tagrQrqrrVrrrWrs)r/r:r;rr�r�r[r\s        rrszLXMLOutputChecker.collect_diff!s������4�y�y�	"��S���	"��L�L��V��$�$�$��L�L��.�.�t�S�9�9�:�:�:��&�&�s�D�1�1�
C����T�3�3�D�I�s�x�H�H�I�I�I����T�6�6�t�S�A�A�B�B�B��L�L��/�/��	�3�8�D�D�E�E�E��L�L������7�7�5�>�>�!�
���S��Z� � � �
���T�*�*�4��5�5�6�6�6�
���T���������	�u�S�X���	��L�L��V��$�$�$��L�L��/�/��	�3�8�D�D�E�E�E��L�L������T�
�
�
��C�y�y���	L�|�	L� �
����T�_�_�\�-=�-=�a�-@�-@�$��q��RU�V�V�W�W�W���
����T�_�_�]�->�->�q�-A�-A�4��PQ��SV�W�W�X�X�X���L�L��*�*��!�!�!�$�$�l�&6�&6�q�&9�&9�4����K�K�
L�
L�
L��	L�|�	L�	���S��Z� � � �
���T�.�.�t�S�9�9�:�:�:�
���T���������	�u�S�X���	��L�L��V��$�$�$��L�L��/�/��	�3�8�D�D�E�E�E��L�L������w�w�u�~�~�rc
�H�|�|j|j��s|j�d|j�d�}n|j}g}|jdkpd|jv}t|j�����D]�\}}||jvr3|s1|�d|�d|�|d���d����A||jvr#|�|j||d��}n|�|d��}|�|�d|�d�����|sft|j�����D]?\}}||jvr�|�d|�d|�|d���d����@|rd	|�d
d
�|���d�}nd|z}|S)
N� (got: �)rLr�r�Fr�r�rGrr�r�)	rMrNrRrSr�rorr�rq)	r/r:r;rNr�rLr�rwrPs	         rr�z"LXMLOutputChecker.collect_diff_tagGs��������#�'�2�2�	�$(�H�H�H�c�g�g�g�6�C�C��'�C����h�%��7�5�D�K�#7��!�#�*�"2�"2�"4�"4�5�5�	7�	7�K�D�%��4�;�&�&�s�&�����4�4�4��1A�1A�%��1O�1O�1O�1O�P�Q�Q�Q�Q��4�;�&�&��1�1�$�+�d�2C�U�E�R�R�D�D��+�+�E�5�9�9�D����$�$�$����5�6�6�6�6��	R�%�d�k�&7�&7�&9�&9�:�:�
R�
R���e��3�:�%�%������4�4�4��1A�1A�%��1O�1O�1O�1O�P�Q�Q�Q�Q��	�	�"�s�s�C�H�H�U�O�O�O�O�4�C�C��3�,�C��
rc�`�|j|jkr|j�d|j�d�}n|j}d|zS)Nr�r�r�)rN)r/r:r;rNs    rr�z&LXMLOutputChecker.collect_diff_end_tagbs:���8�s�w���$(�H�H�H�c�g�g�g�6�C�C��'�C���}�rc��|�|||��r|sdS|�||��S|�d|�d�}|�||��S)Nr`r�r�)rOr)r/r:r;rrPs     rr�z#LXMLOutputChecker.collect_diff_textisg�����T�3��.�.�	0��
��r��#�#�C��/�/�/�!%���s�s�s�+������e�,�,�,rN)T)r`)�__name__�
__module__�__qualname__rzr0r6r7rEr9rOrMrpr|rrrr~r�rsr�r�r��rrrrQs1������'�J����4�4�4�*��� ,�,�,�
���:������%�%�%�@����!�!�!�!�F$�$�$�$�	5�	5�	5� � � �$�$�$�L���6���-�-�-�-�-�-rrc��eZdZd�ZdS)r	c��tSr)r r.s rr0z%LHTMLOutputChecker.get_default_parserrs���rN)r�r�r�r0r�rrr	r	qs#����������rr	c�R�|rtt_dStt_dS)z�
    Install doctestcompare for all future doctests.

    If html is true, then by default the HTML parser will be used;
    otherwise the XML parser is used.
    N)r	�doctestr5rrs rr
r
us(���2� 2����� 1����rc�`�|rt}nt}t��}|jd}|��}|j}||_t
r|jdj}|jj}n|jdj}|jj}tt_	t||||||��dS)z�
    Use this *inside* a doctest to enable this checker for this
    doctest only.

    If html is true, then by default the HTML parser will be used;
    otherwise the XML parser is used.
    r/�checkN)r	r�_find_doctest_frame�f_locals�_checker�_IS_PYTHON_3�__func__r6�im_funcrr��_RestoreChecker)	r�
del_module�Checker�frame�dt_self�checker�old_checker�
check_func�checker_check_funcs	         rrr�s����$�$���#���!�!�E��n�V�$�G��g�i�i�G��"�K��G���:��^�G�,�5�
�$�1�:����^�G�,�4�
�$�1�9���G�M��G�[�'�� 2�� � � � � rc�>�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	S)
r�c���||_||_|j|j_||j_||_||_||_|���|�	��dSr)
r�r��
call_superr4r2r��
clone_funcr��
install_clone�install_dt_self)r/r�r��new_checkerr�r�r�s       r�__init__z_RestoreChecker.__init__�se�����"���59�_���2�+6���(�$���$���$����������������rc��tr:|jj|_|jj|_|jj|j_dS|jj|_|jj|_|jj|j_dSr)r�r��__code__�	func_code�__globals__�func_globalsr�r.s rr�z_RestoreChecker.install_clone�sg���	B�!�_�5�D�N� $�� ;�D��'+��'?�D�O�$�$�$�!�_�6�D�N� $�� <�D��(,��(A�D�O�%�%�%rc�\�tr|j|j_dS|j|j_dSr)r�r�r�r�r.s r�uninstall_clonez_RestoreChecker.uninstall_clone�s.���	7�'+�~�D�O�$�$�$�(,��D�O�%�%�%rc�@�|jj|_||j_dSr)r��_DocTestRunner__record_outcome�	prev_funcr.s rr�z_RestoreChecker.install_dt_self�s����D���6:���3�3�3rc�(�|j|j_dSr)r�r�r�r.s r�uninstall_dt_selfz!_RestoreChecker.uninstall_dt_self�s��6:�n���3�3�3rc���|jrWddl}|j|j=d|jvr?|j�dd��\}}|j|}t	||��dSdSdS)Nr�.rj)r�rm�modules�rsplit�delattr)r/rm�package�module�package_mods     r�uninstall_modulez _RestoreChecker.uninstall_module�s}���?�	-��J�J�J���D�O�,��d�o�%�%�"&�/�"8�"8��a�"@�"@����!�k�'�2����V�,�,�,�,�,�
	-�	-�&�%rc��|���|���|j`|j`|j|i|��}|���|Sr)r�r�r�r2r4r�r�)r/�args�kw�results    r�__call__z_RestoreChecker.__call__�sc����������� � � ��L�,��L�6�����,��,�,���������
rc��|���	|j|i|��|���S#|���wxYwr)r�r�r�)r/r�r�s   rr�z_RestoreChecker.call_super�sZ��������	!�"�4�?�D�/�B�/�/���� � � � ��D��� � � � ���s	�7�A
N)r�r�r�r�r�r�r�r�r�r�r�r�rrr�r��s�������
�
�
�B�B�B�7�7�7�
;�;�;�E�E�E�-�-�-����!�!�!�!�!rr�c�x�ddl}|jd��}|r|j}d|vr|S|j}|�t	d���)Nrrj�BOOMzBCould not find doctest (only use this function *inside* a doctest))rm�	_getframer��f_back�LookupError)rmr��ls   rr�r��sd���J�J�J��C�M�!���E�
���N���Q�;�;��L�������L�N�N�Nr�basicai
    >>> temp_install()
    >>> print """<xml a="1" b="2">stuff</xml>"""
    <xml b="2" a="1">...</xml>
    >>> print """<xml xmlns="http://example.com"><tag   attr="bar"   /></xml>"""
    <xml xmlns="...">
      <tag attr="..." />
    </xml>
    >>> print """<xml>blahblahblah<foo /></xml>""" # doctest: +NOPARSE_MARKUP, +ELLIPSIS
    <xml>...foo /></xml>
    �__main__)F)FN)*�__doc__�lxmlrrmrar�rrr��ImportError�cgi�__all__�
basestringrg�	NameError�str�bytes�version_infor��register_optionflagrrrr5rr�
HTMLParserrr �compilerHrrr	r
r�objectr�r��__test__r��testmodr�rr�<module>r�s���#�#�J������
�
�
�
�	�	�	�	�����*�*�*�*�*�*�*�*���*�*�*�)�)�)�)�)�)�)�)�*����<�<�<����K�K��������,�K�K�K��������"�a�'��
(�W�
(��
6�
6�
�'�G�'��4�4�	�,��,�-=�>�>���%�
����+�+�+� �u����F�F�F��0�0�0��2�:�-�.�.�� �b�j�!3�4�4��^-�^-�^-�^-�^-�
�^-�^-�^-�@	�����*����
2�
2�
2�
2�% �% �% �% �N4!�4!�4!�4!�4!�f�4!�4!�4!�l
N�
N�
N��
�	���z����N�N�N��G�O�������s��+�+�6�	A�A

Zerion Mini Shell 1.0