+
    ĜiCE                        R t ^ RIHt ^ RIt^ RIt^ RIt ^ RIHt . ROt]P                  ! R4      t]P                  ! R4      t]P                  ! R4      t]P                   tR	 tR
 t]P&                  ! RRR7      tR t]P,                  ! R4      t]P,                  ! R4      t ! R R]4      t ! R R]4      tRR ltRR lt ! R R4      tR tRR/t] R8X  d   ^ RIt]PB                  ! 4        R# R#   ]	 d
    ^ RI
Ht  Li ; i)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LHTMLOutputCheckerc                 .    V f   R # V P                  4       # N)stripvs   &\/Users/mibo/.openclaw/workspace/.venv-ak/lib/python3.14/site-packages/lxml/doctestcompare.pyr   r   8   s    ywwy    c                 .    \         P                  R V 4      # ) )_norm_whitespace_resubr   s   &r   norm_whitespacer   >   s    ""3**r   FT)recoverremove_blank_textc                 8    \         P                  ! V \        4      # r
   )r   
fromstring_html_parserhtmls   &r   html_fromstringr   C   s    D,//r   z^<[^>]+ (at|object) z[ \t\n][ \t\n]+c                      a  ] tR t^Jt o RtR tR tR tR tR t	R t
R tR tRR	 ltRR
 ltRR ltR tR tR tR tR tRR ltRtV tR# )r   c                "    \         P                  # r
   )r   XMLselfs   &r   get_default_parser$LXMLOutputChecker.get_default_parserP   s    yyr   c                ^   \        V R R4      pVe   V P                  pTp M\        P                  pV P	                  WV4      pV'       g
   V! WW#4      #  V! V4      p T! T4      pT P                  Yx4      #   \
        P                   d     R# i ; i  \
        P                   d     R# i ; i)_temp_override_selfNF)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	   &&&&     r   r)   LXMLOutputChecker.check_outputS   s    4!6===LD(55LK8C. .	d|H	SkG   33 ## 		 ## 		s$   A7 B 7BBB,+B,c                   R p\         V,          '       d   R # \        V,          '       d	   \        pV# \        V,          '       d   \        P
                  pV# VP                  4       P                  4       P                  R4      '       d.   VP                  4       P                  R4      '       d	   \        pV# V P                  V4      '       d(   V P                  V4      '       d   V P                  4       pV# )Nz<html)r   r   r   r   r   r   r   lower
startswith_looks_like_markupr"   )r!   r-   r.   r/   r2   s   &&&& r   r*   LXMLOutputChecker.get_parserh   s    K''##$F  $$YYF  jjl  "--g66))+((11$F  %%d++))#..,,.Fr   c                    VP                  4       pVP                  R 4      ;'       d    \        P                  V4      '       * # )<)r   r8   _repr_research)r!   ss   &&r   r9   $LXMLOutputChecker._looks_like_markupx   s7    GGIS! + + **	,r   c                   V P                  VP                  VP                  4      '       g   R # V P                  VP                  VP                  R4      '       g   R # V P                  VP                  VP                  R4      '       g   R # RVP
                  9  d   \        VP
                  P                  4       4      p\        VP
                  P                  4       4      pW48w  d   R # V FA  pV P                  VP
                  V,          VP
                  V,          R 4      '       d   K@   R # 	  VP                  R8w  g   \        V4      '       d   \        V4      p\        V4      pV'       g	   V'       dn   V'       d	   V'       g   R # VP                  ^ 4      pVP                  ^ 4      p	V P                  W4      '       g   R # V'       d   Kg  VP                  R8X  g   Kz   R# R# )FTanyz...)tag_comparetagtext_comparetexttailattribsortedkeyslenlistpopr,   )
r!   r-   r.   	want_keysgot_keyskeywant_childrengot_children
want_first	got_firsts
   &&&       r   r,   LXMLOutputChecker.compare_docs}   sS   #''22  CHHd;;  CHHd;;#t{{//12Icjjoo/0H$ ((S)93::c?ERR  ! 99T JM9L<$L *..q1
