Ñò ‰»&Qc@s¿dZyddkZWn#ej oddklZnXddkZddkZddkZddkZddk Z ddk Z ddk Z ddk l Z ddklZeiieƒZeiieiieiieƒƒƒZd„Zd„Zed„Zd „Zd „Zded d „Zdadad „Zd„Z d„Z!d„Z"d„Z#d„Z$d„Z%ddd„Z&d„Z'd„Z(d„Z)dei*fd„ƒYZ+e,djoòei-do,ei-ddjoei.ƒei/ƒneeijoeii0eƒnx‘ei-dD]~Z1eiie1ƒZ1e1e_2ei3e1dedei4ei5Bde+ƒƒeii6e1ƒd d Z7ei8d!e1e7fƒq5WndS("s> These are functions for use when doctest-testing a document. iÿÿÿÿN(t subprocess24(tStringIO(t PySourceColorcCs t|ƒ}|o |GHndS(N(trun_raw(tcommandtdata((s>/usr/lib/python2.6/site-packages/paste/debug/doctest_webapp.pytruns c CsÊti|dtdtidtidtƒƒ}|iiƒ}|iƒx/|i dƒp|i dƒo|d }qLW|o@di g}|i ƒD]}|o ||q™q™~ƒ}|SdSd S( s6 Runs the string command, returns any output. tshelltstderrtstdouttenvs s iÿÿÿÿtN( t subprocesstPopentTruetSTDOUTtPIPEt _make_envR treadtwaittendswithtjoint splitlines(RtprocRt_[1]tl((s>/usr/lib/python2.6/site-packages/paste/debug/doctest_webapp.pyR"s   5cCsPt|ƒ}d||f}td|ddd|ƒ|o|o |GHndS(Ns$ %s %ss shell-commandt descriptionsshell transcriptR(Rt show_file(Rtnamet and_printtoutputR((s>/usr/lib/python2.6/site-packages/paste/debug/doctest_webapp.pyt run_command4s  cCs~tiiƒ}|iddƒdtiitdƒdtiitddddƒ|d<|iddƒdt|d<|S( NtPATHR t:tscriptstpastes 3rd-partyssqlobject-filest PYTHONPATH(tostenvirontcopytgettpathRt paste_parent(R ((s>/usr/lib/python2.6/site-packages/paste/debug/doctest_webapp.pyR<s <cCsti|tƒdS(s. Clears (deletes) the given directory N(tshutiltrmtreeR(tdir((s>/usr/lib/python2.6/site-packages/paste/debug/doctest_webapp.pyt clear_dirIsic Cs¿|p tiƒ}ti|ƒ}|iƒxŒ|D]„}tii||ƒ}tii|ƒo|d}nd||GHtii|ƒo(|o!td|dtd|dƒq3q3WdS(s" Show a directory listing t/t R-trecursetindentiN( R%tgetcwdtlistdirtsortR)RtisdirtlsR(R-R1R2tfnstfntfull((s>/usr/lib/python2.6/site-packages/paste/debug/doctest_webapp.pyR7Os  cCs|a|adS(N(t default_appt default_url(tappturl((s>/usr/lib/python2.6/site-packages/paste/debug/doctest_webapp.pytset_default_appascCsGtiitiitiƒdtiitiitiƒƒd|ƒS(sj Returns the filename of the resource -- generally in the directory resources/DocumentName/fn t resourcesi(R%R)Rtdirnametsysttesting_document_filenametsplitexttbasename(R9((s>/usr/lib/python2.6/site-packages/paste/debug/doctest_webapp.pytresource_filenamegs  "c Cs¥t|dƒ}tƒ}t|}|id||fƒ|idƒtidddd|gdtid tid tƒƒ}|iƒ\}}t|ƒ}t i |ƒ}|i ƒ} x¬|i ƒD]ž\} } | i ƒd jo$t| iƒd ƒd joqÇn| i ƒdjoqÇn| i ƒdjo| idƒoqÇn|id| | fƒqÇWg} | iƒD]} | iƒo | | qzqz~ }x|D]}|i|dƒq¨W|o|id|ƒn|idƒ|iƒ}tii|ƒp*t|dƒ}|i|ƒ|iƒnmt|dƒ}|i ƒ}|iƒt||ƒp7d|GHddGH|GHddGHdGHddGH|GHndS(Ns.htmls9%s
s
tpastersserve--server=consoles --no-verboses--url=RR R tstatusiiÈs content-typescontent-lengths set-cookiet_SID_s/%s: %s
s s$
%s
s
twbtrbs'Pages did not match. Expected from %s:t-i<t=sActual output:(s content-typescontent-length(RFRR<twriteR R RRt communicatetrfc822tMessageRtitemstlowertinttsplitt startswithRtstriptgetvalueR%R)texiststopentcloset html_matches(t path_infot example_nameR9toutR>RR terrorstheaderstcontenttheadertvalueRRtlinestlinetresulttftexpected((s>/usr/lib/python2.6/site-packages/paste/debug/doctest_webapp.pytshowrsf            0 8           cCsPti|ƒ}|iddƒ}tidd|ƒ}d|}ti||ƒS(Ns\.\.\.s.*s 0x[0-9a-f]+s^%s$(tretescapetreplacetsubtsearch(tpatternttexttregex((s>/usr/lib/python2.6/site-packages/paste/debug/doctest_webapp.pyR\¨s  cCs‰|idƒo|d}n|iƒ}g}x?|D]7}|iƒdjo|idƒq7|i|ƒq7Wdi|ƒd}|S(Ns it.R (RVRtrstriptappendR(RRet new_linesRf((s>/usr/lib/python2.6/site-packages/paste/debug/doctest_webapp.pytconvert_docstring_string¯s cCs*t|ƒ}t||ƒt||ƒdS(N(Rwt write_dataR(R)tversionR((s>/usr/lib/python2.6/site-packages/paste/debug/doctest_webapp.pyt create_file¼s  cCs•t|ƒ}t|dƒ}|i|ƒ|iƒ|idƒo2|d}tii|ƒoti|ƒqtnt ||dd|d|ƒdS(Ntas.pytcRs added to %sR( RwRZRNR[RR%R)RYtunlinkR(R)RyRRhtpyc_file((s>/usr/lib/python2.6/site-packages/paste/debug/doctest_webapp.pytappend_to_fileÁs    cCsÄtii|ƒd}|djo)t|dƒ}|iƒ}|iƒn|djodti|ti ƒ}ndt i |dƒ}d|p||f}t t d||fƒ|ƒdS(NiRKs.pys!
%s
s!
%s
s-%s
%ss%s.%s.gen.html(R%R)RDtNoneRZRR[Rtstr2htmltdarktcgiRlRxRF(R)RyRRtextRhthtml((s>/usr/lib/python2.6/site-packages/paste/debug/doctest_webapp.pyRÑs   cCsZtiddddd|gdtdtiƒ}|i|ƒ\}}|}|iƒ|S(Nssource-highlights--out-format=htmls--no-docs --css=nones --src-lang=%sRR (R R tFalseRROR(tinputtformatRR RRg((s>/usr/lib/python2.6/site-packages/paste/debug/doctest_webapp.pytcall_source_highlightás   cCsltiitii|ƒƒ}tii|ƒpti|ƒnt|dƒ}|i|ƒ|iƒdS(NRJ( R%R)RAtabspathRYtmakedirsRZRNR[(R)RR-Rh((s>/usr/lib/python2.6/site-packages/paste/debug/doctest_webapp.pyRxìs  cCs½ttii|ƒdƒ}|iƒ}|iƒxV|D]N\}}}|djo|g|||+q8|djog|||+q8q8Wt|dƒ}|idi|ƒƒ|iƒdS(NRKtinserttdeleteRJR (RZR%R)RŠt readlinesR[RNR(R)tchangesRhRet change_typeRfRq((s>/usr/lib/python2.6/site-packages/paste/debug/doctest_webapp.pyt change_fileõs    tLongFormDocTestParsercBs?eZdZeideieiBƒZd„Zdd„Z RS(s This parser recognizes some reST comments as commands, without prompts or expected output, like: .. run: do_this(... ...) s³ # Source consists of a PS1 line followed by zero or more PS2 lines. (?: (?P (?:^(?P [ ]*) >>> .*) # PS1 line (?:\n [ ]* \.\.\. .*)*) # PS2 lines \n? # Want consists of any non-blank lines that do not start with PS1. (?P (?:(?![ ]*$) # Not a blank line (?![ ]*>>>) # Not a line starting with PS1 .*$\n? # But any other line )*)) | (?: # This is for longer commands that are prefixed with a reST # comment like '.. run:' (two colons makes that a directive). # These commands cannot have any output. (?:^\.\.[ ]*(?Prun):[ ]*\n) # Leading command/command (?:[ ]*\n)? # Blank line following (?P (?:(?P [ ]+)[^ ].*$) (?:\n [ ]+ .*)*) ) | (?: # This is for shell commands (?P (?:^(P [ ]*) [$] .*) # Shell line (?:\n [ ]* [>] .*)*) # Continuation \n? # Want consists of any non-blank lines that do not start with $ (?P (?:(?![ ]*$) (?![ ]*[$]$) .*$\n? )*)) c Cs*|idƒpd}t|id|ƒƒ}|id|ƒidƒ}|o"|i|dd|||ƒn9|i||||ƒ|i|dd|d ||ƒ|o2dig}|D]}|||qÄ~ƒ} n3dig} |D]}| ||d qö~ ƒ} |od} d} nØ|id ƒ} | idƒ} t| ƒdjo"tid | d ƒo | d =n|i| d|||t|ƒƒdig}| D]}|||q¶~ƒ} |i i| ƒ}|o|idƒ} nd} |i | ||ƒ}| || | fS(s? Given a regular expression match from `_EXAMPLE_RE` (`m`), return a pair `(source, want)`, where `source` is the matched example's source code (with prompts and indentation stripped); and `want` is the example's expected output (with indentation stripped). `name` is the string's name, and `lineno` is the line number where the example starts; both are used for error messages. >>> def parseit(s): ... p = LongFormDocTestParser() ... return p._parse_example(p._EXAMPLE_RE.search(s), '', 1) >>> parseit('>>> 1\n1') ('1', {}, '1', None) >>> parseit('>>> (1\n... +1)\n2') ('(1\n+1)', {}, '2', None) >>> parseit('.. run:\n\n test1\n test2\n') ('test1\ntest2', {}, '', None) RR s%sindents%ssources iR0iRsitwants *$iÿÿÿÿtmsgN( tgrouptlenRUt _check_prefixt_check_prompt_blankRR€Rktmatcht _EXCEPTION_REt _find_options(tselftmRtlinenotrunnerR2t source_linesRtsltsourcet_[2]R“texc_msgt want_linest_[3]twltoptions((s>/usr/lib/python2.6/site-packages/paste/debug/doctest_webapp.pyt_parse_example5s4""22 * .scCs—|iƒ}|i|ƒ}|djo;dig}|idƒD]}|||qB~ƒ}ng}d\}}x |ii|ƒD]ö} |i||| iƒ!ƒ||id|| iƒƒ7}|i | ||ƒ\} } } } |i | ƒpU|it i | | | d|d|t | idƒp | idƒƒd| ƒƒn||id| iƒ| iƒƒ7}| iƒ}qˆW|i||ƒ|S(s= Divide the given string into examples and intervening text, and return them as a list of alternating Examples and strings. Line numbers for the Examples are 0-based. The optional argument `name` is a name identifying this string, and is only used for error messages. is RžR2t runindentR¨(ii(t expandtabst _min_indentRRUt _EXAMPLE_REtfinditerRutstarttcountR©t_IS_BLANK_OR_COMMENTtdoctesttExampleR–R•tend(RœtstringRt min_indentRRRtcharnoRžRR¢R¨R“R¤((s>/usr/lib/python2.6/site-packages/paste/debug/doctest_webapp.pytparsews*  ; !  )%( t__name__t __module__t__doc__Rktcompilet MULTILINEtVERBOSER­R©R¸(((s>/usr/lib/python2.6/site-packages/paste/debug/doctest_webapp.pyR’s  " Bt__main__iR²tmodule_relativet optionflagstparsers.htmlsrst2html.py %s > %s(9R»R t ImportErrort paste.utilRR²R%RBR+RkRƒRPt cStringIORRR)RŠt__file__thereRAR*RRR†RRR.R€R7R;R<R?RFRjR\RwRzRRR‰RxR‘t DocTestParserR’R¹targvttestmodtexitRuR9RCttestfiletELLIPSIStREPORT_ONLY_FIRST_FAILURERDtnewtsystem(((s>/usr/lib/python2.6/site-packages/paste/debug/doctest_webapp.pytsh        !      6     "