<s> """<STR_LIT>""" <EOL> import sys <EOL> import linecache <EOL> import cmd <EOL> import bdb <EOL> from repr import Repr <EOL> import os <EOL> import re <EOL> import pprint <EOL> import traceback <EOL> class Restart ( Exception ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> _repr = Repr ( ) <EOL> _repr . maxstring = <NUM_LIT:200> <EOL> _saferepr = _repr . repr <EOL> __all__ = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" ] <EOL> def find_function ( funcname , filename ) : <EOL> cre = re . compile ( r'<STR_LIT>' % re . escape ( funcname ) ) <EOL> try : <EOL> fp = open ( filename ) <EOL> except IOError : <EOL> return None <EOL> lineno = <NUM_LIT:1> <EOL> answer = None <EOL> while <NUM_LIT:1> : <EOL> line = fp . readline ( ) <EOL> if line == '<STR_LIT>' : <EOL> break <EOL> if cre . match ( line ) : <EOL> answer = funcname , filename , lineno <EOL> break <EOL> lineno = lineno + <NUM_LIT:1> <EOL> fp . close ( ) <EOL> return answer <EOL> line_prefix = '<STR_LIT>' <EOL> class Pdb ( bdb . Bdb , cmd . Cmd ) : <EOL> def __init__ ( self , completekey = '<STR_LIT>' , stdin = None , stdout = None , skip = None ) : <EOL> bdb . Bdb . __init__ ( self , skip = skip ) <EOL> cmd . Cmd . __init__ ( self , completekey , stdin , stdout ) <EOL> if stdout : <EOL> self . use_rawinput = <NUM_LIT:0> <EOL> self . prompt = '<STR_LIT>' <EOL> self . aliases = { } <EOL> self . mainpyfile = '<STR_LIT>' <EOL> self . _wait_for_mainpyfile = <NUM_LIT:0> <EOL> try : <EOL> import readline <EOL> except ImportError : <EOL> pass <EOL> self . rcLines = [ ] <EOL> if '<STR_LIT>' in os . environ : <EOL> envHome = os . environ [ '<STR_LIT>' ] <EOL> try : <EOL> rcFile = open ( os . path . join ( envHome , "<STR_LIT>" ) ) <EOL> except IOError : <EOL> pass <EOL> else : <EOL> for line in rcFile . readlines ( ) : <EOL> self . rcLines . append ( line ) <EOL> rcFile . close ( ) <EOL> try : <EOL> rcFile = open ( "<STR_LIT>" ) <EOL> except IOError : <EOL> pass <EOL> else : <EOL> for line in rcFile . readlines ( ) : <EOL> self . rcLines . append ( line ) <EOL> rcFile . close ( ) <EOL> self . commands = { } <EOL> self . commands_doprompt = { } <EOL> self . commands_silent = { } <EOL> self . commands_defining = False <EOL> self . commands_bnum = None <EOL> def reset ( self ) : <EOL> bdb . Bdb . reset ( self ) <EOL> self . forget ( ) <EOL> def forget ( self ) : <EOL> self . lineno = None <EOL> self . stack = [ ] <EOL> self . curindex = <NUM_LIT:0> <EOL> self . curframe = None <EOL> def setup ( self , f , t ) : <EOL> self . forget ( ) <EOL> self . stack , self . curindex = self . get_stack ( f , t ) <EOL> self . curframe = self . stack [ self . curindex ] [ <NUM_LIT:0> ] <EOL> self . curframe_locals = self . curframe . f_locals <EOL> self . execRcLines ( ) <EOL> def execRcLines ( self ) : <EOL> if self . rcLines : <EOL> rcLines = self . rcLines <EOL> self . rcLines = [ ] <EOL> for line in rcLines : <EOL> line = line [ : - <NUM_LIT:1> ] <EOL> if len ( line ) > <NUM_LIT:0> and line [ <NUM_LIT:0> ] != '<STR_LIT:#>' : <EOL> self . onecmd ( line ) <EOL> def user_call ( self , frame , argument_list ) : <EOL> """<STR_LIT>""" <EOL> if self . _wait_for_mainpyfile : <EOL> return <EOL> if self . stop_here ( frame ) : <EOL> print >> self . stdout , '<STR_LIT>' <EOL> self . interaction ( frame , None ) <EOL> def user_line ( self , frame ) : <EOL> """<STR_LIT>""" <EOL> if self . _wait_for_mainpyfile : <EOL> if ( self . mainpyfile != self . canonic ( frame . f_code . co_filename ) <EOL> or frame . f_lineno <= <NUM_LIT:0> ) : <EOL> return <EOL> self . _wait_for_mainpyfile = <NUM_LIT:0> <EOL> if self . bp_commands ( frame ) : <EOL> self . interaction ( frame , None ) <EOL> def bp_commands ( self , frame ) : <EOL> """<STR_LIT>""" <EOL> if getattr ( self , "<STR_LIT>" , False ) and self . currentbp in self . commands : <EOL> currentbp = self . currentbp <EOL> self . currentbp = <NUM_LIT:0> <EOL> lastcmd_back = self . lastcmd <EOL> self . setup ( frame , None ) <EOL> for line in self . commands [ currentbp ] : <EOL> self . onecmd ( line ) <EOL> self . lastcmd = lastcmd_back <EOL> if not self . commands_silent [ currentbp ] : <EOL> self . print_stack_entry ( self . stack [ self . curindex ] ) <EOL> if self . commands_doprompt [ currentbp ] : <EOL> self . cmdloop ( ) <EOL> self . forget ( ) <EOL> return <EOL> return <NUM_LIT:1> <EOL> def user_return ( self , frame , return_value ) : <EOL> """<STR_LIT>""" <EOL> if self . _wait_for_mainpyfile : <EOL> return <EOL> frame . f_locals [ '<STR_LIT>' ] = return_value <EOL> print >> self . stdout , '<STR_LIT>' <EOL> self . interaction ( frame , None ) <EOL> def user_exception ( self , frame , exc_info ) : <EOL> """<STR_LIT>""" <EOL> if self . _wait_for_mainpyfile : <EOL> return <EOL> exc_type , exc_value , exc_traceback = exc_info <EOL> frame . f_locals [ '<STR_LIT>' ] = exc_type , exc_value <EOL> if type ( exc_type ) == type ( '<STR_LIT>' ) : <EOL> exc_type_name = exc_type <EOL> else : exc_type_name = exc_type . __name__ <EOL> print >> self . stdout , exc_type_name + '<STR_LIT::>' , _saferepr ( exc_value ) <EOL> self . interaction ( frame , exc_traceback ) <EOL> def interaction ( self , frame , traceback ) : <EOL> self . setup ( frame , traceback ) <EOL> self . print_stack_entry ( self . stack [ self . curindex ] ) <EOL> self . cmdloop ( ) <EOL> self . forget ( ) <EOL> def displayhook ( self , obj ) : <EOL> """<STR_LIT>""" <EOL> if obj is not None : <EOL> print repr ( obj ) <EOL> def default ( self , line ) : <EOL> if line [ : <NUM_LIT:1> ] == '<STR_LIT:!>' : line = line [ <NUM_LIT:1> : ] <EOL> locals = self . curframe_locals <EOL> globals = self . curframe . f_globals <EOL> try : <EOL> code = compile ( line + '<STR_LIT:\n>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> save_stdout = sys . stdout <EOL> save_stdin = sys . stdin <EOL> save_displayhook = sys . displayhook <EOL> try : <EOL> sys . stdin = self . stdin <EOL> sys . stdout = self . stdout <EOL> sys . displayhook = self . displayhook <EOL> exec code in globals , locals <EOL> finally : <EOL> sys . stdout = save_stdout <EOL> sys . stdin = save_stdin <EOL> sys . displayhook = save_displayhook <EOL> except : <EOL> t , v = sys . exc_info ( ) [ : <NUM_LIT:2> ] <EOL> if type ( t ) == type ( '<STR_LIT>' ) : <EOL> exc_type_name = t <EOL> else : exc_type_name = t . __name__ <EOL> print >> self . stdout , '<STR_LIT>' , exc_type_name + '<STR_LIT::>' , v <EOL> def precmd ( self , line ) : <EOL> """<STR_LIT>""" <EOL> if not line . strip ( ) : <EOL> return line <EOL> args = line . split ( ) <EOL> while args [ <NUM_LIT:0> ] in self . aliases : <EOL> line = self . aliases [ args [ <NUM_LIT:0> ] ] <EOL> ii = <NUM_LIT:1> <EOL> for tmpArg in args [ <NUM_LIT:1> : ] : <EOL> line = line . replace ( "<STR_LIT:%>" + str ( ii ) , <EOL> tmpArg ) <EOL> ii = ii + <NUM_LIT:1> <EOL> line = line . replace ( "<STR_LIT>" , '<STR_LIT:U+0020>' . join ( args [ <NUM_LIT:1> : ] ) ) <EOL> args = line . split ( ) <EOL> if args [ <NUM_LIT:0> ] != '<STR_LIT>' : <EOL> marker = line . find ( '<STR_LIT>' ) <EOL> if marker >= <NUM_LIT:0> : <EOL> next = line [ marker + <NUM_LIT:2> : ] . lstrip ( ) <EOL> self . cmdqueue . append ( next ) <EOL> line = line [ : marker ] . rstrip ( ) <EOL> return line <EOL> def onecmd ( self , line ) : <EOL> """<STR_LIT>""" <EOL> if not self . commands_defining : <EOL> return cmd . Cmd . onecmd ( self , line ) <EOL> else : <EOL> return self . handle_command_def ( line ) <EOL> def handle_command_def ( self , line ) : <EOL> """<STR_LIT>""" <EOL> cmd , arg , line = self . parseline ( line ) <EOL> if not cmd : <EOL> return <EOL> if cmd == '<STR_LIT>' : <EOL> self . commands_silent [ self . commands_bnum ] = True <EOL> return <EOL> elif cmd == '<STR_LIT:end>' : <EOL> self . cmdqueue = [ ] <EOL> return <NUM_LIT:1> <EOL> cmdlist = self . commands [ self . commands_bnum ] <EOL> if arg : <EOL> cmdlist . append ( cmd + '<STR_LIT:U+0020>' + arg ) <EOL> else : <EOL> cmdlist . append ( cmd ) <EOL> try : <EOL> func = getattr ( self , '<STR_LIT>' + cmd ) <EOL> except AttributeError : <EOL> func = self . default <EOL> if func . func_name in self . commands_resuming : <EOL> self . commands_doprompt [ self . commands_bnum ] = False <EOL> self . cmdqueue = [ ] <EOL> return <NUM_LIT:1> <EOL> return <EOL> do_h = cmd . Cmd . do_help <EOL> def do_commands ( self , arg ) : <EOL> """<STR_LIT>""" <EOL> if not arg : <EOL> bnum = len ( bdb . Breakpoint . bpbynumber ) - <NUM_LIT:1> <EOL> else : <EOL> try : <EOL> bnum = int ( arg ) <EOL> except : <EOL> print >> self . stdout , "<STR_LIT>" "<STR_LIT>" <EOL> return <EOL> self . commands_bnum = bnum <EOL> self . commands [ bnum ] = [ ] <EOL> self . commands_doprompt [ bnum ] = True <EOL> self . commands_silent [ bnum ] = False <EOL> prompt_back = self . prompt <EOL> self . prompt = '<STR_LIT>' <EOL> self . commands_defining = True <EOL> try : <EOL> self . cmdloop ( ) <EOL> finally : <EOL> self . commands_defining = False <EOL> self . prompt = prompt_back <EOL> def do_break ( self , arg , temporary = <NUM_LIT:0> ) : <EOL> if not arg : <EOL> if self . breaks : <EOL> print >> self . stdout , "<STR_LIT>" <EOL> for bp in bdb . Breakpoint . bpbynumber : <EOL> if bp : <EOL> bp . bpprint ( self . stdout ) <EOL> return <EOL> filename = None <EOL> lineno = None <EOL> cond = None <EOL> comma = arg . find ( '<STR_LIT:U+002C>' ) <EOL> if comma > <NUM_LIT:0> : <EOL> cond = arg [ comma + <NUM_LIT:1> : ] . lstrip ( ) <EOL> arg = arg [ : comma ] . rstrip ( ) <EOL> colon = arg . rfind ( '<STR_LIT::>' ) <EOL> funcname = None <EOL> if colon >= <NUM_LIT:0> : <EOL> filename = arg [ : colon ] . rstrip ( ) <EOL> f = self . lookupmodule ( filename ) <EOL> if not f : <EOL> print >> self . stdout , '<STR_LIT>' , repr ( filename ) , <EOL> print >> self . stdout , '<STR_LIT>' <EOL> return <EOL> else : <EOL> filename = f <EOL> arg = arg [ colon + <NUM_LIT:1> : ] . lstrip ( ) <EOL> try : <EOL> lineno = int ( arg ) <EOL> except ValueError , msg : <EOL> print >> self . stdout , '<STR_LIT>' , arg <EOL> return <EOL> else : <EOL> try : <EOL> lineno = int ( arg ) <EOL> except ValueError : <EOL> try : <EOL> func = eval ( arg , <EOL> self . curframe . f_globals , <EOL> self . curframe_locals ) <EOL> except : <EOL> func = arg <EOL> try : <EOL> if hasattr ( func , '<STR_LIT>' ) : <EOL> func = func . im_func <EOL> code = func . func_code <EOL> funcname = code . co_name <EOL> lineno = code . co_firstlineno <EOL> filename = code . co_filename <EOL> except : <EOL> ( ok , filename , ln ) = self . lineinfo ( arg ) <EOL> if not ok : <EOL> print >> self . stdout , '<STR_LIT>' , <EOL> print >> self . stdout , repr ( arg ) , <EOL> print >> self . stdout , '<STR_LIT>' <EOL> print >> self . stdout , '<STR_LIT>' <EOL> return <EOL> funcname = ok <EOL> lineno = int ( ln ) <EOL> if not filename : <EOL> filename = self . defaultFile ( ) <EOL> line = self . checkline ( filename , lineno ) <EOL> if line : <EOL> err = self . set_break ( filename , line , temporary , cond , funcname ) <EOL> if err : print >> self . stdout , '<STR_LIT>' , err <EOL> else : <EOL> bp = self . get_breaks ( filename , line ) [ - <NUM_LIT:1> ] <EOL> print >> self . stdout , "<STR_LIT>" % ( bp . number , <EOL> bp . file , <EOL> bp . line ) <EOL> def defaultFile ( self ) : <EOL> """<STR_LIT>""" <EOL> filename = self . curframe . f_code . co_filename <EOL> if filename == '<STR_LIT>' and self . mainpyfile : <EOL> filename = self . mainpyfile <EOL> return filename <EOL> do_b = do_break <EOL> def do_tbreak ( self , arg ) : <EOL> self . do_break ( arg , <NUM_LIT:1> ) <EOL> def lineinfo ( self , identifier ) : <EOL> failed = ( None , None , None ) <EOL> idstring = identifier . split ( "<STR_LIT:'>" ) <EOL> if len ( idstring ) == <NUM_LIT:1> : <EOL> id = idstring [ <NUM_LIT:0> ] . strip ( ) <EOL> elif len ( idstring ) == <NUM_LIT:3> : <EOL> id = idstring [ <NUM_LIT:1> ] . strip ( ) <EOL> else : <EOL> return failed <EOL> if id == '<STR_LIT>' : return failed <EOL> parts = id . split ( '<STR_LIT:.>' ) <EOL> if parts [ <NUM_LIT:0> ] == '<STR_LIT>' : <EOL> del parts [ <NUM_LIT:0> ] <EOL> if len ( parts ) == <NUM_LIT:0> : <EOL> return failed <EOL> fname = self . defaultFile ( ) <EOL> if len ( parts ) == <NUM_LIT:1> : <EOL> item = parts [ <NUM_LIT:0> ] <EOL> else : <EOL> f = self . lookupmodule ( parts [ <NUM_LIT:0> ] ) <EOL> if f : <EOL> fname = f <EOL> item = parts [ <NUM_LIT:1> ] <EOL> answer = find_function ( item , fname ) <EOL> return answer or failed <EOL> def checkline ( self , filename , lineno ) : <EOL> """<STR_LIT>""" <EOL> globs = self . curframe . f_globals if hasattr ( self , '<STR_LIT>' ) else None <EOL> line = linecache . getline ( filename , lineno , globs ) <EOL> if not line : <EOL> print >> self . stdout , '<STR_LIT>' <EOL> return <NUM_LIT:0> <EOL> line = line . strip ( ) <EOL> if ( not line or ( line [ <NUM_LIT:0> ] == '<STR_LIT:#>' ) or <EOL> ( line [ : <NUM_LIT:3> ] == '<STR_LIT>' ) or line [ : <NUM_LIT:3> ] == "<STR_LIT>" ) : <EOL> print >> self . stdout , '<STR_LIT>' <EOL> return <NUM_LIT:0> <EOL> return lineno <EOL> def do_enable ( self , arg ) : <EOL> args = arg . split ( ) <EOL> for i in args : <EOL> try : <EOL> i = int ( i ) <EOL> except ValueError : <EOL> print >> self . stdout , '<STR_LIT>' % i <EOL> continue <EOL> if not ( <NUM_LIT:0> <= i < len ( bdb . Breakpoint . bpbynumber ) ) : <EOL> print >> self . stdout , '<STR_LIT>' , i <EOL> continue <EOL> bp = bdb . Breakpoint . bpbynumber [ i ] <EOL> if bp : <EOL> bp . enable ( ) <EOL> def do_disable ( self , arg ) : <EOL> args = arg . split ( ) <EOL> for i in args : <EOL> try : <EOL> i = int ( i ) <EOL> except ValueError : <EOL> print >> self . stdout , '<STR_LIT>' % i <EOL> continue <EOL> if not ( <NUM_LIT:0> <= i < len ( bdb . Breakpoint . bpbynumber ) ) : <EOL> print >> self . stdout , '<STR_LIT>' , i <EOL> continue <EOL> bp = bdb . Breakpoint . bpbynumber [ i ] <EOL> if bp : <EOL> bp . disable ( ) <EOL> def do_condition ( self , arg ) : <EOL> args = arg . split ( '<STR_LIT:U+0020>' , <NUM_LIT:1> ) <EOL> try : <EOL> bpnum = int ( args [ <NUM_LIT:0> ] . strip ( ) ) <EOL> except ValueError : <EOL> print >> self . stdout , '<STR_LIT>' % args [ <NUM_LIT:0> ] <EOL> return <EOL> try : <EOL> cond = args [ <NUM_LIT:1> ] <EOL> except : <EOL> cond = None <EOL> try : <EOL> bp = bdb . Breakpoint . bpbynumber [ bpnum ] <EOL> except IndexError : <EOL> print >> self . stdout , '<STR_LIT>' % args [ <NUM_LIT:0> ] <EOL> return <EOL> if bp : <EOL> bp . cond = cond <EOL> if not cond : <EOL> print >> self . stdout , '<STR_LIT>' , bpnum , <EOL> print >> self . stdout , '<STR_LIT>' <EOL> def do_ignore ( self , arg ) : <EOL> """<STR_LIT>""" <EOL> args = arg . split ( ) <EOL> try : <EOL> bpnum = int ( args [ <NUM_LIT:0> ] . strip ( ) ) <EOL> except ValueError : <EOL> print >> self . stdout , '<STR_LIT>' % args [ <NUM_LIT:0> ] <EOL> return <EOL> try : <EOL> count = int ( args [ <NUM_LIT:1> ] . strip ( ) ) <EOL> except : <EOL> count = <NUM_LIT:0> <EOL> try : <EOL> bp = bdb . Breakpoint . bpbynumber [ bpnum ] <EOL> except IndexError : <EOL> print >> self . stdout , '<STR_LIT>' % args [ <NUM_LIT:0> ] <EOL> return <EOL> if bp : <EOL> bp . ignore = count <EOL> if count > <NUM_LIT:0> : <EOL> reply = '<STR_LIT>' <EOL> if count > <NUM_LIT:1> : <EOL> reply = reply + '<STR_LIT>' % count <EOL> else : <EOL> reply = reply + '<STR_LIT>' <EOL> print >> self . stdout , reply + '<STR_LIT>' % bpnum <EOL> else : <EOL> print >> self . stdout , '<STR_LIT>' , <EOL> print >> self . stdout , bpnum , '<STR_LIT>' <EOL> def do_clear ( self , arg ) : <EOL> """<STR_LIT>""" <EOL> if not arg : <EOL> try : <EOL> reply = raw_input ( '<STR_LIT>' ) <EOL> except EOFError : <EOL> reply = '<STR_LIT>' <EOL> reply = reply . strip ( ) . lower ( ) <EOL> if reply in ( '<STR_LIT:y>' , '<STR_LIT:yes>' ) : <EOL> self . clear_all_breaks ( ) <EOL> return <EOL> if '<STR_LIT::>' in arg : <EOL> i = arg . rfind ( '<STR_LIT::>' ) <EOL> filename = arg [ : i ] <EOL> arg = arg [ i + <NUM_LIT:1> : ] <EOL> try : <EOL> lineno = int ( arg ) <EOL> except ValueError : <EOL> err = "<STR_LIT>" % arg <EOL> else : <EOL> err = self . clear_break ( filename , lineno ) <EOL> if err : print >> self . stdout , '<STR_LIT>' , err <EOL> return <EOL> numberlist = arg . split ( ) <EOL> for i in numberlist : <EOL> try : <EOL> i = int ( i ) <EOL> except ValueError : <EOL> print >> self . stdout , '<STR_LIT>' % i <EOL> continue <EOL> if not ( <NUM_LIT:0> <= i < len ( bdb . Breakpoint . bpbynumber ) ) : <EOL> print >> self . stdout , '<STR_LIT>' , i <EOL> continue <EOL> err = self . clear_bpbynumber ( i ) <EOL> if err : <EOL> print >> self . stdout , '<STR_LIT>' , err <EOL> else : <EOL> print >> self . stdout , '<STR_LIT>' , i <EOL> do_cl = do_clear <EOL> def do_where ( self , arg ) : <EOL> self . print_stack_trace ( ) <EOL> do_w = do_where <EOL> do_bt = do_where <EOL> def do_up ( self , arg ) : <EOL> if self . curindex == <NUM_LIT:0> : <EOL> print >> self . stdout , '<STR_LIT>' <EOL> else : <EOL> self . curindex = self . curindex - <NUM_LIT:1> <EOL> self . curframe = self . stack [ self . curindex ] [ <NUM_LIT:0> ] <EOL> self . curframe_locals = self . curframe . f_locals <EOL> self . print_stack_entry ( self . stack [ self . curindex ] ) <EOL> self . lineno = None <EOL> do_u = do_up <EOL> def do_down ( self , arg ) : <EOL> if self . curindex + <NUM_LIT:1> == len ( self . stack ) : <EOL> print >> self . stdout , '<STR_LIT>' <EOL> else : <EOL> self . curindex = self . curindex + <NUM_LIT:1> <EOL> self . curframe = self . stack [ self . curindex ] [ <NUM_LIT:0> ] <EOL> self . curframe_locals = self . curframe . f_locals <EOL> self . print_stack_entry ( self . stack [ self . curindex ] ) <EOL> self . lineno = None <EOL> do_d = do_down <EOL> def do_until ( self , arg ) : <EOL> self . set_until ( self . curframe ) <EOL> return <NUM_LIT:1> <EOL> do_unt = do_until <EOL> def do_step ( self , arg ) : <EOL> self . set_step ( ) <EOL> return <NUM_LIT:1> <EOL> do_s = do_step <EOL> def do_next ( self , arg ) : <EOL> self . set_next ( self . curframe ) <EOL> return <NUM_LIT:1> <EOL> do_n = do_next <EOL> def do_run ( self , arg ) : <EOL> """<STR_LIT>""" <EOL> if arg : <EOL> import shlex <EOL> argv0 = sys . argv [ <NUM_LIT:0> : <NUM_LIT:1> ] <EOL> sys . argv = shlex . split ( arg ) <EOL> sys . argv [ : <NUM_LIT:0> ] = argv0 <EOL> raise Restart <EOL> do_restart = do_run <EOL> def do_return ( self , arg ) : <EOL> self . set_return ( self . curframe ) <EOL> return <NUM_LIT:1> <EOL> do_r = do_return <EOL> def do_continue ( self , arg ) : <EOL> self . set_continue ( ) <EOL> return <NUM_LIT:1> <EOL> do_c = do_cont = do_continue <EOL> def do_jump ( self , arg ) : <EOL> if self . curindex + <NUM_LIT:1> != len ( self . stack ) : <EOL> print >> self . stdout , "<STR_LIT>" <EOL> return <EOL> try : <EOL> arg = int ( arg ) <EOL> except ValueError : <EOL> print >> self . stdout , "<STR_LIT>" <EOL> else : <EOL> try : <EOL> self . curframe . f_lineno = arg <EOL> self . stack [ self . curindex ] = self . stack [ self . curindex ] [ <NUM_LIT:0> ] , arg <EOL> self . print_stack_entry ( self . stack [ self . curindex ] ) <EOL> except ValueError , e : <EOL> print >> self . stdout , '<STR_LIT>' , e <EOL> do_j = do_jump <EOL> def do_debug ( self , arg ) : <EOL> sys . settrace ( None ) <EOL> globals = self . curframe . f_globals <EOL> locals = self . curframe_locals <EOL> p = Pdb ( self . completekey , self . stdin , self . stdout ) <EOL> p . prompt = "<STR_LIT>" % self . prompt . strip ( ) <EOL> print >> self . stdout , "<STR_LIT>" <EOL> sys . call_tracing ( p . run , ( arg , globals , locals ) ) <EOL> print >> self . stdout , "<STR_LIT>" <EOL> sys . settrace ( self . trace_dispatch ) <EOL> self . lastcmd = p . lastcmd <EOL> def do_quit ( self , arg ) : <EOL> self . _user_requested_quit = <NUM_LIT:1> <EOL> self . set_quit ( ) <EOL> return <NUM_LIT:1> <EOL> do_q = do_quit <EOL> do_exit = do_quit <EOL> def do_EOF ( self , arg ) : <EOL> print >> self . stdout <EOL> self . _user_requested_quit = <NUM_LIT:1> <EOL> self . set_quit ( ) <EOL> return <NUM_LIT:1> <EOL> def do_args ( self , arg ) : <EOL> co = self . curframe . f_code <EOL> dict = self . curframe_locals <EOL> n = co . co_argcount <EOL> if co . co_flags & <NUM_LIT:4> : n = n + <NUM_LIT:1> <EOL> if co . co_flags & <NUM_LIT:8> : n = n + <NUM_LIT:1> <EOL> for i in range ( n ) : <EOL> name = co . co_varnames [ i ] <EOL> print >> self . stdout , name , '<STR_LIT:=>' , <EOL> if name in dict : print >> self . stdout , dict [ name ] <EOL> else : print >> self . stdout , "<STR_LIT>" <EOL> do_a = do_args <EOL> def do_retval ( self , arg ) : <EOL> if '<STR_LIT>' in self . curframe_locals : <EOL> print >> self . stdout , self . curframe_locals [ '<STR_LIT>' ] <EOL> else : <EOL> print >> self . stdout , '<STR_LIT>' <EOL> do_rv = do_retval <EOL> def _getval ( self , arg ) : <EOL> try : <EOL> return eval ( arg , self . curframe . f_globals , <EOL> self . curframe_locals ) <EOL> except : <EOL> t , v = sys . exc_info ( ) [ : <NUM_LIT:2> ] <EOL> if isinstance ( t , str ) : <EOL> exc_type_name = t <EOL> else : exc_type_name = t . __name__ <EOL> print >> self . stdout , '<STR_LIT>' , exc_type_name + '<STR_LIT::>' , repr ( v ) <EOL> raise <EOL> def do_p ( self , arg ) : <EOL> try : <EOL> print >> self . stdout , repr ( self . _getval ( arg ) ) <EOL> except : <EOL> pass <EOL> def do_pp ( self , arg ) : <EOL> try : <EOL> pprint . pprint ( self . _getval ( arg ) , self . stdout ) <EOL> except : <EOL> pass <EOL> def do_list ( self , arg ) : <EOL> self . lastcmd = '<STR_LIT:list>' <EOL> last = None <EOL> if arg : <EOL> try : <EOL> x = eval ( arg , { } , { } ) <EOL> if type ( x ) == type ( ( ) ) : <EOL> first , last = x <EOL> first = int ( first ) <EOL> last = int ( last ) <EOL> if last < first : <EOL> last = first + last <EOL> else : <EOL> first = max ( <NUM_LIT:1> , int ( x ) - <NUM_LIT:5> ) <EOL> except : <EOL> print >> self . stdout , '<STR_LIT>' , repr ( arg ) <EOL> return <EOL> elif self . lineno is None : <EOL> first = max ( <NUM_LIT:1> , self . curframe . f_lineno - <NUM_LIT:5> ) <EOL> else : <EOL> first = self . lineno + <NUM_LIT:1> <EOL> if last is None : <EOL> last = first + <NUM_LIT:10> <EOL> filename = self . curframe . f_code . co_filename <EOL> breaklist = self . get_file_breaks ( filename ) <EOL> try : <EOL> for lineno in range ( first , last + <NUM_LIT:1> ) : <EOL> line = linecache . getline ( filename , lineno , <EOL> self . curframe . f_globals ) <EOL> if not line : <EOL> print >> self . stdout , '<STR_LIT>' <EOL> break <EOL> else : <EOL> s = repr ( lineno ) . rjust ( <NUM_LIT:3> ) <EOL> if len ( s ) < <NUM_LIT:4> : s = s + '<STR_LIT:U+0020>' <EOL> if lineno in breaklist : s = s + '<STR_LIT:B>' <EOL> else : s = s + '<STR_LIT:U+0020>' <EOL> if lineno == self . curframe . f_lineno : <EOL> s = s + '<STR_LIT>' <EOL> print >> self . stdout , s + '<STR_LIT:\t>' + line , <EOL> self . lineno = lineno <EOL> except KeyboardInterrupt : <EOL> pass <EOL> do_l = do_list <EOL> def do_whatis ( self , arg ) : <EOL> try : <EOL> value = eval ( arg , self . curframe . f_globals , <EOL> self . curframe_locals ) <EOL> except : <EOL> t , v = sys . exc_info ( ) [ : <NUM_LIT:2> ] <EOL> if type ( t ) == type ( '<STR_LIT>' ) : <EOL> exc_type_name = t <EOL> else : exc_type_name = t . __name__ <EOL> print >> self . stdout , '<STR_LIT>' , exc_type_name + '<STR_LIT::>' , repr ( v ) <EOL> return <EOL> code = None <EOL> try : code = value . func_code <EOL> except : pass <EOL> if code : <EOL> print >> self . stdout , '<STR_LIT>' , code . co_name <EOL> return <EOL> try : code = value . im_func . func_code <EOL> except : pass <EOL> if code : <EOL> print >> self . stdout , '<STR_LIT>' , code . co_name <EOL> return <EOL> print >> self . stdout , type ( value ) <EOL> def do_alias ( self , arg ) : <EOL> args = arg . split ( ) <EOL> if len ( args ) == <NUM_LIT:0> : <EOL> keys = self . aliases . keys ( ) <EOL> keys . sort ( ) <EOL> for alias in keys : <EOL> print >> self . stdout , "<STR_LIT>" % ( alias , self . aliases [ alias ] ) <EOL> return <EOL> if args [ <NUM_LIT:0> ] in self . aliases and len ( args ) == <NUM_LIT:1> : <EOL> print >> self . stdout , "<STR_LIT>" % ( args [ <NUM_LIT:0> ] , self . aliases [ args [ <NUM_LIT:0> ] ] ) <EOL> else : <EOL> self . aliases [ args [ <NUM_LIT:0> ] ] = '<STR_LIT:U+0020>' . join ( args [ <NUM_LIT:1> : ] ) <EOL> def do_unalias ( self , arg ) : <EOL> args = arg . split ( ) <EOL> if len ( args ) == <NUM_LIT:0> : return <EOL> if args [ <NUM_LIT:0> ] in self . aliases : <EOL> del self . aliases [ args [ <NUM_LIT:0> ] ] <EOL> commands_resuming = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] <EOL> def print_stack_trace ( self ) : <EOL> try : <EOL> for frame_lineno in self . stack : <EOL> self . print_stack_entry ( frame_lineno ) <EOL> except KeyboardInterrupt : <EOL> pass <EOL> def print_stack_entry ( self , frame_lineno , prompt_prefix = line_prefix ) : <EOL> frame , lineno = frame_lineno <EOL> if frame is self . curframe : <EOL> print >> self . stdout , '<STR_LIT:>>' , <EOL> else : <EOL> print >> self . stdout , '<STR_LIT:U+0020>' , <EOL> print >> self . stdout , self . format_stack_entry ( frame_lineno , <EOL> prompt_prefix ) <EOL> def help_help ( self ) : <EOL> self . help_h ( ) <EOL> def help_h ( self ) : <EOL> print >> self . stdout , """<STR_LIT>""" <EOL> def help_where ( self ) : <EOL> self . help_w ( ) <EOL> def help_w ( self ) : <EOL> print >> self . stdout , """<STR_LIT>""" <EOL> help_bt = help_w <EOL> def help_down ( self ) : <EOL> self . help_d ( ) <EOL> def help_d ( self ) : <EOL> print >> self . stdout , """<STR_LIT>""" <EOL> def help_up ( self ) : <EOL> self . help_u ( ) <EOL> def help_u ( self ) : <EOL> print >> self . stdout , """<STR_LIT>""" <EOL> def help_break ( self ) : <EOL> self . help_b ( ) <EOL> def help_b ( self ) : <EOL> print >> self . stdout , """<STR_LIT>""" <EOL> def help_clear ( self ) : <EOL> self . help_cl ( ) <EOL> def help_cl ( self ) : <EOL> print >> self . stdout , "<STR_LIT>" <EOL> print >> self . stdout , """<STR_LIT>""" <EOL> def help_tbreak ( self ) : <EOL> print >> self . stdout , """<STR_LIT>""" <EOL> def help_enable ( self ) : <EOL> print >> self . stdout , """<STR_LIT>""" <EOL> def help_disable ( self ) : <EOL> print >> self . stdout , """<STR_LIT>""" <EOL> def help_ignore ( self ) : <EOL> print >> self . stdout , """<STR_LIT>""" <EOL> def help_condition ( self ) : <EOL> print >> self . stdout , """<STR_LIT>""" <EOL> def help_step ( self ) : <EOL> self . help_s ( ) <EOL> def help_s ( self ) : <EOL> print >> self . stdout , """<STR_LIT>""" <EOL> def help_until ( self ) : <EOL> self . help_unt ( ) <EOL> def help_unt ( self ) : <EOL> print """<STR_LIT>""" <EOL> def help_next ( self ) : <EOL> self . help_n ( ) <EOL> def help_n ( self ) : <EOL> print >> self . stdout , """<STR_LIT>""" <EOL> def help_return ( self ) : <EOL> self . help_r ( ) <EOL> def help_r ( self ) : <EOL> print >> self . stdout , """<STR_LIT>""" <EOL> def help_continue ( self ) : <EOL> self . help_c ( ) <EOL> def help_cont ( self ) : <EOL> self . help_c ( ) <EOL> def help_c ( self ) : <EOL> print >> self . stdout , """<STR_LIT>""" <EOL> def help_jump ( self ) : <EOL> self . help_j ( ) <EOL> def help_j ( self ) : <EOL> print >> self . stdout , """<STR_LIT>""" <EOL> def help_debug ( self ) : <EOL> print >> self . stdout , """<STR_LIT>""" <EOL> def help_list ( self ) : <EOL> self . help_l ( ) <EOL> def help_l ( self ) : <EOL> print >> self . stdout , """<STR_LIT>""" <EOL> def help_args ( self ) : <EOL> self . help_a ( ) <EOL> def help_a ( self ) : <EOL> print >> self . stdout , """<STR_LIT>""" <EOL> def help_p ( self ) : <EOL> print >> self . stdout , """<STR_LIT>""" <EOL> def help_pp ( self ) : <EOL> print >> self . stdout , """<STR_LIT>""" <EOL> def help_exec ( self ) : <EOL> print >> self . stdout , """<STR_LIT>""" <EOL> def help_run ( self ) : <EOL> print """<STR_LIT>""" <EOL> help_restart = help_run <EOL> def help_quit ( self ) : <EOL> self . help_q ( ) <EOL> def help_q ( self ) : <EOL> print >> self . stdout , """<STR_LIT>""" <EOL> help_exit = help_q <EOL> def help_whatis ( self ) : <EOL> print >> self . stdout , """<STR_LIT>""" <EOL> def help_EOF ( self ) : <EOL> print >> self . stdout , """<STR_LIT>""" <EOL> def help_alias ( self ) : <EOL> print >> self . stdout , """<STR_LIT>""" <EOL> def help_unalias ( self ) : <EOL> print >> self . stdout , """<STR_LIT>""" <EOL> def help_commands ( self ) : <EOL> print >> self . stdout , """<STR_LIT>""" <EOL> def help_pdb ( self ) : <EOL> help ( ) <EOL> def lookupmodule ( self , filename ) : <EOL> """<STR_LIT>""" <EOL> if os . path . isabs ( filename ) and os . path . exists ( filename ) : <EOL> return filename <EOL> f = os . path . join ( sys . path [ <NUM_LIT:0> ] , filename ) <EOL> if os . path . exists ( f ) and self . canonic ( f ) == self . mainpyfile : <EOL> return f <EOL> root , ext = os . path . splitext ( filename ) <EOL> if ext == '<STR_LIT>' : <EOL> filename = filename + '<STR_LIT>' <EOL> if os . path . isabs ( filename ) : <EOL> return filename <EOL> for dirname in sys . path : <EOL> while os . path . islink ( dirname ) : <EOL> dirname = os . readlink ( dirname ) <EOL> fullname = os . path . join ( dirname , filename ) <EOL> if os . path . exists ( fullname ) : <EOL> return fullname <EOL> return None <EOL> def _runscript ( self , filename ) : <EOL> import __main__ <EOL> __main__ . __dict__ . clear ( ) <EOL> __main__ . __dict__ . update ( { "<STR_LIT>" : "<STR_LIT:__main__>" , <EOL> "<STR_LIT>" : filename , <EOL> "<STR_LIT>" : __builtins__ , <EOL> } ) <EOL> self . _wait_for_mainpyfile = <NUM_LIT:1> <EOL> self . mainpyfile = self . canonic ( filename ) <EOL> self . _user_requested_quit = <NUM_LIT:0> <EOL> statement = '<STR_LIT>' % filename <EOL> self . run ( statement ) <EOL> def run ( statement , globals = None , locals = None ) : <EOL> Pdb ( ) . run ( statement , globals , locals ) <EOL> def runeval ( expression , globals = None , locals = None ) : <EOL> return Pdb ( ) . runeval ( expression , globals , locals ) <EOL> def runctx ( statement , globals , locals ) : <EOL> run ( statement , globals , locals ) <EOL> def runcall ( * args , ** kwds ) : <EOL> return Pdb ( ) . runcall ( * args , ** kwds ) <EOL> def set_trace ( ) : <EOL> Pdb ( ) . set_trace ( sys . _getframe ( ) . f_back ) <EOL> def post_mortem ( t = None ) : <EOL> if t is None : <EOL> t = sys . exc_info ( ) [ <NUM_LIT:2> ] <EOL> if t is None : <EOL> raise ValueError ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> p = Pdb ( ) <EOL> p . reset ( ) <EOL> p . interaction ( None , t ) <EOL> def pm ( ) : <EOL> post_mortem ( sys . last_traceback ) <EOL> TESTCMD = '<STR_LIT>' <EOL> def test ( ) : <EOL> run ( TESTCMD ) <EOL> def help ( ) : <EOL> for dirname in sys . path : <EOL> fullname = os . path . join ( dirname , '<STR_LIT>' ) <EOL> if os . path . exists ( fullname ) : <EOL> sts = os . system ( '<STR_LIT>' + fullname ) <EOL> if sts : print '<STR_LIT>' , sts <EOL> break <EOL> else : <EOL> print '<STR_LIT>' , <EOL> print '<STR_LIT>' <EOL> def main ( ) : <EOL> if not sys . argv [ <NUM_LIT:1> : ] or sys . argv [ <NUM_LIT:1> ] in ( "<STR_LIT>" , "<STR_LIT>" ) : <EOL> print "<STR_LIT>" <EOL> sys . exit ( <NUM_LIT:2> ) <EOL> mainpyfile = sys . argv [ <NUM_LIT:1> ] <EOL> if not os . path . exists ( mainpyfile ) : <EOL> print '<STR_LIT>' , mainpyfile , '<STR_LIT>' <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> del sys . argv [ <NUM_LIT:0> ] <EOL> sys . path [ <NUM_LIT:0> ] = os . path . dirname ( mainpyfile ) <EOL> pdb = Pdb ( ) <EOL> while True : <EOL> try : <EOL> pdb . _runscript ( mainpyfile ) <EOL> if pdb . _user_requested_quit : <EOL> break <EOL> print "<STR_LIT>" <EOL> except Restart : <EOL> print "<STR_LIT>" , mainpyfile , "<STR_LIT>" <EOL> print "<STR_LIT:\t>" + "<STR_LIT:U+0020>" . join ( sys . argv [ <NUM_LIT:1> : ] ) <EOL> except SystemExit : <EOL> print "<STR_LIT>" , <EOL> print sys . exc_info ( ) [ <NUM_LIT:1> ] <EOL> except : <EOL> traceback . print_exc ( ) <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> t = sys . exc_info ( ) [ <NUM_LIT:2> ] <EOL> pdb . interaction ( None , t ) <EOL> print "<STR_LIT>" + mainpyfile + "<STR_LIT>" <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> import pdb <EOL> pdb . main ( ) </s>