(,,Q/	((?? #|
5(@r   c                D   T;'       g    R pT;'       g    R pV'       d3   \        V4      P                  4       p\        V4      P                  4       pR\        P                  ! V4      ,          pVP	                  RR4      p\        P
                  ! W4      '       d   R# R# ) z^%s$z\.\.\.z.*TF)r   r   rer   replacer>   )r!   r-   r.   r   s   &&&&r   rE   LXMLOutputChecker.text_compare   sx    zzriiR"4(..0D!#&,,.C		$'||It,99Tr   c                T   VR 8X  d   R# \        V\        \        34      '       d   \        V\        \        34      '       g   W8H  # T;'       g    RpT;'       g    RpVP                  R4      '       d2   VP	                  R4      R,          VP	                  R4      R,          8H  # W8H  # )rB   TrW   z{...}})
isinstancestrbytesr8   split)r!   r-   r.   s   &&&r   rC   LXMLOutputChecker.tag_compare   s    5=4#u..!#U|44;zzriiR??7##::c?2&#))C.*<<<;r   c                   VP                   pV P                  WBV4      p. pVe    V! V4      p V! V4      p	Ve	   V'       dC   \        P                  WW#4      p
V'       d#   VP                  V
4       RP                  V4      # V
# V\        J pRV P                  XV^4      RV P                  X	V^4      RV P                  WyV^4      .pRP                  V4      #   \        P                   d8    \        P
                  ! 4       ^,          pTP                  RT,          4        Li ; i  \        P                   d9    \        P
                  ! 4       ^,          pTP                  RT,          4        EL=i ; i)NzIn example: %szIn actual output: %s
z	Expected:zGot:zDiff:)r-   r*   r   r+   sysexc_infoappendr(   output_differencejoinr   
format_doccollect_diff)r!   exampler.   r/   r-   r2   errorsr3   er4   valuer   
diff_partss   &&&&         r   rh   #LXMLOutputChecker.output_difference   sR   ||K84!$<: + >V!33s1Ee$yy(((!ooha8oogtQ7''4CE
 yy$$/ '' 4LLN1%.234
 '' :LLN1%4q89:s$   C D( A	D%$D%(A	E54E5c                    V'       g   R # VP                   V P                  9  d   R # VP                  '       g   \        V4      '       d   R # R# )FT)rD   
empty_tagsrF   rK   )r!   elr   s   &&&r   html_empty_tag LXMLOutputChecker.html_empty_tag   s2    66(777c"ggr   c           	     2   . p\        V4      '       Eg-   VP                  R V,          4       VP                  V4       VP                  V P                  V4      4       V P                  W4      '       gf   \	        VP
                  4      '       d+   VP                  V P                  VP
                  4      4       VP                  V P                  V4      4       \	        VP                  4      '       d+   VP                  V P                  VP                  4      4       VP                  R4       RP                  V4      # VP                  R V,          4       VP                  V4       VP                  V P                  V4      4       V P                  W4      '       g   VP                  R4       \	        VP
                  4      '       dT   VP                  R V,          4       VP                  V P                  VP
                  4      4       VP                  R4       V F+  pVP                  V P                  WbV^,           4      4       K-  	  VP                  R V,          4       VP                  V P                  V4      4       VP                  R4       \	        VP                  4      '       dT   VP                  R V,          4       VP                  V P                  VP                  4      4       VP                  R4       RP                  V4      # )r   rd   rW   )rK   rg   
format_tagru   r   rF   format_textformat_end_tagrG   ri   rj   )r!   docr   indentprefixpartsrt   s   &&&&&  r   rj   LXMLOutputChecker.format_doc   s   3xxLLV$LL LL-.&&s11??LL!1!1#((!;<T0056SXXT--chh78LL775>!SZ VT__S)*""3--LLSXXSZ(T--chh78T"T__Rvax@A LLV$LL,,S12LL??LLV$LL))#((34LLwwu~r   c                V    Vf   R# V'       d   VP                  4       p\        V^4      # )NrW   )r   html_escape)r!   rF   r   s   &&&r   ry   LXMLOutputChecker.format_text  s%    <::<D4##r   c           	     r   . p\        V\        P                  4      '       d   R # \        VP                  P                  4       4       F.  w  r4VP                  V: RV P                  VR4      : R24       K0  	  V'       g   RVP                  ,          # RVP                  : RRP                  V4      : R2# )z<!--="F"<%s>r<   r   >)
r^   r   CommentBaserI   rH   itemsrg   ry   rD   ri   )r!   rt   attrsnamero   s   &&   r   rx   LXMLOutputChecker.format_tag	  s    b%++,,!"))//"34KDLLdD,<,<UE,JKL 5BFF?" FFCHHUO44r   c                l    \        V\        P                  4      '       d   R # RVP                  ,          # )z--></%s>)r^   r   r   rD   )r!   rt   s   &&r   rz    LXMLOutputChecker.format_end_tag  s'    b%++,,r   c           	        . p\        V4      '       Eg   \        V4      '       g   VP                  R V,          4       VP                  V P                  W4      4       V P                  W#4      '       gV   VP                  V P	                  VP
                  VP
                  4      4       VP                  V P                  W4      4       VP                  V P	                  VP                  VP                  4      4       VP                  R4       RP                  V4      # VP                  R V,          4       VP                  V P                  W4      4       VP                  R4       \        VP
                  4      '       g   \        VP
                  4      '       d_   VP                  R V,          4       VP                  V P	                  VP
                  VP
                  4      4       VP                  R4       \        V4      p\        V4      pV'       g	   V'       d   V'       g;   VP                  V P                  VP                  ^ 4      W4^,           R4      4       KR  V'       g;   VP                  V P                  VP                  ^ 4      W4^,           R4      4       K  VP                  V P                  VP                  ^ 4      VP                  ^ 4      W4^,           4      4       K  VP                  R V,          4       VP                  V P                  W4      4       VP                  R4       \        VP                  4      '       g   \        VP                  4      '       d_   VP                  R V,          4       VP                  V P	                  VP                  VP                  4      4       VP                  R4       RP                  V4      # )r   rd   rW   +-)rK   rg   collect_diff_tagru   collect_diff_textrF   collect_diff_end_tagrG   ri   r   rL   rj   rM   rk   )r!   r-   r.   r   r|   r~   rQ   rR   s   &&&&&   r   rk   LXMLOutputChecker.collect_diff  s   4yySLLV$LL..t9:&&s11T33DIIsxxHIT66tABLL//		388DELL775>!SZ T**456TuSXXLLV$LL//		388DELLT
Cy| T__\-=-=a-@$qRUVWT__]->->q-A4PQSVWXLL**!!!$l&6&6q&94K LSZ T..t9:TuSXXLLV$LL//		388DELLwwu~r   c           
        V P                  VP                  VP                  4      '       g    VP                  : R VP                  : R2pMVP                  p. pVP                  R8H  ;'       g    RVP                  9   p\        VP                  P	                  4       4       F  w  rgWaP                  9  d5   V'       g-   VP                  RV: RV P                  VR4      : R24       KI  WaP                  9   d&   V P                  VP                  V,          VR4      pMV P                  VR4      pVP                  V: RV: R24       K  	  V'       gi   \        VP                  P	                  4       4       FA  w  rgWbP                  9   d   K  VP                  RV: RV P                  VR4      : R24       KC  	  V'       d   RV: R	R	P                  V4      : R
