
+e|Mc           @   s  d  Z  d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k	 Z	 d d k
 Z
 d d k Z d d k l Z y d d k l Z Wn# e j
 o d d k l Z n Xd d k Z y d d k Z Wn# e j
 o d d k l Z n Xd d k l Z d d k l Z d d k l Z d	   Z d
 e f d     YZ d   Z d e f d     YZ d e f d     YZ  d e f d     YZ! d e f d     YZ" d e f d     YZ# d e f d     YZ$ d e f d     YZ% e i& d e i'  Z( d   Z) d e f d     YZ* d e* f d      YZ+ e+ e* i, d! <d" e+ f d#     YZ- e- e* i, d$ <d% e* f d&     YZ. e. e* i, d' <d( e* f d)     YZ/ e/ e* i, d* <d+ e/ f d,     YZ0 e0 e* i, d- <d. e/ f d/     YZ1 e1 e* i, d0 <d1 e* f d2     YZ2 e2 e* i, d3 <e2 e* i, d4 <e2 e* i, d5 <d6 e f d7     YZ3 d8 e f d9     YZ4 d: e f d;     YZ5 d< e f d=     YZ6 e7 d>  Z8 e7 e7 e9 d?  Z: d@   Z; e7 dA  Z< dB   Z= d S(C   s  
Routines for testing WSGI applications.

