Ñò ‰»&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,djoei-do,ei-ddjoei.ƒei/ƒneeijoeii0eƒnx¥ei-dD]’Z1eiie1ƒZ1e1e_2ei3e1dedei4ei5Bde+ƒƒeii6e1ƒd d Z7e7e1jpt8‚ei9d!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ƒ}tdj p td‚t|}|id||fƒ|idƒtidddd|gd ti d ti d t ƒƒ}|i ƒ\}}t|ƒ}t i |ƒ}|iƒ} x¬|iƒD]ž\} } | iƒd jo$t| iƒd ƒdjoqÞn| iƒdjoqÞn| iƒdjo| idƒoqÞn|id| | fƒqÞWg} | iƒD]} | iƒo | | q‘q‘~ }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.htmlsNo default_app sets9%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;tNonetAssertionErrorR<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.pytshowrsj            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 (RXRtrstriptappendR(RRgt new_linesRh((s>/usr/lib/python2.6/site-packages/paste/debug/doctest_webapp.pytconvert_docstring_string¯s cCs*t|ƒ}t||ƒt||ƒdS(N(Ryt 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( RyR\RPR]RR%R)R[tunlinkR(R)R{RRjtpyc_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)RDRNR\RR]Rtstr2htmltdarktcgiRnRzRF(R)R{RRtextRjthtml((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 tFalseRRQR(tinputtformatRR RRi((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)RAtabspathR[tmakedirsR\RPR](R)RR-Rj((s>/usr/lib/python2.6/site-packages/paste/debug/doctest_webapp.pyRzìs  cCsÒttii|ƒdƒ}|iƒ}|iƒxk|D]c\}}}|djo|g|||+q8|djog|||+q8dptd|‚q8Wt|dƒ}|idi|ƒƒ|iƒdS(NRKtinserttdeleteisUnknown change_type: %rRJR ( R\R%R)R‹t readlinesR]RORPR(R)tchangesRjRgt change_typeRhRs((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 iR0iRuitwants *$iÿÿÿÿtmsgN( tgrouptlenRWt _check_prefixt_check_prompt_blankRRNRmtmatcht _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_indentRRWt _EXAMPLE_REtfinditerRwtstarttcountRªt_IS_BLANK_OR_COMMENTtdoctesttExampleR—R–tend(RtstringRt min_indentRRRtcharnoRŸRžR£R©R”R¥((s>/usr/lib/python2.6/site-packages/paste/debug/doctest_webapp.pytparsews*  ; !  )%( t__name__t __module__t__doc__Rmtcompilet 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(:R¼R t ImportErrort paste.utilRR³R%RBR+RmR„RRt cStringIORRR)R‹t__file__thereRAR*RRR‡RRR.RNR7R;R<R?RFRlR^RyR|RRRŠRzR’t DocTestParserR“RºtargvttestmodtexitRwR9RCttestfiletELLIPSIStREPORT_ONLY_FIRST_FAILURERDtnewROtsystem(((s>/usr/lib/python2.6/site-packages/paste/debug/doctest_webapp.pytsj        !      6     "