2pV# RV,          pV# ) (got: )rB   r   r   Fr   r   r<   r   r   r   )	rC   rD   rH   rI   r   rg   ry   r   ri   )	r!   r-   r.   rD   r   rB   r   ro   rF   s	   &&&      r   r   "LXMLOutputChecker.collect_diff_tag@  sl   #''22$(HHcgg6C''Chh%775DKK#7!#**"2"2"45KD;;&s41A1A%1OPQ;;&11$++d2CUERD++E59D$56 6 %dkk&7&7&9:::%41A1A%1OPQ  ; 5"CHHUO4C 
 3,C
r   c                    VP                   VP                   8w  d(   VP                   : R VP                   : R2pRV,          # VP                   pRV,          # )r   r   r   )rD   )r!   r-   r.   rD   s   &&& r   r   &LXMLOutputChecker.collect_diff_end_tag[  sE    88sww$(HHcgg6C } ''C}r   c                    V P                  WV4      '       d   V'       g   R # V P                  W#4      # V: RV: R2pV P                  WC4      # )rW   r   r   )rE   ry   )r!   r-   r.   r   rF   s   &&&& r   r   #LXMLOutputChecker.collect_diff_textb  sG    T..##C//!%s+,,r    N)
paramimgareabrbasefontinputbasemetalinkcol)T)rW   )__name__
__module____qualname____firstlineno__rs   r"   r)   r*   r9   r,   rE   rC   rh   ru   rj   ry   rx   rz   rk   r   r   r   __static_attributes____classdictcell____classdict__s   @r   r   r   J   si     'J4* ,
:%@!F$	5 $L6- -r   c                   &   a  ] tR tRt o R tRtV tR# )r   ij  c                    \         # r
   )r   r    s   &r   r"   %LHTMLOutputChecker.get_default_parserk  s    r   r   N)r   r   r   r   r"   r   r   r   s   @r   r   r   j  s      r   c                V    V '       d   \         \        n        R# \        \        n        R# )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   doctestr(   r   r   s   &r   installr   n  s      2 1r   c                <   V '       d   \         pM\        p\        4       pVP                  R,          pV! 4       pVP                  pWTn        VP                  R,          P
                  pVP                  P
                  p\        \        n        \        WFVWxV4       R# )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__func__r)   r   r   _RestoreChecker)	r   
