HEX
Server: Apache
System: Linux vps.rockyroadprinting.net 4.18.0 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64
User: rockyroadprintin (1011)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib64/python2.7/site-packages/lxml/doctestcompare.pyo
�
U�*Wc@s�dZddlmZddlZddlZddlZyddlmZWn!e	k
rqddl
mZnXddddd	d
dgZy
eZ
Wnek
r�eefZ
nXejdd
kZejd�Zejd�Zejd�ZejZd�Zd�Zejdede�Zd�Zejd�Z ejd�Z!defd��YZ"d	e"fd��YZ#ed�Z$ee%d�Z&de'fd��YZ(d�Z)idd6Z*e+dkr�ddlZej,�ndS(s�
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``
i����(tetreeN(tescapet
PARSE_HTMLt	PARSE_XMLtNOPARSE_MARKUPtLXMLOutputCheckertLHTMLOutputCheckertinstallttemp_installiicCs|dkrdS|j�SdS(N(tNonetstrip(tv((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pyR
?scCstjd|�S(Nt (t_norm_whitespace_retsub(R((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pytnorm_whitespaceEstrecovertremove_blank_textcCstj|t�S(N(Rt
fromstringt_html_parser(thtml((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pythtml_fromstringJss^<[^>]+ (at|object) s[ \t\n][ \t\n]+c
Bs�eZdZd
�Zd�Zd�Zd
�Zd�Zd�Zd�Z	d�Z
ed�Zdd�Z
ed�Zd�Zd�Zd�Zd�Zd�Zed�ZRS(tparamtimgtareatbrtbasefonttinputtbasetmetatlinktcolcCstjS(N(RtXML(tself((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pytget_default_parserWsc	Cs�t|dd�}|dk	r0|j}|}n	tj}|j|||�}|sg|||||�Sy||�}Wntjk
r�tSXy||�}Wntjk
r�tSX|j	||�S(Nt_temp_override_self(
tgetattrR	t_temp_call_super_check_outputt
OutputCheckertcheck_outputt
get_parserRtXMLSyntaxErrortFalsetcompare_docs(	R!twanttgottoptionflagstalt_selftsuper_methodtparsertwant_doctgot_doc((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pyR'Zs$			cCs�d}t|@rdSt|@r't}n|t|@r=tj}nf|j�j�j	d�rv|j�j	d�rvt}n-|j
|�r�|j
|�r�|j�}n|S(Ns<html(R	RRRRRR R
tlowert
startswitht_looks_like_markupR"(R!R,R-R.R1((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pyR(os

	
	cCs)|j�}|jd�o(tj|�S(Nt<(R
R5t_repr_retsearch(R!ts((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pyR6sc
Cs�|j|j|j�stS|j|j|jt�s;tS|j|j|jt�sZtSd|jkr�t|jj	��}t|jj	��}||kr�tSx8|D]-}|j|j||j|t�s�tSq�Wn|jdks�t
|�r�t|�}t|�}xs|s |r�|s.|r2tS|jd�}|jd�}	|j
||	�sftS|r|jdkrPqqWntS(Ntanys...i(ttag_comparettagR*ttext_comparettexttTruettailtattribtsortedtkeystlentlisttpopR+(
R!R,R-t	want_keystgot_keystkeyt
want_childrentgot_childrent
want_firstt	got_first((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pyR+�s6
#cCs�|p	d}|pd}|rEt|�j�}t|�j�}ndtj|�}|jdd�}tj||�r�tStSdS(Nts^%s$s\.\.\.s.*(RR
treRtreplaceR9R@R*(R!R,R-R
((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pyR>�scCs�|dkrtSt|t�s0t|t�r:||kS|pCd}|pOd}|jd�r�|jd�d|jd�dkS||kSdS(NR;ROs{...}t}i����(R@t
isinstancet_basestringR5tsplit(R!R,R-((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pyR<�s
$c
Cs�|j}|j|||�}g}|dk	r�y||�}Wn5tjk
rwtj�d}|jd|�nXy||�}	Wq�tjk
r�tj�d}|jd|�q�Xn|dks�|rtj	||||�}
|r
|j|
�dj
|�S|
Sn|tk}g}|jd�|j|j||d��|jd�|j|j|	|d��|jd�|j|j
||	|d��dj
|�S(	NisIn example: %ssIn actual output: %ss
s	Expected:isGot:sDiff:(R,R(R	RR)tsystexc_infotappendR&toutput_differencetjoinRt
format_doctcollect_diff(
R!texampleR-R.R,R1terrorsR2teR3tvalueRt
diff_parts((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pyRY�s<	




cCs=|s
tS|j|jkr tS|js5t|�r9tStS(N(R*R=t
empty_tagsR?RER@(R!telR((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pythtml_empty_tag�sROcCs;g}t|�s�|jd|�|j|�|j|j|��|j||�s�t|j�r�|j|j|j��n|j|j|��nt|j�r�|j|j|j��n|jd�dj	|�S|jd|�|j|�|j|j|��|j||�s�|jd�t|j�r}|jd|�|j|j|j��|jd�nx.|D]&}|j|j
|||d��q�W|jd|�|j|j|��|jd�nt|j�r.|jd|�|j|j|j��|jd�ndj	|�S(NRs
ROi(RERXt
format_tagRdR
R?tformat_texttformat_end_tagRARZR[(R!tdocRtindenttprefixtpartsRc((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pyR[�s@





$cCs2|dkrdS|r%|j�}nt|d�S(NROi(R	R
thtml_escape(R!R?R
((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pyRf
s
cCs�g}t|tj�rdSxFt|jj��D]/\}}|jd||j|t�f�q2W|svd|j	Sd|j	dj
|�fS(Ns<!--s%s="%s"s<%s>s<%s %s>R(RSRtCommentBaseRCRBtitemsRXRfR*R=RZ(R!RctattrstnameR`((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pyRes"'cCs!t|tj�rdSd|jS(Ns-->s</%s>(RSRRmR=(R!Rc((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pyRgscCs�g}t|�r�t|�r�|jd|�|j|j||��|j||�s�|j|j|j|j��|j|j||��n|j|j|j|j��|jd�dj|�S|jd|�|j|j||��|jd�t	|j�s%t	|j�re|jd|�|j|j|j|j��|jd�nt
|�}t
|�}x�|s�|r4|s�|j|j|jd�||dd��q�n|s�|j|j|jd�||dd��q�n|j|j
|jd�|jd�||d��q�W|jd|�|j|j||��|jd�t	|j�s�t	|j�r�|jd|�|j|j|j|j��|jd�ndj|�S(NRs
ROiit+t-(RERXtcollect_diff_tagRdtcollect_diff_textR?tcollect_diff_end_tagRARZR
RFR[RGR\(R!R,R-RRiRkRKRL((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pyR\"sH


,,-
c	Cs�|j|j|j�s1d|j|jf}n	|j}g}|jdkp[d|jk}x�t|jj��D]�\}}||jkr�|r�|jd||j|t�f�qt||jkr�|j|j||t�}n|j|t�}|jd||f�qtW|s~x^t|jj��D]D\}}||jkrTq3n|jd||j|t�f�q3Wn|r�d|dj	|�f}n
d|}|S(	Ns%s (got: %s)R;s+%s="%s"s%s="%s"s-%s="%s"s<%s %s>Rs<%s>(
R<R=RBRCRnRXRfR*RtRZ(	R!R,R-R=RoR;RpR`R?((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pyRsHs*	"&"*
cCs<|j|jkr+d|j|jf}n	|j}d|S(Ns%s (got: %s)s</%s>(R=(R!R,R-R=((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pyRucs	cCsO|j|||�r/|sdS|j||�Sd||f}|j||�S(NROs%s (got: %s)(R>Rf(R!R,R-R
R?((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pyRtjs(
RRRRRRRRRR(t__name__t
__module__RbR"R'R(R6R+R>R<RYR@RdR[RfReRgR\RsRuRt(((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pyRQs&						
		!
#			&		cBseZd�ZRS(cCstS(N(R(R!((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pyR"ss(RvRwR"(((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pyRrscCs|rtt_n	tt_dS(s�
    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(RtdoctestR&R(R((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pyRvsc	Cs�|rt}nt}t�}|jd}|�}|j}||_trk|jdj}|jj}n|jdj}|jj}t	t
_	t||||||�dS(s�
    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!tcheckN(RRt_find_doctest_frametf_localst_checkert_IS_PYTHON_3t__func__R'tim_funcRRxt_RestoreChecker(	Rt
del_moduletCheckertframetdt_selftcheckertold_checkert
check_functchecker_check_func((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pyR�s"		
			
	R�cBsPeZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z	RS(cCs`||_||_|j|j_||j_||_||_||_|j�|j	�dS(N(
R�R�t
call_superR%R#R�t
clone_funcR�t
install_clonetinstall_dt_self(R!R�R�tnew_checkerR�R�R�((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pyt__init__�s					
cCsmtr9|jj|_|jj|_|jj|j_n0|jj|_|jj|_|jj|j_dS(N(R}R�t__code__t	func_codet__globals__tfunc_globalsR�(R!((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pyR��scCs+tr|j|j_n|j|j_dS(N(R}R�R�R�(R!((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pytuninstall_clone�scCs|jj|_||j_dS(N(R�t_DocTestRunner__record_outcomet	prev_func(R!((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pyR��scCs|j|j_dS(N(R�R�R�(R!((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pytuninstall_dt_self�scCsp|jrlddl}|j|j=d|jkrl|jjdd�\}}|j|}t||�qlndS(Ni����t.i(R�RVtmodulestrsplittdelattr(R!RVtpackagetmoduletpackage_mod((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pytuninstall_module�s	

cOsF|j�|j�|j`|j`|j||�}|j�|S(N(R�R�R�R#R%R�R�(R!targstkwtresult((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pyt__call__�s

		
cOs0|j�z|j||�SWd|j�XdS(N(R�R�R�(R!R�R�((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pyR��s
(
RvRwR�R�R�R�R�R�R�R�(((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pyR��s								cCsZddl}|jd�}x,|rI|j}d|kr=|S|j}qWtd��dS(Ni����itBOOMsBCould not find doctest (only use this function *inside* a doctest)(RVt	_getframeR{tf_backtLookupError(RVR�tl((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pyRz�s		
si
    >>> 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>
    tbasict__main__(-t__doc__tlxmlRRVRPRxRRRltImportErrortcgit__all__t
basestringRTt	NameErrortstrtbytestversion_infoR}tregister_optionflagRRRR&R
Rt
HTMLParserR*R@RRtcompileR8R
RRRR	RtobjectR�Rzt__test__Rvttestmod(((s9/usr/lib64/python2.7/site-packages/lxml/doctestcompare.pyt<module>$sJ


				�"'6