File: //opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/evalcontext.pyc
�
a�Nc           @   s   d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l Z e j �  Z d e f d �  �  YZ	 d e j
 f d �  �  YZ d S(   i����(   t   StringIONt   EvalContextc           B   s    e  Z d  Z d �  Z d �  Z RS(   s%  
    Class that represents a interactive interface.  It has its own
    namespace.  Use eval_context.exec_expr(expr) to run commands; the
    output of those commands is returned, as are print statements.
    This is essentially what doctest does, and is taken directly from
    doctest.
    c         C   s   | |  _  | |  _ d  S(   N(   t	   namespacet   globs(   t   selfR   R   (    (    sP   /opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/evalcontext.pyt   __init__   s    	c         B   s�   e  �  } e j �  e j } z� e | � } | j �  | j e _ | e _ y6 e	 | d d d d � } | |  j
 |  j U| j �  Wn4 e
 k
 r� �  n! e j d | � | j �  n XWd  | e _ e j �  X| j �  S(   Ns   <web>t   singlei    i   t   file(   R    t	   exec_lockt   acquiret   syst   stdoutt   _OutputRedirectingPdbt   resett	   set_tracet   pdbt   compileR   R   t   set_continuet   KeyboardInterruptt	   tracebackt	   print_exct   releaset   getvalue(   R   t   st   outt   save_stdoutt   debuggert   code(    (    sP   /opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/evalcontext.pyt	   exec_expr   s(    	
	
	
	(   t   __name__t
   __module__t   __doc__R   R   (    (    (    sP   /opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/evalcontext.pyR      s   		R   c           B   s    e  Z d  Z d �  Z d �  Z RS(   s�   
    A specialized version of the python debugger that redirects stdout
    to a given stream when interacting with the user.  Stdout is *not*
    redirected when traced code is executed.
    c         C   s   | |  _  t j j |  � d  S(   N(   t   _OutputRedirectingPdb__outR   t   PdbR   (   R   R   (    (    sP   /opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/evalcontext.pyR   8   s    	c         G   s=   t  j } |  j t  _ z t j j |  | � SWd  | t  _ Xd  S(   N(   R
   R   R    R   R!   t   trace_dispatch(   R   t   argsR   (    (    sP   /opt/alt/python27/lib/python2.7/site-packages/paste/evalexception/evalcontext.pyR"