del_moduleCheckerframedt_selfcheckerold_checker
check_funcchecker_check_funcs	   &&       r   temp_installr   z  s     $#!EnnV$GiG""K (11J --66 GMG' r   c                   P   a  ] tR tRt o R tR tR tR tR tR t	R t
R	 tR
tV tR# )r   i  c                    Wn         W n        V P                  V P                  n        W0P                  n        W@n        WPn        W`n        V P                  4        V P                  4        R # r
   )
r   r   
call_superr'   r%   r   
clone_funcr   install_cloneinstall_dt_self)r!   r   r   new_checkerr   r   r   s   &&&&&&&r   __init___RestoreChecker.__init__  sM    "59__2+6($$$r   c                    V P                   P                  V n        V P                   P                  V n        V P
                  P                  V P                   n        R # r
   )r   __code__	func_code__globals__func_globalsr   r    s   &r   r   _RestoreChecker.install_clone  s;    11 OO77#'??#;#; r   c                <    V P                   V P                  n        R # r
   )r   r   r   r    s   &r   uninstall_clone_RestoreChecker.uninstall_clone  s    #'>> r   c                \    V P                   P                  V n        W P                   n        R # r
   )r   _DocTestRunner__record_outcome	prev_funcr    s   &r   r   _RestoreChecker.install_dt_self  s    DD6:3r   c                <    V P                   V P                  n        R # r
   )r   r   r   r    s   &r   uninstall_dt_self!_RestoreChecker.uninstall_dt_self  s    6:nn3r   c                   V P                   '       dm   ^ RIpVP                  V P                    RV P                   9   d?   V P                   P                  R^4      w  r#VP                  V,          p\	        WC4       R# R# R# )    N.)r   re   modulesrsplitdelattr)r!   re   packagemodulepackage_mods   &    r   uninstall_module _RestoreChecker.uninstall_module  sb    ???DOO,doo%"&//"8"8a"@!kk'2, & r   c                    V P                  4        V P                  4        V P                  =V P                  =V P
                  ! V/ VB pV P                  4        V# r
   )r   r   r   r%   r'   r   r   )r!   argskwresults   &*, r   __call___RestoreChecker.__call__  sR     LL,LL6,,r   c                    V P                  4         V P                  ! V/ VB V P                  4        #   T P                  4        i ; ir
   )r   r   r   )r!   r   r   s   &*,r   r   _RestoreChecker.call_super  s=    	!??D/B/ D s	   4 A)r   r   r   r   r   r   r   r   N)r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   s   @r   r   r     s3     
<2;E-! !r   r   c                      ^ RI p V P                  ! ^4      pV'       d$   VP                  pRV9   d   V# VP                  pK+  \	        R4      h)r   NBOOMzBCould not find doctest (only use this function *inside* a doctest))re   	_getframer   f_backLookupError)re   r   ls      r   r   r     sF    MM!E
NNQ;L
LN Nr   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__)r   r   r   r   r   r   r   )F)FN)"__doc__lxmlr   re   rX   r   r   r   r   ImportErrorcgi__all__register_optionflagr   r   r   r(   r   r   
HTMLParserr   r   compiler=   r   r   r   r   r   r   r   __test__r   testmodr   r   r   <module>r     s$  #J  
 	 **< ((6
''4	,,-=>%%+ F0 ::-.jj!34 ^- ^-@	* 
2! F,! ,!\
N  
	 zOO q  *)*s   C4 4DD