Most interesting is the `TestApp <class-paste.fixture.TestApp.html>`_
for testing WSGI applications, and the `TestFileEnvironment
<class-paste.fixture.TestFileEnvironment.html>`_ class for testing the
effects of command-line scripts.
iN(   t
   BaseCookie(   t   StringIO(   t   subprocess24(   t   wsgilib(   t   lint(   t
   HeaderDictc          G   s   t  i |    S(   s   
    An os.tempnam with the warning turned off, because sometimes
    you just need to use this and don't care about the stupid
    security warning.
    (   t   ost   tempnam(   t   args(    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt   tempnam_no_warning&   s    t	   NoDefaultc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR
   .   s   c         C   s   t  |   }  |  i   |  S(   N(   t   listt   sort(   t   l(    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt   sorted1   s    
t   Dummy_smtplibc           B   sG   e  Z d Z d    Z d   Z d   Z d   Z e e  Z d   Z	 RS(   c         C   sV   d d  k  } | i d t d  |  i p
 t d  | |  _ t |  _ |  |  i _ d  S(   Nis1   Dummy_smtplib is not maintained and is deprecatedi   sI   smtplib.SMTP() called again before Dummy_smtplib.existing.reset() called.(	   t   warningst   warnt   DeprecationWarningt   existingt   AssertionErrort   servert   Truet   opent	   __class__(   t   selfR   R   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt   __init__:   s    
		c         C   s%   |  i  p t d |   t |  _  d  S(   Ns   Called %s.quit() twice(   R   R   t   False(   R   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt   quitF   s    c         C   s   | |  _  | |  _ | |  _ d  S(   N(   t   from_addresst   to_addressest   message(   R   R   R    t   msg(    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt   sendmailK   s    		c         C   s   |  t  _ d  S(   N(   t   smtplibt   SMTP(   t   cls(    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt   installP   s    c         C   s%   |  i  p
 t d  d  |  i _ d  S(   Ns   SMTP connection not quit(   R   R   t   NoneR   R   (   R   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt   resetU   s    N(
   R   R   R(   R   R   R   R#   R'   t   classmethodR)   (    (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR   6   s   				t   AppErrorc           B   s   e  Z RS(    (   R   R   (    (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR+   Z   s   t   TestAppc           B   s   e  Z e Z d d d d d d   Z d   Z d   Z d d d d e d  Z	 d d d d d e d  Z
 d d d d d e d  Z d d d d d e d  Z d d d d e d  Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z RS(   c         C   s   t  | t t f  o& d d k l } | | d | } n | |  _ | |  _ | |  _ | d j o
 h  } n | |  _	 | |  _
 | |  _ |  i   d S(   s}  
        Wraps a WSGI application in a more convenient interface for
        testing.

        ``app`` may be an application, or a Paste Deploy app
        URI, like ``'config:filename.ini#test'``.

        ``namespace`` is a dictionary that will be written to (if
        provided).  This can be used with doctest or some other
        system, and the variable ``res`` will be assigned everytime
        you make a request (instead of returning the request).

        ``relative_to`` is a directory, and filenames used for file
        uploads are calculated relative to this.  Also ``config:``
        URIs that aren't absolute.

        ``extra_environ`` is a dictionary of values that should go
        into the environment for each request.  These can provide a
        communication channel with the application.

        ``pre_request_hook`` is a function to be called prior to
        making requests (such as ``post`` or ``get``). This function
        must take one argument (the instance of the TestApp).

        ``post_request_hook`` is a function, similar to
        ``pre_request_hook``, to be called after requests are made.
        i(   t   loadappt   relative_toN(   t
   isinstancet   strt   unicodet   paste.deployR-   t   appt	   namespaceR.   R(   t   extra_environt   pre_request_hookt   post_request_hookR)   (   R   R3   R4   R.   R5   R6   R7   R-   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR   b   s    			
			c         C   s   h  |  _  d S(   sc   
        Resets the state of the application; currently just clears
        saved cookies.
        N(   t   cookies(   R   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR)      s    c         C   s   |  i  i   } t | d <| S(   Ns   paste.throw_errors(   R5   t   copyR   (   R   t   environ(    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt   _make_environ   s    
c   
      C   s  | d j o
 h  } n t } | ob t | t t f  p t i | d t } n d | j o | d 7} n | d 7} | | 7} n |  i   } t |  } d | j o  | i d d  \ } | d <n d | d <|  i	 | |  | i
 |  t | | |  }	 |  i |	 d | S(	   s  
        Get the given url (well, actually a path like
        ``'/page.html'``).

        ``params``:
            A query string, or a dictionary that will be encoded
            into a query string.  You may also include a query
            string on the ``url``.

        ``headers``:
            A dictionary of extra headers to send.

        ``extra_environ``:
            A dictionary of environmental variables that should
            be added to the request.

        ``status``:
            The integer status code you expect (if not 200 or 3xx).
            If you expect a 404 response, for instance, you must give
            ``status=404`` or it will be an error.  You can also give
            a wildcard, like ``'3*'`` or ``'*'``.

        ``expect_errors``:
            If this is not true, then if anything is written to
            ``wsgi.errors`` it will be an error.  If it is true, then
            non-200/3xx responses are also okay.

        Returns a `response object
        <class-paste.fixture.TestResponse.html>`_
        t   doseqt   ?t   &i   t   QUERY_STRINGt    t   statusN(   R(   R   R/   R0   R1   t   urllibt	   urlencodeR;   t   splitt   _set_headerst   updatet   TestRequestt
   do_request(
   R   t   urlt   paramst   headersR5   RA   t   expect_errorst   __tracebackhide__R:   t   req(    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt   get   s&     

 
R@   c	         C   s  | d j o
 h  } n | d j o
 h  } n |  i   }	 t | t t t f  o t i |  } n t | d  o t i | i	    } n | o; t
 i | d t } |  i | |  \ }
 } |
 |	 d <n | o |	 i d d  n d | j o  | i d d  \ } |	 d <n d |	 d <t t |   |	 d	 <| |	 d
 <t |  |	 d <|  i | |	  |	 i |  t | |	 |  } |  i | d | S(   s'   
        Do a generic request.
        t   itemst   keep_blank_valuest   CONTENT_TYPEs!   application/x-www-form-urlencodedR=   i   R?   R@   t   CONTENT_LENGTHt   REQUEST_METHODs
   wsgi.inputRA   N(   R(   R;   R/   R   t   tuplet   dictRB   RC   t   hasattrRP   t   cgit	   parse_qslR   t   encode_multipartt
   setdefaultRD   R0   t   lenR   RE   RF   RG   RH   (   R   t   methodRI   RJ   RK   R5   RA   t   upload_filesRL   R:   t   content_typeRN   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt   _gen_request   s4    

 

c         C   s4   |  i  d | d | d | d | d | d | d | S(   s  
        Do a POST request.  Very like the ``.get()`` method.
        ``params`` are put in the body of the request.

        ``upload_files`` is for file uploads.  It should be a list of
        ``[(fieldname, filename, file_content)]``.  You can also use
        just ``[(fieldname, filename)]`` and the file content will be
        read from disk.

        Returns a `response object
        <class-paste.fixture.TestResponse.html>`_
        t   POSTRJ   RK   R5   RA   R^   RL   (   R`   (   R   RI   RJ   RK   R5   RA   R^   RL   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt   post   s    c         C   s4   |  i  d | d | d | d | d | d | d | S(   s  
        Do a PUT request.  Very like the ``.get()`` method.
        ``params`` are put in the body of the request.

        ``upload_files`` is for file uploads.  It should be a list of
        ``[(fieldname, filename, file_content)]``.  You can also use
        just ``[(fieldname, filename)]`` and the file content will be
        read from disk.

        Returns a `response object
        <class-paste.fixture.TestResponse.html>`_
        t   PUTRJ   RK   R5   RA   R^   RL   (   R`   (   R   RI   RJ   RK   R5   RA   R^   RL   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt   put  s    c         C   s4   |  i  d | d | d | d | d | d d d | S(	   s   
        Do a DELETE request.  Very like the ``.get()`` method.
        ``params`` are put in the body of the request.

        Returns a `response object
        <class-paste.fixture.TestResponse.html>`_
        t   DELETERJ   RK   R5   RA   R^   RL   N(   R`   R(   (   R   RI   RJ   RK   R5   RA   RL   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt   delete  s    	c         C   s   | p d Sn xz | i    D]l \ } } | i   d j o
 d } n: | i   d j o
 d } n d | i d d  i   } | | | <q Wd S(	   s9   
        Turn any headers into environ variables
        Ns   content-typeRR   s   content-lengthRS   s   HTTP_%st   -t   _(   RP   t   lowert   replacet   upper(   R   RK   R:   t   headert   valuet   var(    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyRE   +  s     

c         C   sD  d t  i    } g  } xP | D]H \ } } | i d |  | i d |  | i d  | i |  q Wx | D] } |  i |  \ } } } | i d |  | i d | | f  t i |  d }	 | i d |	 p d  | i d  | i |  qp W| i d | d  | i d  d	 i |  }
 d
 | } | |
 f S(   s   
        Encodes a set of parameters (typically a name/value list) and
        a set of files (a list of (name, filename, file_body)) into a
        typical POST body, returning the (content_type, body).
        s   ----------a_BoUnDaRy%s$s   --s)   Content-Disposition: form-data; name="%s"R@   s8   Content-Disposition: form-data; name="%s"; filename="%s"i    s   Content-Type: %ss   application/octet-streams   
s    multipart/form-data; boundary=%s(   t   randomt   appendt   _get_file_infot	   mimetypest
   guess_typet   join(   R   RJ   t   filest   boundaryt   linest   keyRm   t	   file_infot   filenamet   fcontentt   bodyR_   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyRZ   :  s0      		
c         C   s   t  |  d j oj | d } |  i o t i i |  i |  } n t | d  } | i   } | i   | d | | f Sn6 t  |  d j o | Sn t d t	 |  d    d  S(   Ni   i   t   rbi    i   su   upload_files need to be a list of tuples of (fieldname, filename, filecontent) or (fieldname, filename); you gave: %rid   (
   R\   R.   R   t   pathRt   R   t   readt   closet
   ValueErrort   repr(   R   Ry   Rz   t   ft   content(    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyRq   W  s    


c         C   s  |  i  o |  i  |   n t } |  i o t   } x' |  i i   D] \ } } | | | <qD Wd i g  } | i   D]" } | d i | i | i g  qu ~  }	 |	 | i	 d <n t | i	 d <h  | i	 d <t
 i |  i  }
 t i } t |  } zP | t _ t i   } | i } t i |
 | i d | | i	 } t i   } Wd | t _ t i i | i    X|  i | | |  } | | _ xU | i	 d i   D]@ \ } } t | |  o t d |   n t | | |  qW|  i d j	 o | |  i d	 <n | i p! |  i | |  |  i  |  n h  | _! x` | i" d
  D]O } t |  } x: | i   D], \ } } | i |  i | <| i | i! | <qcWqDW|  i# o |  i# |   n |  i d j o | Sn d S(   s   
        Executes the given request (``req``), with the expected
        ``status``.  Generally ``.get()`` and ``.post()`` are used
        instead.
        s   ; t   =t   HTTP_COOKIEs   paste.testings   paste.testing_variablest   raise_on_wsgi_errorNso   paste.testing_variables contains the variable %r, but the response object already has an attribute by that namet   ress
   set-cookie($   R6   R   R8   R    RP   Rt   t   valuesRx   Rm   R:   R   t
   middlewareR3   t   syst   stdoutt   CaptureStdoutt   timeRL   R   t   raw_interactiveRI   t   stderrt   writet   getvaluet   _make_responset   requestRW   R   t   setattrR4   R(   t   _check_statust   _check_errorst   cookies_sett   all_headersR7   (   R   RN   RA   RM   t   ct   nameRm   t   _[1]t   mt   hcR3   t
   old_stdoutt   outt
   start_timeR   t   raw_rest   end_timeR   Rl   Rx   t   morsel(    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyRH   j  sh    

	 E		
		 
	  
c         C   s  t  } | d j o d  Sn t | t t f  oV | i | j o> t d | i d i t t	 |   | i
 i | i f   n d  Sn | d  j oQ | i d j o | i d j  o d  Sn t d | i | i
 i | i f   n | | i j o t d | i | f   n d  S(   Nt   *s*   Bad response: %s (not one of %s for %s)
%ss   , i   i  s7   Bad response: %s (not 200 OK or 3xx redirect for %s)
%ss   Bad response: %s (not %s)(   R   R/   R   RU   RA   R+   t   full_statusRt   t   mapR0   R   RI   R|   R(   (   R   RA   R   RM   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR     s(     c         C   s%   | i  o t d | i    n d  S(   Ns!   Application had errors logged:
%s(   t   errorsR+   (   R   R   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR     s    
c         C   s+   | \ } } } } t  |  | | | | |  S(   N(   t   TestResponse(   R   t   .1t
   total_timeRA   RK   R|   R   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR     s    N(   R   R   R   t   disabledR(   R   R)   R;   R   RO   R`   Rb   Rd   Rf   RE   RZ   Rq   RH   R   R   R   (    (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR,   ]   s.   +			6	"							<		R   c           B   s5   e  Z d    Z d   Z d   Z d   Z d   Z RS(   c         C   s   t    |  _ | |  _ d  S(   N(   R   t   capturedt   actual(   R   R   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR     s    c         C   s$   |  i  i |  |  i i |  d  S(   N(   R   R   R   (   R   t   s(    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR     s    c         C   s   |  i  i   d  S(   N(   R   t   flush(   R   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR     s    c         C   s"   x | D] } |  i  |  q Wd  S(   N(   R   (   R   Rw   t   item(    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt
   writelines  s     c         C   s   |  i  i   S(   N(   R   R   (   R   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR     s    (   R   R   R   R   R   R   R   (    (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR     s
   				R   c           B   s2  e  Z e Z d    Z d   Z e e d d Z d   Z e e d d Z	 e
 i d e
 i e
 i B Z d   Z e d  Z d	   Z d
   Z d d d d d e d  Z d d d d d e d  Z d   Z d d  Z e
 i d  Z d   Z e e d d Z d   Z d   Z d   Z d   Z  d   Z! RS(   c         C   sz   | |  _  t | i   d  |  _ | |  _ | |  _ t i |  i  |  _ | |  _	 | |  _
 d  |  _ | |  _ d  |  _ d  S(   Ni    (   t   test_appt   intRD   RA   R   RK   R   t   fromlistt   header_dictR|   R   R(   t   _normal_bodyR   t   _forms_indexed(   R   R   RA   RK   R|   R   R   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR     s    							c         C   s%   |  i  d j o |  i   n |  i  S(   s   
        Returns a dictionary of ``Form`` objects.  Indexes are both in
        order (from zero) and by form id (if the form is given an id).
        N(   R   R(   t   _parse_forms(   R   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt
   forms__get  s    t   docs   
                     A list of <form>s found on the page (instances of
                     `Form <class-paste.fixture.Form.html>`_)
                     c         C   sE   |  i  } | p t d   n d | j o t d   n | d S(   Ns*   You used response.form, but no forms existi   s5   You used response.form, but more than one form existsi    (   t   formst	   TypeError(   R   R   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt	   form__get  s    	s   
                    Returns a single `Form
                    <class-paste.fixture.Form.html>`_ instance; it
                    is an error if there are multiple forms on the
                    page.
                    s   <(/?)([:a-z0-9_\-]*)(.*?)>c   
      C   sZ  h  } |  _  g  } d  } x |  i i |  i  D] } | i d  d j } | i d  i   } | d j o q/ n | oB | p t d | i    | i	 |  i | | i
   ! d  } q/ | p t d | i    | i   } q/ W| p t d |  i |  xN t |  D]@ \ } } t |  |  }	 |	 | | <|	 i o |	 | |	 i <qqWd  S(   Ni   t   /i   t   forms   </form> unexpected at %ss   Nested form tags at %ss   Danging form: %r(   R   R(   t   _tag_ret   finditerR|   t   groupRi   R   t   startRp   t   endt	   enumeratet   Formt   id(
   R   R   t
   form_textst   startedt   matchR   t   tagt   it   textR   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR     s2     

 

c   	   
   C   s   d } xY |  i D]N \ } } | i   | i   j o) | p t d | | | f  | } q q W| d j o\ | t j oG t d | d i g  } |  i D] \ } } | | q ~  f   q | Sn | S(   s   
        Returns the named header; an error if there is not exactly one
        matching header (unless you give a default -- always an error
        if there is more than one header)
        s&   Ambiguous header: %s matches %r and %rs   No header found: %r (from %s)s   , N(   R(   RK   Ri   R   R
   t   KeyErrorRt   (	   R   R   t   defaultt   foundt   cur_nameRm   R   t   nt   v(    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyRl   .  s    
 Ac         C   sN   g  } xA |  i  D]6 \ } } | i   | i   j o | i |  q q W| S(   sE   
        Gets all headers by the ``name``, returns as a list
        (   RK   Ri   Rp   (   R   R   R   R   Rm   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR   D  s    
 c         K   s}   |  i  d j o |  i  d j  p t d |  i  |  i d  } t i |  \ } } t i |  \ } } |  i i | |  S(   s   
        If this request is a redirect, follow that redirect.  It
        is an error if this is not a redirect response.  Returns
        another response object.
        i,  i  s/   You can only follow redirect responses (not %s)t   location(	   RA   R   R   Rl   RB   t	   splittypet	   splithostR   RO   (   R   t   kwR   t   typet   restt   hostR~   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt   followN  s    #c         C   sb   t  } |  i d d d d d d d | d | d | d	 | d
 | d |  	\ } }	 }
 |  i |
 d  S(   s  
        Click the link as described.  Each of ``description``,
        ``linkid``, and ``url`` are *patterns*, meaning that they are
        either strings (regular expressions), compiled regular
        expressions (objects with a ``search`` method), or callables
        returning true or false.

        All the given patterns are ANDed together:

        * ``description`` is a pattern that matches the contents of the
          anchor (HTML and all -- everything between ``<a...>`` and
          ``</a>``)

        * ``linkid`` is a pattern that matches the ``id`` attribute of
          the anchor.  It will receive the empty string if no id is
          given.

        * ``href`` is a pattern that matches the ``href`` of the anchor;
          the literal content of that attribute, not the fully qualified
          attribute.

        * ``anchor`` is a pattern that matches the entire anchor, with
          its contents.

        If more than one link matches, then the ``index`` link is
        followed.  If ``index`` is not given and more than one link
        matches, or if no link matches, then ``IndexError`` will be
        raised.

        If you give ``verbose`` then messages will be printed about
        each link, and why it does or doesn't match.  If you use
        ``app.click(verbose=True)`` you'll see a list of all the
        links.

        You can use multiple criteria to essentially assert multiple
        aspects about the link, e.g., where the link's destination is.
        R   t   at	   href_attrt   hreft   href_extractR   R   t   href_patternt   html_patternt   indext   verboset   uriN(   R   t   _find_elementR(   t   goto(   R   t   descriptiont   linkidR   t   anchorR   R   RM   t
   found_htmlt
   found_desct   found_attrs(    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt   click]  s    '	c         C   sk   t  } |  i d d d d d t i d  d | d | d	 | d
 | d | d |  	\ } }	 }
 |  i |
 d  S(   s   
        Like ``.click()``, except looks for link-like buttons.
        This kind of button should look like
        ``<button onclick="...location.href='url'...">``.
        R   t   buttonR   t   onclickR   s   location\.href='(.*?)'R   R   R   R   R   R   R   (   R   R   t   ret   compileR   (   R   R   t   buttonidR   R   R   R   RM   R   R   R   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt   clickbutton  s    	c
            sA  t  |  }
 t  |  } t  |  } t  |  } t i d | | f t i t i  }   f d   } g  } d } x| i |  i  D]} | i d  } | i d  } | i d  } t |  }   o | d |  n | i	 |  p | d |  q n | | } | o: | i
 |  } | p | d  q n | i d  } n | | d	 <| i d
  o | d  q n | i d  o | d  q n | d 7} |
 o |
 |  o | d  q n | o+ | | i	 d d   o | d  q n | o | |  o | d  q n | o | |  o | d  q n | d  | i | | | f  q W| p t d |   n | d  j oh t |  d j oG t d d i g  } | D] \ } } } | t |  q~    n | d } nD y | | } Wn2 t j
 o& t d t |  | | f   n X| S(   Ns   <%s\s+(.*?)>(.*?)</%s>c            s     o	 |  GHn d  S(   N(    (   R   (   R   (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt   printlog  s    i    i   i   s   Element: %rs     Skipped: no %s attributes(     Skipped: doesn't match extract patternR   t   #s&     Skipped: only internal fragment hrefs   javascript:s$     Skipped: cannot follow javascript:s$     Skipped: doesn't match descriptionR   R@   s     Skipped: doesn't match ids     Skipped: doesn't match hrefs     Skipped: doesn't match htmls
     Accepteds-   No matching elements found (from %s possible)s   Multiple links match: %ss   , s6   Only %s (out of %s) links match; index %s out of range(   t   _make_patternR   R   t   It   SR   R|   R   t   _parse_attrsRO   t   searcht
   startswithRp   t
   IndexErrorR(   R\   Rt   R   (   R   R   R   R   R   R   R   R   R   R   t   content_patt   id_patt   href_patt   html_patR   R   t   found_linkst   total_linksR   t   el_htmlt   el_attrt
   el_contentt   attrst   el_hrefR   R   t   anct   dt   attrt
   found_link(    (   R   s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR     s     






!



ARO   c   	      K   s   t  i |  \ } } } } } d } } } t  i | | | | | f  } t  i |  i i |  } | i   } | d j p t d |  | d j o |  i i	 } n |  i i
 } | | |  S(   s  
        Go to the (potentially relative) link ``href``, using the
        given method (``'get'`` or ``'post'``) and any extra arguments
        you want to pass to the ``app.get()`` or ``app.post()``
        methods.

        All hostnames and schemes will be ignored.
        R@   RO   Rb   s9   Only "get" or "post" are allowed for method (you gave %r)(   s   gets   post(   t   urlparset   urlsplitt
   urlunsplitt   urljoinR   t   full_urlRi   R   R   RO   Rb   (	   R   R   R]   R   t   schemeR   R~   t   queryt   fragment(    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR     s    	s
   [ \n\r\t]+c         C   s6   |  i  d  j o |  i i d |  i  |  _  n |  i  S(   Nt    (   R   R(   t   _normal_body_regext   subR|   (   R   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt   normal_body__get  s    	s]   
                           Return the whitespace-normalized body
                           c         C   sx   t  | t t f  p t |  } n t  | t  o | i d  } n |  i i |  d j p |  i i |  d j S(   s   
        A response 'contains' a string if it is present in the body
        of the response.  Whitespace is normalized when searching
        for a string.
        t   utf8i(   R/   R0   R1   t   encodeR|   t   findt   normal_body(   R   R   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt   __contains__  s    c         O   s   d | j o2 | d } | d =t  | t  o | g } qE n g  } | o t d   n xM | D]E } | |  j o2 t i d | IJt i |  IJt d |   qc qc WxM | D]E } | |  j o2 t i d | IJt i |  IJt d |   q q Wd S(   s   
        Assert that the response contains all of the strings passed
        in as arguments.

        Equivalent to::

            assert string in res
        t   nos)   The only keyword argument allowed is 'no's   Actual response (no %r):s   Body does not contain string %rs   Actual response (has %r)s   Body contains string %rN(   R/   t
   basestringR   R   R   R   (   R   t   stringsR   R  R   t   no_s(    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt   mustcontain!  s.    	
  c         C   s   d |  i  |  i d  f S(   Ns   <Response %s %r>i   (   R   R|   (   R   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt   __repr__A  s    c         C   s   d i  g  } |  i i   D] } | i   o | | q q ~  } d |  i d i  g  } |  i D] \ } } | d | | f qa ~  | f S(   Ns   
s   Response: %s
%s
%ss   %s: %s(   Rt   R|   t
   splitlinest   stripRA   RK   (   R   R   R   t   simple_bodyt   _[2]R   R   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt   __str__D  s     $:c         C   sr   d d k  } t d d  d } t | d  } | i |  i  | i   d | i t i	 d  } | i
 |  d S(   s{   
        Show this response in a browser window (for debugging purposes,
        when it's hard to read the HTML).
        iNs   paste-fixtures   .htmlt   wbs   file:R   (   t
   webbrowserR	   R(   R   R   R|   R   Rj   R   t   sept   open_new(   R   R*  t   fnR   RI   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt   showbrowserL  s    
N("   R   R   R   R   R   R   t   propertyR   R   R   R   R   R   R   R   R   R
   Rl   R   R   R(   R   R   R   R   R   R  R  R  R  R"  R#  R(  R.  (    (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR     s8   										
		1		M					 		RG   c           B   s   e  Z e Z e d   Z RS(   c         C   su   | i  d  o | t d  } n | |  _ | |  _ | i d  o | d | d |  _ n
 | |  _ | |  _ d  S(   Ns   http://localhostR?   R=   (   R   R\   RI   R:   RO   R  RL   (   R   RI   R:   RL   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR   s  s    			(   R   R   R   R   R   R   (    (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyRG   Y  s   R   c           B   s   e  Z d  Z e i d e i  Z d   Z d   Z d   Z	 d   Z
 d   Z d d  Z d e d  Z d d	  Z d d d
  Z d d d  Z RS(   s  
    This object represents a form that has been found in a page.
    This has a couple useful attributes:

    ``text``:
        the full HTML of the form.

    ``action``:
        the relative URI of the action.

    ``method``:
        the method (e.g., ``'GET'``).

    ``id``:
        the id, or None if not given.

    ``fields``:
        a dictionary of fields, each value is a list of fields by
        that name.  ``<input type="radio">`` and ``<select>`` are
        both represented as single fields with multiple options.
    s   <(/?)([:a-z0-9_\-]*)([^>]*?)>c         C   s*   | |  _  | |  _ |  i   |  i   d  S(   N(   t   responseR   t   _parse_fieldst   _parse_action(   R   R0  R   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR     s    		
c         C   sa  d  } d  } h  } x?|  i i |  i  D](} | i d  d j } | i d  i   } | d j o q( n | d j o2 | o+ | p t d	 | i d
   d  } q( n | d j oV | oO | p t d | i    t |  i | d | i   ! | d
 _	 d  } q( n | o q( n t
 | i d   } d | j o | i d  } n d  } | d j o, | i i | i d  d | j f  q( n | d j o | i d  d j o | i |  }	 |	 p; t |  | | | i   |  }	 | i | g   i |	  n" |	 d
 }	 t |	 t  p t  |	 i i | i d  d | j f  q( n | }
 | d j o | i d d  i   }
 n t i i |
 t  } | |  | | | i   |  }	 | d j o; | p t d | | i d
  f  |	 | i   f } n= | d j o/ | p t d | | i d
  f  |	 } n | i | g   i |	  q( W| |  _ d  S(   Ni   R   i   t   inputt   selectt   optiont   textareaR   s   %r without starting selecti    s$   </textarea> with no <textarea> at %si   R   Rm   t   selectedR   t   radiot   checkedR   s   Nested textareas: %r and %rs   Nested selects: %r and %r(   s   inputs   selects   optionR6  s   button(   R(   R   R   R   R   Ri   R   R   t   html_unquoteRm   R   t   popt   optionsRp   RO   t   RadioR[   R/   t   Fieldt   classesR   t   fields(   R   t	   in_selectt   in_textareaR@  R   R   R   R  R   t   fieldt   tag_typet
   FieldClass(    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR1    st     


'#

c         C   s   d  |  _ x |  i i |  i  D] } | i d  d j } | i d  i   } | d j o q n | o Pn t | i d   } | i d d  |  _ | i d d	  |  _	 | i d
  |  _
 q Wd p
 t d  |  i d  j	 p
 t d  d  S(   Ni   R   i   R   i   t   actionR@   R]   t   GETR   i    s   No </form> tag founds   No <form> tag found(   R(   RF  R   R   R   R   Ri   R   RO   R]   R   R   (   R   R   R   R   R  (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR2    s     	 c         C   s   |  i  i |  } | d j	 p/ t d | d i t t |  i  i     f  t |  d j p& t d | d i t t |   f  | | d _	 d S(   s  
        Set the value of the named field.  If there is 0 or multiple
        fields by that name, it is an error.

        Setting the value of a ``<select>`` selects the given option
        (and confirms it is an option).  Setting radio fields does the
        same.  Checkboxes get boolean values.  You cannot set hidden
        fields or buttons.

        Use ``.set()`` if there is any ambiguity and you must provide
        an index.
        s*   No field by the name %r found (fields: %s)s   , i   s   Multiple fields match %r: %si    N(
   R@  RO   R(   R   Rt   R   R   t   keysR\   Rm   (   R   R   Rm   R@  (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt   __setitem__  s    ) c         C   sn   |  i  i |  } | d j	 p t d |  t |  d j p& t d | d i t t |   f  | d S(   sE   
        Get the named field object (ambiguity is an error).
        s   No field by the name %r foundi   s   Multiple fields match %r: %ss   , i    N(   R@  RO   R(   R   R\   Rt   R   R   (   R   R   R@  (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt   __getitem__  s     c         C   s_   | d j o | |  | <nA |  i i |  } | d j	 p t d |  | | } | | _ d S(   sF   
        Set the given name, using ``index`` to disambiguate.
        s   No fields found matching %rN(   R(   R@  RO   R   Rm   (   R   R   Rm   R   R@  RC  (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt   set  s    
c         C   s   |  i  i |  } | d j o | t j	 o | Sn | d j o |  | Sn< |  i  i |  } | d j	 p t d |  | | } | Sd S(   sb   
        Get the named/indexed field object, or ``default`` if no field
        is found.
        s   No fields found matching %rN(   R@  RO   R(   R
   R   (   R   R   R   R   R@  RC  (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyRO   !  s    
c         C   s9   |  i  | d | } t | t  p t  | | _ d S(   s]   
        Like ``.set()``, except also confirms the target is a
        ``<select>``.
        R   N(   RO   R/   t   SelectR   Rm   (   R   R   Rm   R   RC  (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR4  2  s    c         K   s:   |  i  | d | } |  i i |  i d |  i d | | S(   s	  
        Submits the form.  If ``name`` is given, then also select that
        button (using ``index`` to disambiguate)``.

        Any extra keyword arguments are passed to the ``.get()`` or
        ``.post()`` method.

        Returns a response object.
        R   R]   RJ   (   t   submit_fieldsR0  R   RF  R]   (   R   R   R   R   R@  (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt   submit;  s    
c         C   s   g  } | d j	 o5 |  i | d | } | i | i | i   f  n xr |  i i   D]a \ } } | d j o qX n x> | D]6 } | i } | d j o q n | i | | f  q WqX W| S(   sf   
        Return a list of ``[(name, value), ...]`` for the current
        state of the form.
        R   N(   R(   RO   Rp   R   t   value_if_submittedR@  RP   Rm   (   R   R   R   RN  RC  R@  Rm   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyRM  I  s       	N(   R   R   t   __doc__R   R   R   R   R   R1  R2  RI  RJ  R(   RK  R
   RO   R4  RN  RM  (    (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR     s   		=				sH   ([^= \n\r\t]+)[ \n\r\t]*(?:=[ \n\r\t]*(?:"([^"]*)"|([^"][^ \n\r\t>]*)))?c         C   su   h  } xh t  i |   D]W } | i d  i   } | i d  p | i d  } t | p d  } | | | <q W| S(   Ni   i   i   R@   (   t   _attr_reR   R   Ri   R:  (   R   R  R   t	   attr_namet	   attr_body(    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR   _  s     R>  c           B   sS   e  Z d  Z h  Z e Z d d d  Z d   Z d   Z	 d   Z
 e e
 e  Z RS(   s   
    Field object.
    c         K   sC   | |  _  | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ d  S(   N(   R   R   R   t   post   _valueR   R  (   R   R   R   R   RT  Rm   R   R  (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR   s  s    						c         C   s7   |  i  p  t d |  i |  i f   n | |  _ d  S(   Ns-   You cannot set the value of the <%s> field %r(   t   settablet   AttributeErrorR   R   RU  (   R   Rm   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt
   value__set}  s
    
c         C   s   | |  _  d S(   s^   
        Like setting a value, except forces it even for, say, hidden
        fields.
        N(   RU  (   R   Rm   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt   force_value  s    c         C   s   |  i  S(   N(   RU  (   R   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt
   value__get  s    N(   R   R   RP  R?  R   RV  R(   R   RX  RY  RZ  R/  Rm   (    (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR>  h  s   				RL  c           B   s8   e  Z d  Z d   Z d   Z d   Z e e e  Z RS(   s)   
    Field representing ``<select>``
    c         O   sV   t  t |   i | |   g  |  _ | i d  |  _ |  i p
 t d  d  |  _ d  S(   Nt   multiples#   <select multiple> not yet supported(	   t   superRL  R   R<  RO   R[  R   R(   t   selectedIndex(   R   R   R  (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR     s    	c         C   s   x t  |  i  D]3 \ } \ } } | t |  j o | |  _ Pq q Wt d | d i g  } |  i D] \ } } | t |  qd ~  f   d  S(   Ns   Option %r not found (from %s)s   , (   R   R<  R0   R]  R   Rt   R   (   R   Rm   R   R5  R9  R   t   oR   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyRX    s     			c         C   st   |  i  d  j	 o |  i |  i  d SnK xG |  i D] \ } } | o | Sq0 q0 W|  i o |  i d d Sn d  Sd  S(   Ni    (   R]  R(   R<  (   R   R5  R9  (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyRZ    s    
 
(   R   R   RP  R   RX  RZ  R/  Rm   (    (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyRL    s
   				R4  R=  c           B   s   e  Z d  Z RS(   s5   
    Field representing ``<input type="radio">``
    (   R   R   RP  (    (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR=    s   R8  t   Checkboxc           B   s8   e  Z d  Z d   Z d   Z d   Z e e e  Z RS(   s8   
    Field representing ``<input type="checkbox">``
    c         O   s,   t  t |   i | |   d | j |  _ d  S(   NR9  (   R\  R_  R   R9  (   R   R   R  (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR     s    c         C   s   | |  _  d  S(   N(   R9  (   R   Rm   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyRX    s    c         C   s5   |  i  o# |  i d  j o d Sq1 |  i Sn d  Sd  S(   Nt   on(   R9  RU  R(   (   R   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyRZ    s
    
(   R   R   RP  R   RX  RZ  R/  Rm   (    (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR_    s
   				t   checkboxt   Textc           B   s   e  Z d  Z d d d  Z RS(   s4   
    Field representing ``<input type="text">``
    R@   c         K   s,   t  i |  | | | | d | d | | d  S(   NRm   R   (   R>  R   (   R   R   R   R   RT  Rm   R   R  (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR     s    N(   R   R   RP  R(   R   (    (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyRb    s   R   t   Textareac           B   s   e  Z d  Z RS(   s+   
    Field representing ``<textarea>``
    (   R   R   RP  (    (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyRc    s   R6  t   Hiddenc           B   s   e  Z d  Z RS(   s6   
    Field representing ``<input type="hidden">``
    (   R   R   RP  (    (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyRd    s   t   hiddent   Submitc           B   s2   e  Z d  Z e Z d   Z e e  Z d   Z RS(   sG   
    Field representing ``<input type="submit">`` and ``<button>``
    c         C   s   d  S(   N(   R(   (   R   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyRZ    s    c         C   s   |  i  S(   N(   RU  (   R   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyRO    s    (	   R   R   RP  R   RV  RZ  R/  Rm   RO  (    (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyRf    s
   	RN  R   t   imaget   TestFileEnvironmentc           B   sw   e  Z d  Z e Z d	 d	 d	 d	 e d	 e d  Z d   Z d   Z d   Z	 d   Z
 d   Z d   Z d	 d	 d  Z RS(
   se   
    This represents an environment in which files will be written, and
    scripts will be run.
    c	   	      C   s  | |  _  | |  _ | d j o t i i   } n | |  _ | d j oN t i d j o | i d d  i	 d  } q | i d d  i	 d  } n | |  _
 | d j o
 | } n | |  _ | o |  i   n% t i i |  p t i |  n | p g  |  _ | |  _ d S(   s  
        Creates an environment.  ``base_path`` is used as the current
        working directory, and generally where changes are looked for.

        ``template_path`` is the directory to look for *template*
        files, which are files you'll explicitly add to the
        environment.  This is done with ``.writefile()``.

        ``script_path`` is the PATH for finding executables.  Usually
        grabbed from ``$PATH``.

        ``environ`` is the operating system environment,
        ``os.environ`` if not given.

        ``cwd`` is the working directory, ``base_path`` by default.

        If ``start_clear`` is true (default) then the ``base_path``
        will be cleared (all files deleted) when an instance is
        created.  You can also use ``.clear()`` to clear the files.

        ``ignore_paths`` is a set of specific filenames that should be
        ignored when created in the environment.  ``ignore_hidden``
        means, if true (default) that filenames and directories
        starting with ``'.'`` will be ignored.
        t   win32t   PATHR@   t   ;t   :N(   t	   base_patht   template_pathR(   R   R:   R9   R   t   platformRO   RD   t   script_patht   cwdt   clearR~   t   existst   makedirst   ignore_pathst   ignore_hidden(	   R   Rm  Rn  Rp  R:   Rq  t   start_clearRu  Rv  (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR     s&    				
	c         O   s  t  } t | d t  } t | d |  } t | d |  i  } t | d d  } t | d t   }	 t t |  } | p t d d i | i	     d | j oG | p t d	 | | f  | i
 d d
  \ } } t i
 |  } n |  i |  } | g | }
 |  i   } t i |
 d t i d t i d t i d | d |  i } | i |  \ } } |  i   } t |  |
 | | | d | i d | d | } |	 o | GHd d GHn | p | i   n | p | i   n | S(   s  
        Run the command, with the given arguments.  The ``script``
        argument can have space-separated arguments, or you can use
        the positional arguments.

        Keywords allowed are:

        ``expect_error``: (default False)
            Don't raise an exception in case of errors
        ``expect_stderr``: (default ``expect_error``)
            Don't raise an exception if anything is printed to stderr
        ``stdin``: (default ``""``)
            Input to the script
        ``printresult``: (default True)
            Print the result after running
        ``cwd``: (default ``self.cwd``)
            The working directory to run in

        Returns a `ProcResponse
        <class-paste.fixture.ProcResponse.html>`_ object.
        t   expect_errort   expect_stderrRq  t   stdint   printresults   Arguments not expected: %ss   , R  s?   You cannot give a multi-argument script (%r) and arguments (%s)i   R   R   t   envt
   returncodet   files_beforet   files_afterRg   i(   N(   R   t   _popgetR   Rq  R(   R   R0   R   Rt   RH  RD   t   shlext	   _find_exet   _find_filest
   subprocesst   Popent   PIPER:   t   communicatet
   ProcResultR}  t   assert_no_errort   assert_no_stderr(   R   t   scriptR   R   RM   Rx  Ry  Rq  Rz  R{  t   allR~  t   procR   R   R  t   result(    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt   runM  sL    				c         C   s   |  i  d  j oG t i i |  i |  } t i i |  p t d |   n | Sn xA |  i  D]6 } t i i | |  } t i i |  o | Sqa qa Wt d | d i |  i   f   d  S(   Ns   Script %s does not exists"   Script %s could not be found in %sRl  (   Rp  R(   R   R~   Rt   Rq  Rs  t   OSError(   R   t   script_nameR~   R-  (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR    s    
 c         C   sN   h  } xA t  i |  i  D]- } |  i |  o q n |  i | |  q W| S(   N(   R   t   listdirRm  t   _ignore_filet   _find_traverse(   R   R  R-  (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR    s     c         C   sJ   | |  i  j o t Sn |  i o$ t i i |  i d  o t Sn t S(   Nt   .(   Ru  R   Rv  R   R~   t   basenameR   R   (   R   R-  (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR    s
    &c         C   s   t  i i |  i |  } t  i i |  op t |  i |  | | <xm t  i |  D]B } t  i i | |  } |  i |  o qQ n |  i | |  qQ Wn t	 |  i |  | | <d  S(   N(
   R   R~   Rt   Rm  t   isdirt   FoundDirR  R  R  t	   FoundFile(   R   R~   R  t   fullR-  (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR    s     c         C   s>   t  i i |  i  o t i |  i  n t  i |  i  d S(   s=   
        Delete all the files in the base directory.
        N(   R   R~   Rs  Rm  t   shutilt   rmtreet   mkdir(   R   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyRr    s    c         C   s   t  i i |  i |  } t  i i t  i i |   p t  i t  i i |   n t | d  } | d j	 o | i	 |  n | d j	 oV |  i
 o t  i i |  i
 |  } n t | d  } | i	 | i    | i   n | i   t |  i |  S(   s   
        Write a file to the given path.  If ``content`` is given then
        that text is written, otherwise the file in ``frompath`` is
        used.  ``frompath`` is relative to ``self.template_path``
        R)  R}   N(   R   R~   Rt   Rm  Rs  t   dirnameRt  R   R(   R   Rn  R   R   R  (   R   R~   R   t   frompathR  R   t   f2(    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt	   writefile  s    

N(   R   R   RP  R   R   R(   R   R  R  R  R  R  Rr  R  (    (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyRh    s   	/	=					R  c           B   s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   s  
    Represents the results of running a command in
    `TestFileEnvironment
    <class-paste.fixture.TestFileEnvironment.html>`_.

    Attributes to pay particular attention to:

    ``stdout``, ``stderr``:
        What is produced

    ``files_created``, ``files_deleted``, ``files_updated``:
        Dictionaries mapping filenames (relative to the ``base_dir``)
        to `FoundFile <class-paste.fixture.FoundFile.html>`_ or
        `FoundDir <class-paste.fixture.FoundDir.html>`_ objects.
    c	         C   s   | |  _  | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ h  |  _ h  |  _	 | i
   |  _ xq | i   D]c \ }	 }
 |	 | j o |
 |  i |	 <qv n |  i |	 =|
 i | |	 i j  o | |	 |  i	 |	 <qv qv Wd  S(   N(   t   test_envR   Rz  R   R   R}  R~  R  t   files_deletedt   files_updatedR9   t   files_createdRP   t   mtime(   R   R  R   Rz  R   R   R}  R~  R  R~   R   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR     s&    										 
c         C   s+   t  } |  i d j p t d |  i  d  S(   Ni    s   Script returned code: %s(   R   R}  R   (   R   RM   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR    s    c         C   s1   t  } |  i o d GH|  i GHt d   n d  S(   Ns   Error output:s   stderr output not expected(   R   R   R   (   R   RM   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR    s
    
c   	   
   C   s  d d i  |  i  g } |  i o | i d |  i  n |  i o! | i d  | i |  i  n |  i o! | i d  | i |  i  n x d |  i t f d |  i t f d |  i	 t f g D] \ } } } | o | i d	 |  | i
   } | i   d
 } xv | D]j \ } } d t | | d d d t } | } | o% | i d j o | d | i 7} n | i |  qWq q Wd i  |  S(   Ns   Script result: %sR  s     return code: %ss   -- stderr: --------------------s   -- stdout: --------------------t   createdt   deletedt   updateds   -- %s: -------------------R@   s     %st   indenti   t   include_seps   N/As     (%s bytes)s   
(   Rt   R   R}  Rp   R   R   R  R   R  R  RP   R   t   _space_prefixR   t   size(	   R   R   R   Ru   t	   show_sizet   lastR~   R   t   t(    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR(    s8    


 
 
(   R   R   RP  R   R  R  R(  (    (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR    s
   			R  c           B   sS   e  Z d  Z e Z e Z d   Z d   Z e	 e  Z
 d   Z d   Z d   Z RS(   s  
    Represents a single file found as the result of a command.

    Has attributes:

    ``path``:
        The path of the file, relative to the ``base_path``

    ``full``:
        The full path

    ``stat``:
        The results of ``os.stat``.  Also ``mtime`` and ``size``
        contain the ``.st_mtime`` and ``st_size`` of the stat.

    ``bytes``:
        The contents of the file.

    You may use the ``in`` operator with these objects (tested against
    the contents of the file), and the ``.mustcontain()`` method.
    c         C   sj   | |  _  | |  _ t i i | |  |  _ t i |  i  |  _ |  i i |  _ |  i i |  _	 d  |  _ d  S(   N(   Rm  R~   R   Rt   R  t   statt   st_mtimeR  t   st_sizeR  R(   t   _bytes(   R   Rm  R~   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR   <  s    		c         C   sF   |  i  d  j o/ t |  i d  } | i   |  _  | i   n |  i  S(   NR}   (   R  R(   R   R  R   R   (   R   R   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt
   bytes__getE  s
    c         C   s   | |  i  j S(   N(   t   bytes(   R   R   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR  M  s    c         C   sF   t  } |  i } | | j o& d | GH| GH| | j p t  n d  S(   Ns   Could not find %r in:(   R   R  R   (   R   R   RM   R  (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR"  P  s    		c         C   s   d |  i  i |  i |  i f S(   Ns
   <%s %s:%s>(   R   R   Rm  R~   (   R   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR#  X  s    	(   R   R   RP  R   t   fileR   t   dirR   R  R/  R  R  R"  R#  (    (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR  !  s   					R  c           B   s,   e  Z d  Z e Z e Z d   Z d   Z RS(   s6   
    Represents a directory created by a command.
    c         C   s@   | |  _  | |  _ t i i | |  |  _ d |  _ d |  _ d  S(   Ns   N/A(   Rm  R~   R   Rt   R  R  R  (   R   Rm  R~   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR   f  s
    			c         C   s   d |  i  i |  i |  i f S(   Ns
   <%s %s:%s>(   R   R   Rm  R~   (   R   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR#  m  s    	(	   R   R   RP  R   R  R   R  R   R#  (    (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR  ]  s
   	c         C   s"   | |  j o |  i  |  Sn | S(   s4   
    Pop the key if found (else return default)
    (   R;  (   R
  Rx   R   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR  r  s    c         C   s,  | d j o t i i } n |  i |  }  | i |  } g  } x |  o | oz |  d | d j oe | d j o) | i d t | d  t |   n | i d |  | i d  |  i d  qD W| oG | o" d i |  | | i |  Sq(d i |  | i |  Sn | i |  Sd S(   sg   
    Anything shared by pref and full will be replaced with spaces
    in full, and full returned.
    i    R  R@   N(	   R(   R   R~   R+  RD   Rp   R\   R;  Rt   (   t   prefR  R+  R  R  t   padding(    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR  z  s"     #)"c         C   s   |  d  j o d  Sn t |  t t f  o t i |   }  n t |  d  o |  i Sn t |   o |  Sn d p t	 d |   d  S(   NR   i    s-   Cannot make callable pattern object out of %r(
   R(   R/   R0   R1   R   R   RW   R   t   callableR   (   t   pat(    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR     s    
c         C   s   d d k  } | i d t d  |  d j o t i   i i d }  n t |  t	 t
 f  o t i |  }  n t |  d  o |  i   n d S(   s   
    This is used by py.test if it is in the module, so you can
    import this directly.

    Use like::

        from paste.fixture import setup_module
    iNs   setup_module is deprecatedi   R   t   reset_state(   R   R   R   R(   R   t	   _getframet   f_backt	   f_globalsR/   R0   R1   t   modulesRW   R  (   t   moduleR   (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyt   setup_module  s    

c         C   s<   x5 d d d d d g D] \ } } |  i  | |  }  q W|  S(   s8   
    Unquote (some) entities in HTML.  (incomplete)
    s   &nbsp;R  s   &gt;t   >s   &lt;t   <s   &quot;t   "s   &amp;R>   (   s   &nbsp;R  (   s   &gt;R  (   s   &lt;R  (   s   &quot;R  (   s   &amp;R>   (   Rj   (   R   t   entt   repl(    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pyR:    s    	 (>   RP  R   Ro   RB   R  Rr   R   RX   R   R  R$   R  t   CookieR    t	   cStringIOR   t   ImportErrorR   R  t
   paste.utilR   t   pasteR   R   t   paste.responseR   R	   t   objectR
   R   R   t	   ExceptionR+   R,   R   R   RG   R   R   R   RQ  R   R>  RL  R?  R=  R_  Rb  Rc  Rd  Rf  Rh  R  R  R  R(   R  R   R  R   R  R:  (    (    (    s\   /afs/athena.mit.edu/user/x/a/xavid/Public/bazki/lib/Paste-1.7.5.1-py2.5.egg/paste/fixture.pys   <module>
   s   		$ i &		()
O<	