Ñò ŸªJc @sÅdZddklZddkZddkZddkZddkZdddddd d gZy eZ Wne j oe e fZ nXei d d jZeidƒZeidƒZeidƒZeiZd „Zd„ZeidedeƒZd„ZeidƒZeidƒZdefd„ƒYZdefd„ƒYZed„Z ee!d„Z"de#fd„ƒYZ$d„Z%hdd6Z&e'djoddkZei(ƒ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 ```` 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ÿÿÿÿ(tetreeNt PARSE_HTMLt PARSE_XMLtNOPARSE_MARKUPtLXMLOutputCheckertLHTMLOutputCheckertinstallt temp_installiicCs |djodS|iƒSdS(N(tNonetstrip(tv((s9/usr/lib64/python2.6/site-packages/lxml/doctestcompare.pyR <s cCstid|ƒS(Nt (t_norm_whitespace_retsub(R ((s9/usr/lib64/python2.6/site-packages/lxml/doctestcompare.pytnorm_whitespaceBstrecovertremove_blank_textcCsti|tƒS(N(Rt fromstringt _html_parser(thtml((s9/usr/lib64/python2.6/site-packages/lxml/doctestcompare.pythtml_fromstringGss^<[^>]+ (at|object) s[ \t\n][ \t\n]+c Bs³eZdZd „Zd „Zd „Zd „Zd„Zd„Zd„Z d„Z e d„Z dd„Z e d„Zd„Zd„Zd„Zd„Zd„Ze d„ZRS(tparamtimgtareatbrtbasefonttinputtbasetmetatlinktcolcCstiS(N(RtXML(tself((s9/usr/lib64/python2.6/site-packages/lxml/doctestcompare.pytget_default_parserTsc CsÏt|ddƒ}|dj o|i}|}n ti}|i|||ƒ}|p|||||ƒSy||ƒ}Wntij otSXy||ƒ}Wntij otSX|i ||ƒS(Nt_temp_override_self( tgetattrRt_temp_call_super_check_outputt OutputCheckert check_outputt get_parserRtXMLSyntaxErrortFalset compare_docs( R twanttgott optionflagstalt_selft super_methodtparsertwant_doctgot_doc((s9/usr/lib64/python2.6/site-packages/lxml/doctestcompare.pyR&Ws$    cCs³d}t|@odSt|@o t}n…t|@o ti}nm|iƒiƒi dƒo |iƒi dƒo t}n1|i |ƒo |i |ƒo|i ƒ}n|S(NsRDR?(R telR((s9/usr/lib64/python2.6/site-packages/lxml/doctestcompare.pythtml_empty_tagÚsRNcCsIg}t|ƒpÖ|id|ƒ|i|ƒ|i|i|ƒƒ|i||ƒpGt|iƒo|i|i|iƒƒn|i|i|ƒƒnt|iƒo|i|i|iƒƒn|idƒdi |ƒS|id|ƒ|i|ƒ|i|i|ƒƒ|i||ƒpÁ|idƒt|iƒo;|id|ƒ|i|i|iƒƒ|idƒnx.|D]&}|i|i |||dƒƒqW|id|ƒ|i|i|ƒƒ|idƒnt|iƒo;|id|ƒ|i|i|iƒƒ|idƒndi |ƒS(NR s RNi( RDRXt format_tagRdR R>t format_texttformat_end_tagR@RZR[(R tdocRtindenttprefixtpartsRc((s9/usr/lib64/python2.6/site-packages/lxml/doctestcompare.pyR[äsB     $cCs9|djodS|o|iƒ}nti|dƒS(NRNi(RR tcgiRP(R R>R ((s9/usr/lib64/python2.6/site-packages/lxml/doctestcompare.pyRfs  cCs”g}t|tiƒodSxFt|iiƒƒD]/\}}|id||i|tƒfƒq4W|p d|i Sd|i di |ƒfS(Nss(RSRRmR<(R Rc((s9/usr/lib64/python2.6/site-packages/lxml/doctestcompare.pyRgscCség}t|ƒ oÁt|ƒ o³|id|ƒ|i|i||ƒƒ|i||ƒp<|i|i|i|iƒƒ|i|i||ƒƒn|i|i|i|iƒƒ|idƒdi|ƒS|id|ƒ|i|i||ƒƒ|idƒt |iƒpt |iƒoA|id|ƒ|i|i|i|iƒƒ|idƒnt |ƒ}t |ƒ}x¼|p|o­|p3|i|i |i dƒ||ddƒƒqˆn|p3|i|i |i dƒ||ddƒƒqˆn|i|i |i dƒ|i dƒ||dƒƒqˆW|id|ƒ|i|i||ƒƒ|idƒt |iƒpt |iƒoA|id|ƒ|i|i|i|iƒƒ|idƒndi|ƒS(NR s RNiit-t+(RDRXtcollect_diff_tagRdtcollect_diff_textR>tcollect_diff_end_tagR@RZR RER[RFR\(R R+R,RRiRkRJRK((s9/usr/lib64/python2.6/site-packages/lxml/doctestcompare.pyR\sJ     ,, .  c Cs¼|i|i|iƒpd|i|if}n |i}g}|idjp d|ij}x»t|iiƒƒD]¤\}}||ijo/| o'|id||i|tƒfƒqw||ijo |i||i|tƒ}n|i|tƒ}|id||fƒqwW|pdxat|iiƒƒD]F\}}||ijoq<n|id||i|tƒfƒq<Wn|od|di |ƒ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<RARBRnRXRfR)RtRZ( R R+R,R<RoR:RpR`R>((s9/usr/lib64/python2.6/site-packages/lxml/doctestcompare.pyRsEs.  '  + cCs>|i|ijod|i|if}n |i}d|S(Ns %s (got: %s)s(R<(R R+R,R<((s9/usr/lib64/python2.6/site-packages/lxml/doctestcompare.pyRu`s cCsS|i|||ƒo|pdS|i||ƒSd||f}|i||ƒS(NRNs %s (got: %s)(R=Rf(R R+R,R R>((s9/usr/lib64/python2.6/site-packages/lxml/doctestcompare.pyRtgs ( RRRRRsinputsbaseRslinkR(t__name__t __module__RbR!R&R'R5R*R=R;RYR?RdR[RfReRgR\RsRuRt(((s9/usr/lib64/python2.6/site-packages/lxml/doctestcompare.pyRNs&       ! #   &  cBseZd„ZRS(cCstS(N(R(R ((s9/usr/lib64/python2.6/site-packages/lxml/doctestcompare.pyR!ps(RvRwR!(((s9/usr/lib64/python2.6/site-packages/lxml/doctestcompare.pyRoscCs!|o tt_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.6/site-packages/lxml/doctestcompare.pyRss c Cs±|o t}nt}tƒ}|id}|ƒ}|i}||_to |idi}|ii}n|idi}|ii}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_selftcheckert old_checkert check_functchecker_check_func((s9/usr/lib64/python2.6/site-packages/lxml/doctestcompare.pyRs"         R€cBsPeZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z RS(cCs`||_||_|i|i_||i_||_||_||_|iƒ|i ƒdS(N( R„R…t call_superR$R"R‡t clone_funcRt install_clonetinstall_dt_self(R R„R†t new_checkerR‡RŠR((s9/usr/lib64/python2.6/site-packages/lxml/doctestcompare.pyt__init__§s       cCsoto4|ii|_|ii|_|ii|i_n1|ii|_|ii|_|ii|i_dS(N(R}R‡t__code__t func_codet __globals__t func_globalsRŠ(R ((s9/usr/lib64/python2.6/site-packages/lxml/doctestcompare.pyR‹²scCs-to|i|i_n|i|i_dS(N(R}RR‡R(R ((s9/usr/lib64/python2.6/site-packages/lxml/doctestcompare.pytuninstall_clone»scCs|ii|_||i_dS(N(R„t_DocTestRunner__record_outcomet prev_func(R ((s9/usr/lib64/python2.6/site-packages/lxml/doctestcompare.pyRŒÀscCs|i|i_dS(N(R•R„R”(R ((s9/usr/lib64/python2.6/site-packages/lxml/doctestcompare.pytuninstall_dt_selfÃscCst|iofddk}|i|i=d|ijo9|iiddƒ\}}|i|}t||ƒqpndS(Niÿÿÿÿt.i(RRVtmodulestrsplittdelattr(R RVtpackagetmodulet package_mod((s9/usr/lib64/python2.6/site-packages/lxml/doctestcompare.pytuninstall_moduleÅs    cOsF|iƒ|iƒ|i`|i`|i||Ž}|iƒ|S(N(R“R–R…R"R$R•Rž(R targstkwtresult((s9/usr/lib64/python2.6/site-packages/lxml/doctestcompare.pyt__call__Ís     cOs0|iƒz|i||ŽSWd|iƒXdS(N(R“R‡R‹(R RŸR ((s9/usr/lib64/python2.6/site-packages/lxml/doctestcompare.pyR‰Õs ( RvRwRŽR‹R“RŒR–RžR¢R‰(((s9/usr/lib64/python2.6/site-packages/lxml/doctestcompare.pyR€¦s     cCs^ddk}|idƒ}x0|o(|i}d|jo|S|i}qWtdƒ‚dS(NiÿÿÿÿitBOOMsBCould not find doctest (only use this function *inside* a doctest)(RVt _getframeR{tf_backt LookupError(RVRƒtl((s9/usr/lib64/python2.6/site-packages/lxml/doctestcompare.pyRzÜs   si >>> temp_install() >>> print """stuff""" ... >>> print """""" >>> print """blahblahblah""" # doctest: +NOPARSE_MARKUP, +ELLIPSIS ...foo /> tbasict__main__()t__doc__tlxmlRRVRORxRlt__all__t basestringRTt NameErrortstrtbytest version_infoR}tregister_optionflagRRRR%R Rt HTMLParserR)R?RRtcompileR7R RRRRRtobjectR€Rzt__test__Rvttestmod(((s9/usr/lib64/python2.6/site-packages/lxml/doctestcompare.pyt$sD          ÿ" '6