%PDF- %PDF-
Mini Shell

Mini Shell

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

�
|��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
dZ5e5e/ks~t6�ej7d 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�}tdk	s1td��t|}|jd||f�|jd�tjdddd|gd	tj	d
tj	dt
��}|j�\}}t|�}tj
|�}|j�}	x�|j�D]�\}
}|
j�dkrt|j�d
�dkrq�n|
j�dkr7q�n|
j�dkr^|jd�r^q�n|jd|
|f�q�Wg|	j�D]}|j�r�|^q�}
x|
D]}|j|d�q�W|r�|jd|�n|jd�|j�}tjj|�s4t|d�}|j|�|j�njt|d�}|j�}|j�t||�s�d|GHddGH|GHddGHdGHddGH|GHndS(Ns.htmlsNo default_app sets9<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(RDRR9tNonetAssertionErrorR: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.pytshowosf		
	
	
		.	+
	



				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.pyR\�s

cCs�|jd�r|d}n|j�}g}x=|D]5}|j�dkr]|jd�q5|j|�q5Wdj|�d}|S(Ns
it.R
(RVRtrstriptappendR(RRet	new_linesRf((sK/opt/alt/python27/lib/python2.7/site-packages/paste/debug/doctest_webapp.pytconvert_docstring_string�s

cCs*t|�}t||�t||�dS(N(Rwt
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(
RwRZRNR[RR#R'RYtunlinkR(R'RyRRhtpyc_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'RBRLRZRR[Rtstr2htmltdarktcgiRlRxRD(R'RyRRtextRhthtml((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tFalseRROR(tinputtformatRRRRg((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?tabspathRYtmakedirsRZRNR[(R'RR+Rh((sK/opt/alt/python27/lib/python2.7/site-packages/paste/debug/doctest_webapp.pyRx�s
cCs�ttjj|�d�}|j�}|j�xh|D]`\}}}|dkrf|g|||+q8|dkr�g|||+q8ds8td|��q8Wt|d�}|jdj|��|j�dS(NRItinserttdeleteisUnknown change_type: %rRHR
(	RZR#R'R�t	readlinesR[RMRNR(R'tchangesRhRetchange_typeRfRq((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.iRsitwants *$i����tmsgN(tgrouptlenRUt
_check_prefixt_check_prompt_blankRRLRktmatcht
_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_indentRRUt_EXAMPLE_REtfinditerRutstarttcountR�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__Rktcompilet	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(8R�RR�R#R@R)RkR�RPt	cStringIORt
paste.utilRR'R�t__file__thereR?R(RRR�RRR,RLR5R9R:R=RDRjR\RwRzRRR�RxR�t
DocTestParserR�R�targvttestmodtexitRuR7RAttestfiletELLIPSIStREPORT_ONLY_FIRST_FAILURERBtnewRMtsystem(((sK/opt/alt/python27/lib/python2.7/site-packages/paste/debug/doctest_webapp.pyt<module>sb	!			
				6		
						� 

	


Zerion Mini Shell 1.0