;ò
ÎÑAHc           @   s  d  Z  d k l Z d e i d Z d Z d k Z d k Z d k Z d k	 Z	 d k
 Z
 d k l Z l Z l Z d k l Z d k l Z e Z d	 Z d
 e
 i j oY y: d k Z e e i d ƒ o e i d j o
 e Z n Wqÿ e j
 o d GHqÿ Xn e o d k l Z d Z n d k l Z d „  Z d „  Z d e  f d „  ƒ  YZ! d d „ Z" d „  Z# d e f d „  ƒ  YZ d S(   sM  
Pdb debugger class.

Modified from the standard pdb.Pdb class to avoid including readline, so that
the command line completion of other programs which include this isn't
damaged.

In the future, this class will be expanded with improvements over the standard
pdb.

The code in this file is mainly lifted out of cmd.py in Python 2.2, with minor
changes. Licensing should therefore be under the standard Python terms.  For
details on the PSF (Python Software Foundation) standard license, see:

http://www.python.org/2.2.3/license.html

$Id: Debugger.py 2913 2007-12-31 12:42:14Z vivainio $(   s   Releases   %s <%s>s   Fernandos   PythonN(   s
   PyColorizes	   ColorANSIs   ipapi(   s   Term(   s   ExceptionColorss   ipdb> s   -pydbs   runls   1.17sH   Pydb (http://bashdb.sourceforge.net/pydb/) does not seem to be available(   s   Pdbs   ipydb> c         C   s0   |  t i j o	 d GHn t i |  | | ƒ d  S(   Ns   Exiting Debugger.(   s   ets   bdbs   BdbQuits   BdbQuit_excepthooks   excepthook_oris   evs   tb(   s   ets   evs   tb(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/Debugger.pys   BdbQuit_excepthookD   s    	c         C   s	   d GHd  S(   Ns   Exiting Debugger.(    (   s   selfs   ets   evs   tb(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/Debugger.pys   BdbQuit_IPython_excepthookJ   s    s   Tracerc           B   s#   t  Z d  Z e d „ Z d „  Z RS(   s3  Class for local debugging, similar to pdb.set_trace.

    Instances of this class, when called, behave like pdb.set_trace, but
    providing IPython's enhanced capabilities.

    This is implemented as a class which must be initialized in your own code
    and not as a standalone function because we need to detect at runtime
    whether IPython is already active or not.  That detection is done in the
    constructor, ensuring that this code plays nicely with a running IPython,
    while functioning acceptably (though with limitations) if outside of it.
    c         C   sÜ   y t  Wny t j
 om t i t t ƒ a  t i t _	 t t _ d } y# d k } d k } | i d ƒ Wq² t j
 o q² Xn0 Xt i ƒ  } | i i } | i t i f t ƒ | t j o
 | } n t | ƒ |  _ d S(   sù  Create a local debugger instance.

        :Parameters:

          - `colors` (None): a string containing the name of the color scheme to
        use, it must be one of IPython's valid color schemes.  If not given, the
        function will default to the current IPython scheme when running inside
        IPython, and to 'NoColor' otherwise.

        Usage example:

        from IPython.Debugger import Tracer; debug_here = Tracer()

        ... later in your code
        debug_here()  # -> will open up the debugger at that point.

        Once the debugger activates, you can use all of its regular commands to
        step through code, set breakpoints, etc.  See the pdb documentation
        from the Python standard library for usage details.
        s   NoColorNs   tab: complete(   s   __IPYTHON__s	   NameErrors   ipapis   gets   Trues   Falses   syss
   excepthooks   BdbQuit_excepthooks   excepthook_oris
   def_colorss   rlcompleters   readlines   parse_and_binds   ImportErrors   ips   optionss   colorss   set_custom_excs   bdbs   BdbQuits   BdbQuit_IPython_excepthooks   Nones   Pdbs   selfs   debugger(   s   selfs   colorss
   def_colorss   ips   readlines   rlcompleter(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/Debugger.pys   __init__Z   s(      	

c         C   s   |  i i t i ƒ  i ƒ d S(   s³   Starts an interactive debugger at the point where called.

        This is similar to the pdb.set_trace() function from the std lib, but
        using IPython's enhanced debugger.N(   s   selfs   debuggers	   set_traces   syss	   _getframes   f_back(   s   self(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/Debugger.pys   __call__‰   s     (   s   __name__s
   __module__s   __doc__s   Nones   __init__s   __call__(    (    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/Debugger.pys   TracerM   s    /s    c            s2   ‡  d †  } | i o | i | | _ n | Sd S(   sÃ   Make new_fn have old_fn's doc string. This is particularly useful
    for the do_... commands that hook into the help system.
    Adapted from from a comp.lang.python posting
    by Duncan Booth.c             s   ˆ  |  | Ž  Sd  S(   N(   s   new_fns   argss   kw(   s   argss   kw(   s   new_fn(    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/Debugger.pys   wrapper–   s    N(   s   wrappers   old_fns   __doc__s   additional_text(   s   new_fns   old_fns   additional_texts   wrapper(    (   s   new_fns@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/Debugger.pys   decorate_fn_with_doc‘   s
     
c         C   sH   y t  |  ƒ } Wn t j
 o g  Sn X| i ƒ  } | i ƒ  | Sd S(   s­   Return the contents of a named file as a list of lines.

    This function never raises an IOError exception: if the file can't be
    read, it simply returns an empty list.N(   s   opens   fnames   outfiles   IOErrors	   readliness   outs   close(   s   fnames   outfiles   out(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/Debugger.pys   _file_linesœ   s     	
s   Pdbc           B   sG  t  Z d  Z e i d  d j p e o d e e e d „ Z n d d „ Z d „  Z d „  Z	 d „  Z
 e e
 e i ƒ Z Z d	 „  Z e e e i ƒ Z Z d
 „  Z d „  Z e e e i ƒ Z Z d „  Z d „  Z d „  Z d d d „ Z d d d „ Z e d „ Z d „  Z d „  Z d „  Z e Z  d „  Z! d „  Z" d „  Z# RS(   s+   Modified Pdb class, does not load readline.i   s   2.5s   NoColorc            s°  t  o
 | t j o  t i ˆ  d | d t i ƒn t i ˆ  | | | ƒ t
 ˆ  _
 t  ˆ  _ ˆ  i oŽ d  k ‰ ‡  ‡ d †  ˆ  _ t ˆ  _ ˆ  i ˆ  _ t i i ˆ  _ ˆ  i t i _ t ˆ  i t i ƒ ˆ  _ ˆ  i ˆ  _ t ˆ  i t i ƒ ˆ  _ n h  ˆ  _ t i ƒ  ˆ  _ t  i! } ˆ  i } | i$ | d i% _& | i$ | d i% _' | i( | d i% _& | i) | d i% _' | i( | d i% _& | i) | d i% _' ˆ  i* | ƒ t, i- ƒ  ˆ  _. d  S(   Ns   stdins   stdoutc            s   ˆ i i ˆ  |  | ƒ S(   N(   s   pydbs   fnss	   checklines   selfs   filenames   lineno(   s   filenames   lineno(   s   selfs   pydb(    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/Debugger.pys   <lambda>Â   s    s   NoColors   Linuxs   LightBG(/   s   has_pydbs   completekeys   Nones   OldPdbs   __init__s   selfs   stdins   Terms   couts   stdouts   prompts   is_pydbs   pydb.fnss   pydbs	   checklines   curframes   new_do_restarts
   do_restarts   __IPYTHON__s	   Completers   all_completionss   old_all_completionss   decorate_fn_with_docs   list_command_pydbs   do_lists   do_ls   new_do_frames   do_frames   aliasess   ExceptionColorss   copys   color_scheme_tables	   ColorANSIs
   TermColorss   Cs   csts   NoColors   colorss   breakpoint_enableds   breakpoint_disableds   LightReds   Reds
   set_colorss   color_schemes
   PyColorizes   Parsers   parser(   s   selfs   color_schemes   completekeys   stdins   stdouts   csts   Cs   pydb(    (   s   selfs   pydbs@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/Debugger.pys   __init__¯   s:     		
							c         C   sh  t  i i |  ƒ t i i |  d t ƒd |  _ h  |  _ d |  _	 d |  _
 y) t t i i t i d d ƒ ƒ |  _ Wn t j
 o g  |  _ n X|  i i t d ƒ ƒ t i | ƒ t i ƒ  |  _ t i } |  i } | i | d i _ | i | d i _ | i  | d i _ | i! | d i _ | i  | d	 i _ | i! | d	 i _ |  i" | ƒ t# i$ ƒ  |  _% d  S(
   Ns   completekeys   ipdb> s    i    s   HOMEs   .pdbrcs   NoColors   Linuxs   LightBG(&   s   bdbs   Bdbs   __init__s   selfs   cmds   Cmds   Nones   prompts   aliasess
   mainpyfiles   _wait_for_mainpyfiles   _file_liness   oss   paths   joins   environs   rcLiness   KeyErrors   extends   ExceptionColorss   set_active_schemes   color_schemes   copys   color_scheme_tables	   ColorANSIs
   TermColorss   Cs   csts   NoColors   colorss   breakpoint_enableds   breakpoint_disableds   LightReds   Reds
   set_colorss
   PyColorizes   Parsers   parser(   s   selfs   color_schemes   Cs   cst(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/Debugger.pys   __init__ï   s0    						c         C   s   |  i i | ƒ d S(   s;   Shorthand access to the color table scheme selector method.N(   s   selfs   color_scheme_tables   set_active_schemes   scheme(   s   selfs   scheme(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/Debugger.pys
   set_colors  s     c         C   s$   t  i | ƒ t i |  | | ƒ d  S(   N(   s   __IPYTHON__s   set_completer_frames   frames   OldPdbs   interactions   selfs	   traceback(   s   selfs   frames	   traceback(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/Debugger.pys   interaction  s    c         C   s$   t  i |  | ƒ t i |  i ƒ d  S(   N(   s   OldPdbs   do_ups   selfs   args   __IPYTHON__s   set_completer_frames   curframe(   s   selfs   arg(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/Debugger.pys	   new_do_up"  s    c         C   s$   t  i |  | ƒ t i |  i ƒ d  S(   N(   s   OldPdbs   do_downs   selfs   args   __IPYTHON__s   set_completer_frames   curframe(   s   selfs   arg(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/Debugger.pys   new_do_down'  s    c         C   s$   t  i |  | ƒ t i |  i ƒ d  S(   N(   s   OldPdbs   do_frames   selfs   args   __IPYTHON__s   set_completer_frames   curframe(   s   selfs   arg(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/Debugger.pys   new_do_frame-  s    c         C   s7   t  |  d ƒ o |  i t i _ n t i |  | ƒ Sd  S(   Ns   old_all_completions(	   s   hasattrs   selfs   old_all_completionss   __IPYTHON__s	   Completers   all_completionss   OldPdbs   do_quits   arg(   s   selfs   arg(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/Debugger.pys   new_do_quit1  s    c         C   s   |  i d ƒ |  i | ƒ Sd S(   s\   Restart command. In the context of ipython this is exactly the same
        thing as 'quit'.s6   Restart doesn't make sense here. Using 'quit' instead.N(   s   selfs   msgs   do_quits   arg(   s   selfs   arg(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/Debugger.pys   new_do_restart;  s     c         C   s   t  i t ƒ d  S(   N(   s   __IPYTHON__s   set_completer_frames   None(   s   self(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/Debugger.pys   postloopA  s    c         C   sE   y+ x$ |  i D] } |  i | d d ƒq WWn t j
 o n Xd  S(   Ns   contexti   (   s   selfs   stacks   frame_linenos   print_stack_entrys   KeyboardInterrupt(   s   selfs   frame_lineno(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/Debugger.pys   print_stack_traceD  s    
 s   
-> c         C   s    t  i |  i | d | ƒ IJd  S(   Ns    (   s   Terms   couts   selfs   format_stack_entrys   frame_linenos   context(   s   selfs   frame_linenos   prompt_prefixs   context(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/Debugger.pys   print_stack_entryK  s    s   : c      	   C   sª  d  k  } d  k } g  }	 |  i i } | i } d | i	 | f } d | i | i | f } d | i | f } d | i | i | f } | \ } } d } d | i j o( | i d } | | i | ƒ d 7} n |	 i | ƒ |  i | i i ƒ }
 | |
 } | i i o | i i } n d } d } | d	 j oD d
 | i j o | i | i d
 ƒ } n d } | | | f } n | |  i" j o |	 i d ƒ n |	 i d ƒ |	 i d | | | f ƒ | d | d } | i% |
 ƒ } t' | d ƒ } t( | t) | ƒ | ƒ } | | | | !} x t* | ƒ D]q \ } } | d | | j } | |  i" j p | o | p | } |	 i |  i. | |
 | d | | d | ƒƒ q$Wd i/ |	 ƒ Sd  S(   Ns   %s%%s%ss   %s%%s%s%%s%ss   %%s%s%%s %s%%ss   %%s%s%%s %s%%s%ss    s
   __return__s   
s   <lambda>s   ?s   __args__s   ()s   > s     s	   %s(%s)%s
i   i   i    s   arrow(0   s	   linecaches   reprs   rets   selfs   color_scheme_tables   active_colorss   Colorss   Normals   ColorsNormals
   filenameEms   tpl_links   vNames   valEms   tpl_calls   linenos   tpl_lines   linenoEms   lines   tpl_line_ems   frame_linenos   frames   return_values   f_localss   rvs   appends   canonics   f_codes   co_filenames   filenames   links   co_names   funcs   calls   argss   curframes   contexts   starts   getliness   liness   maxs   mins   lens	   enumerates   is
   show_arrows   linetpls   _Pdb__format_lines   join(   s   selfs   frame_linenos   lprefixs   contexts   frames   return_values
   show_arrows   rvs	   linecaches   rets   filenames   starts   calls   linenos   tpl_links   tpl_lines   linetpls   argss   reprs   links   funcs   lines   is   tpl_calls   liness   tpl_line_ems   Colorss   ColorsNormal(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/Debugger.pys   format_stack_entryP  sT    	
 $c         C   s¿  d } d } |  i i } |  i i | d | ƒ \ } }	 |	 o
 | } n t } | |  i | ƒ j o  |  i | | ƒ } | d } n | o@ |  i i }
 t | i ƒ } |
 i } | i o |
 i } qË n d } | o¨ | t t | ƒ ƒ t | ƒ } | d j o d | d d } n5 | d j o
 d	 } n | d
 j o
 d } n d } d | t | ƒ f } | | | | | f } n8 d | t | ƒ t | ƒ f } | | | | | f } | Sd  S(   Ns    s   striÿÿÿÿi   i   s   -s   -> i   s   > i   s   >s   %s%ss   %*s(    s   bp_marks   bp_mark_colors   selfs   color_scheme_tables   active_scheme_names   schemes   parsers   format2s   lines   new_lines   errs   Nones   bps   linenos   get_file_breakss   filenames
   get_breakss   bpss   active_colorss   Colorss   strs   numbers   breakpoint_enableds   enableds   breakpoint_disableds   numbers_widths   arrows   lens   pads   markers   nums   tpl_line(   s   selfs   tpl_lines   filenames   linenos   lines   arrows   new_lines   schemes   numbers_widths   errs   Colorss   bp_marks   bpss   nums   bps   markers   pads   bp_mark_color(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/Debugger.pys   __format_line  s>     
	 

 c         C   sC   t  i |  | ƒ \ } } } | t j	 o |  i | | | ƒ n d S(   s5   List command to use if we have a newer pydb installedN(	   s   OldPdbs   parse_list_cmds   selfs   args   filenames   firsts   lasts   Nones   print_list_lines(   s   selfs   args   lasts   filenames   first(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/Debugger.pys   list_command_pydb¸  s     c         C   s!  y|  i i } | i } d | i | f } d | i | i	 | f } g  } x£ t | | d ƒ D]Ž }
 t i | |
 ƒ }	 |	 o Pn |
 |  i i j o" |  i | | |
 |	 d t ƒ}	 n |  i | | |
 |	 d t ƒ}	 | i |	 ƒ |
 |  _ q^ Wt i d i | ƒ IJWn t j
 o n Xd S(   sI   The printing (as opposed to the parsing part of a 'list'
        command.s   %%s%s%%s %s%%ss   %%s%s%%s %s%%s%si   s   arrows    N(   s   selfs   color_scheme_tables   active_colorss   Colorss   Normals   ColorsNormals   linenos   tpl_lines   linenoEms   lines   tpl_line_ems   srcs   ranges   firsts   lasts	   linecaches   getlines   filenames   curframes   f_linenos   _Pdb__format_lines   Trues   Falses   appends   Terms   couts   joins   KeyboardInterrupt(   s   selfs   filenames   firsts   lasts   srcs   tpl_line_ems   Colorss   tpl_lines   ColorsNormals   lines   lineno(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/Debugger.pys   print_list_lines¾  s(     	 "c         C   s2  d |  _ t } | o§ y‹ t | h  h  ƒ } t | ƒ t f  ƒ j oC | \ } } t	 | ƒ } t	 | ƒ } | | j  o | | } q  n t
 d t	 | ƒ d ƒ } Wq÷ d G| GHd  Sq÷ Xn; |  i t j o t
 d |  i i d ƒ } n |  i d } | t j o | d } n |  i |  i i i | | ƒ d  S(   Ns   listi   i   s   *** Error in argument:i
   (   s   selfs   lastcmds   Nones   lasts   args   evals   xs   types   firsts   ints   maxs   linenos   curframes   f_linenos   print_list_liness   f_codes   co_filename(   s   selfs   args   lasts   xs   first(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/Debugger.pys   do_listÙ  s*    	
c         C   s;   d |  i i f d |  i i f g } t i | d | ƒd S(   s$   The debugger interface to magic_pdefs   Localss   Globalss
   namespacesN(   s   selfs   curframes   f_localss	   f_globalss
   namespacess   __IPYTHON__s
   magic_pdefs   arg(   s   selfs   args
   namespaces(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/Debugger.pys   do_pdefõ  s     $c         C   s;   d |  i i f d |  i i f g } t i | d | ƒd S(   s$   The debugger interface to magic_pdocs   Localss   Globalss
   namespacesN(   s   selfs   curframes   f_localss	   f_globalss
   namespacess   __IPYTHON__s
   magic_pdocs   arg(   s   selfs   args
   namespaces(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/Debugger.pys   do_pdocû  s     $c         C   s?   d |  i i f d |  i i f g } t i d | d | ƒd S(   s   The debugger equivalant of ?objs   Localss   Globalss   pinfo %ss
   namespacesN(   s   selfs   curframes   f_localss	   f_globalss
   namespacess   __IPYTHON__s   magic_pinfos   arg(   s   selfs   args
   namespaces(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/Debugger.pys   do_pinfo  s     $($   s   __name__s
   __module__s   __doc__s   syss   versions   has_pydbs   Nones   __init__s
   set_colorss   interactions	   new_do_ups   decorate_fn_with_docs   OldPdbs   do_ups   do_us   new_do_downs   do_downs   do_ds   new_do_frames   new_do_quits   do_quits   do_qs   new_do_restarts   postloops   print_stack_traces   print_stack_entrys   format_stack_entrys   Falses   _Pdb__format_lines   list_command_pydbs   print_list_liness   do_lists   do_ls   do_pdefs   do_pdocs   do_pinfo(    (    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/Debugger.pys   Pdb«   s4    @+									@(					($   s   __doc__s   IPythons   Releases   authorss
   __author__s   __license__s   bdbs   cmds	   linecaches   oss   syss
   PyColorizes	   ColorANSIs   ipapis   IPython.genutilss   Terms   IPython.excolorss   ExceptionColorss   Falses   has_pydbs   prompts   argvs   pydbs   hasattrs   versions   Trues   ImportErrors   Pdbs   OldPdbs   pdbs   BdbQuit_excepthooks   BdbQuit_IPython_excepthooks   objects   Tracers   decorate_fn_with_docs   _file_lines(   s   prompts   BdbQuit_IPython_excepthooks	   ColorANSIs   _file_liness   __license__s   bdbs   Pdbs   pydbs   ipapis   Terms   OldPdbs
   PyColorizes   has_pydbs   BdbQuit_excepthooks
   __author__s   syss   Releases   decorate_fn_with_docs   Tracers   cmds	   linecaches   ExceptionColorss   os(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/Debugger.pys   ?   s<   						#
		D	