<s> """<STR_LIT>""" <EOL> """<STR_LIT>""" <EOL> import sys <EOL> import os <EOL> import time <EOL> import marshal <EOL> import re <EOL> __all__ = [ "<STR_LIT>" ] <EOL> class Stats : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , * args , ** kwds ) : <EOL> self . stream = sys . stdout <EOL> if "<STR_LIT>" in kwds : <EOL> self . stream = kwds [ "<STR_LIT>" ] <EOL> del kwds [ "<STR_LIT>" ] <EOL> if kwds : <EOL> keys = kwds . keys ( ) <EOL> keys . sort ( ) <EOL> extras = "<STR_LIT:U+002CU+0020>" . join ( [ "<STR_LIT>" % ( k , kwds [ k ] ) for k in keys ] ) <EOL> raise ValueError , "<STR_LIT>" % extras <EOL> if not len ( args ) : <EOL> arg = None <EOL> else : <EOL> arg = args [ <NUM_LIT:0> ] <EOL> args = args [ <NUM_LIT:1> : ] <EOL> self . init ( arg ) <EOL> self . add ( * args ) <EOL> def init ( self , arg ) : <EOL> self . all_callees = None <EOL> self . files = [ ] <EOL> self . fcn_list = None <EOL> self . total_tt = <NUM_LIT:0> <EOL> self . total_calls = <NUM_LIT:0> <EOL> self . prim_calls = <NUM_LIT:0> <EOL> self . max_name_len = <NUM_LIT:0> <EOL> self . top_level = { } <EOL> self . stats = { } <EOL> self . sort_arg_dict = { } <EOL> self . load_stats ( arg ) <EOL> trouble = <NUM_LIT:1> <EOL> try : <EOL> self . get_top_level_stats ( ) <EOL> trouble = <NUM_LIT:0> <EOL> finally : <EOL> if trouble : <EOL> print >> self . stream , "<STR_LIT>" , <EOL> if self . files : print >> self . stream , self . files [ - <NUM_LIT:1> ] , <EOL> print >> self . stream <EOL> def load_stats ( self , arg ) : <EOL> if not arg : self . stats = { } <EOL> elif isinstance ( arg , basestring ) : <EOL> f = open ( arg , '<STR_LIT:rb>' ) <EOL> self . stats = marshal . load ( f ) <EOL> f . close ( ) <EOL> try : <EOL> file_stats = os . stat ( arg ) <EOL> arg = time . ctime ( file_stats . st_mtime ) + "<STR_LIT:U+0020>" + arg <EOL> except : <EOL> pass <EOL> self . files = [ arg ] <EOL> elif hasattr ( arg , '<STR_LIT>' ) : <EOL> arg . create_stats ( ) <EOL> self . stats = arg . stats <EOL> arg . stats = { } <EOL> if not self . stats : <EOL> raise TypeError , "<STR_LIT>" % ( <EOL> self . __class__ , arg ) <EOL> return <EOL> def get_top_level_stats ( self ) : <EOL> for func , ( cc , nc , tt , ct , callers ) in self . stats . items ( ) : <EOL> self . total_calls += nc <EOL> self . prim_calls += cc <EOL> self . total_tt += tt <EOL> if ( "<STR_LIT>" , <NUM_LIT:0> , "<STR_LIT>" ) in callers : <EOL> self . top_level [ func ] = None <EOL> if len ( func_std_string ( func ) ) > self . max_name_len : <EOL> self . max_name_len = len ( func_std_string ( func ) ) <EOL> def add ( self , * arg_list ) : <EOL> if not arg_list : return self <EOL> if len ( arg_list ) > <NUM_LIT:1> : self . add ( * arg_list [ <NUM_LIT:1> : ] ) <EOL> other = arg_list [ <NUM_LIT:0> ] <EOL> if type ( self ) != type ( other ) or self . __class__ != other . __class__ : <EOL> other = Stats ( other ) <EOL> self . files += other . files <EOL> self . total_calls += other . total_calls <EOL> self . prim_calls += other . prim_calls <EOL> self . total_tt += other . total_tt <EOL> for func in other . top_level : <EOL> self . top_level [ func ] = None <EOL> if self . max_name_len < other . max_name_len : <EOL> self . max_name_len = other . max_name_len <EOL> self . fcn_list = None <EOL> for func , stat in other . stats . iteritems ( ) : <EOL> if func in self . stats : <EOL> old_func_stat = self . stats [ func ] <EOL> else : <EOL> old_func_stat = ( <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , <NUM_LIT:0> , { } , ) <EOL> self . stats [ func ] = add_func_stats ( old_func_stat , stat ) <EOL> return self <EOL> def dump_stats ( self , filename ) : <EOL> """<STR_LIT>""" <EOL> f = file ( filename , '<STR_LIT:wb>' ) <EOL> try : <EOL> marshal . dump ( self . stats , f ) <EOL> finally : <EOL> f . close ( ) <EOL> sort_arg_dict_default = { <EOL> "<STR_LIT>" : ( ( ( <NUM_LIT:1> , - <NUM_LIT:1> ) , ) , "<STR_LIT>" ) , <EOL> "<STR_LIT>" : ( ( ( <NUM_LIT:3> , - <NUM_LIT:1> ) , ) , "<STR_LIT>" ) , <EOL> "<STR_LIT:file>" : ( ( ( <NUM_LIT:4> , <NUM_LIT:1> ) , ) , "<STR_LIT>" ) , <EOL> "<STR_LIT>" : ( ( ( <NUM_LIT:5> , <NUM_LIT:1> ) , ) , "<STR_LIT>" ) , <EOL> "<STR_LIT>" : ( ( ( <NUM_LIT:4> , <NUM_LIT:1> ) , ) , "<STR_LIT>" ) , <EOL> "<STR_LIT:name>" : ( ( ( <NUM_LIT:6> , <NUM_LIT:1> ) , ) , "<STR_LIT>" ) , <EOL> "<STR_LIT>" : ( ( ( <NUM_LIT:6> , <NUM_LIT:1> ) , ( <NUM_LIT:4> , <NUM_LIT:1> ) , ( <NUM_LIT:5> , <NUM_LIT:1> ) , ) , "<STR_LIT>" ) , <EOL> "<STR_LIT>" : ( ( ( <NUM_LIT:0> , - <NUM_LIT:1> ) , ) , "<STR_LIT>" ) , <EOL> "<STR_LIT>" : ( ( ( <NUM_LIT:7> , <NUM_LIT:1> ) , ) , "<STR_LIT>" ) , <EOL> "<STR_LIT:time>" : ( ( ( <NUM_LIT:2> , - <NUM_LIT:1> ) , ) , "<STR_LIT>" ) , <EOL> } <EOL> def get_sort_arg_defs ( self ) : <EOL> """<STR_LIT>""" <EOL> if not self . sort_arg_dict : <EOL> self . sort_arg_dict = dict = { } <EOL> bad_list = { } <EOL> for word , tup in self . sort_arg_dict_default . iteritems ( ) : <EOL> fragment = word <EOL> while fragment : <EOL> if not fragment : <EOL> break <EOL> if fragment in dict : <EOL> bad_list [ fragment ] = <NUM_LIT:0> <EOL> break <EOL> dict [ fragment ] = tup <EOL> fragment = fragment [ : - <NUM_LIT:1> ] <EOL> for word in bad_list : <EOL> del dict [ word ] <EOL> return self . sort_arg_dict <EOL> def sort_stats ( self , * field ) : <EOL> if not field : <EOL> self . fcn_list = <NUM_LIT:0> <EOL> return self <EOL> if len ( field ) == <NUM_LIT:1> and type ( field [ <NUM_LIT:0> ] ) == type ( <NUM_LIT:1> ) : <EOL> field = [ { - <NUM_LIT:1> : "<STR_LIT>" , <EOL> <NUM_LIT:0> : "<STR_LIT>" , <EOL> <NUM_LIT:1> : "<STR_LIT:time>" , <EOL> <NUM_LIT:2> : "<STR_LIT>" } [ field [ <NUM_LIT:0> ] ] ] <EOL> sort_arg_defs = self . get_sort_arg_defs ( ) <EOL> sort_tuple = ( ) <EOL> self . sort_type = "<STR_LIT>" <EOL> connector = "<STR_LIT>" <EOL> for word in field : <EOL> sort_tuple = sort_tuple + sort_arg_defs [ word ] [ <NUM_LIT:0> ] <EOL> self . sort_type += connector + sort_arg_defs [ word ] [ <NUM_LIT:1> ] <EOL> connector = "<STR_LIT:U+002CU+0020>" <EOL> stats_list = [ ] <EOL> for func , ( cc , nc , tt , ct , callers ) in self . stats . iteritems ( ) : <EOL> stats_list . append ( ( cc , nc , tt , ct ) + func + <EOL> ( func_std_string ( func ) , func ) ) <EOL> stats_list . sort ( key = CmpToKey ( TupleComp ( sort_tuple ) . compare ) ) <EOL> self . fcn_list = fcn_list = [ ] <EOL> for tuple in stats_list : <EOL> fcn_list . append ( tuple [ - <NUM_LIT:1> ] ) <EOL> return self <EOL> def reverse_order ( self ) : <EOL> if self . fcn_list : <EOL> self . fcn_list . reverse ( ) <EOL> return self <EOL> def strip_dirs ( self ) : <EOL> oldstats = self . stats <EOL> self . stats = newstats = { } <EOL> max_name_len = <NUM_LIT:0> <EOL> for func , ( cc , nc , tt , ct , callers ) in oldstats . iteritems ( ) : <EOL> newfunc = func_strip_path ( func ) <EOL> if len ( func_std_string ( newfunc ) ) > max_name_len : <EOL> max_name_len = len ( func_std_string ( newfunc ) ) <EOL> newcallers = { } <EOL> for func2 , caller in callers . iteritems ( ) : <EOL> newcallers [ func_strip_path ( func2 ) ] = caller <EOL> if newfunc in newstats : <EOL> newstats [ newfunc ] = add_func_stats ( <EOL> newstats [ newfunc ] , <EOL> ( cc , nc , tt , ct , newcallers ) ) <EOL> else : <EOL> newstats [ newfunc ] = ( cc , nc , tt , ct , newcallers ) <EOL> old_top = self . top_level <EOL> self . top_level = new_top = { } <EOL> for func in old_top : <EOL> new_top [ func_strip_path ( func ) ] = None <EOL> self . max_name_len = max_name_len <EOL> self . fcn_list = None <EOL> self . all_callees = None <EOL> return self <EOL> def calc_callees ( self ) : <EOL> if self . all_callees : return <EOL> self . all_callees = all_callees = { } <EOL> for func , ( cc , nc , tt , ct , callers ) in self . stats . iteritems ( ) : <EOL> if not func in all_callees : <EOL> all_callees [ func ] = { } <EOL> for func2 , caller in callers . iteritems ( ) : <EOL> if not func2 in all_callees : <EOL> all_callees [ func2 ] = { } <EOL> all_callees [ func2 ] [ func ] = caller <EOL> return <EOL> def eval_print_amount ( self , sel , list , msg ) : <EOL> new_list = list <EOL> if type ( sel ) == type ( "<STR_LIT>" ) : <EOL> new_list = [ ] <EOL> for func in list : <EOL> if re . search ( sel , func_std_string ( func ) ) : <EOL> new_list . append ( func ) <EOL> else : <EOL> count = len ( list ) <EOL> if type ( sel ) == type ( <NUM_LIT:1.0> ) and <NUM_LIT:0.0> <= sel < <NUM_LIT:1.0> : <EOL> count = int ( count * sel + <NUM_LIT> ) <EOL> new_list = list [ : count ] <EOL> elif type ( sel ) == type ( <NUM_LIT:1> ) and <NUM_LIT:0> <= sel < count : <EOL> count = sel <EOL> new_list = list [ : count ] <EOL> if len ( list ) != len ( new_list ) : <EOL> msg = msg + "<STR_LIT>" % ( <EOL> len ( list ) , len ( new_list ) , sel ) <EOL> return new_list , msg <EOL> def get_print_list ( self , sel_list ) : <EOL> width = self . max_name_len <EOL> if self . fcn_list : <EOL> list = self . fcn_list [ : ] <EOL> msg = "<STR_LIT>" + self . sort_type + '<STR_LIT:\n>' <EOL> else : <EOL> list = self . stats . keys ( ) <EOL> msg = "<STR_LIT>" <EOL> for selection in sel_list : <EOL> list , msg = self . eval_print_amount ( selection , list , msg ) <EOL> count = len ( list ) <EOL> if not list : <EOL> return <NUM_LIT:0> , list <EOL> print >> self . stream , msg <EOL> if count < len ( self . stats ) : <EOL> width = <NUM_LIT:0> <EOL> for func in list : <EOL> if len ( func_std_string ( func ) ) > width : <EOL> width = len ( func_std_string ( func ) ) <EOL> return width + <NUM_LIT:2> , list <EOL> def print_stats ( self , * amount ) : <EOL> for filename in self . files : <EOL> print >> self . stream , filename <EOL> if self . files : print >> self . stream <EOL> indent = '<STR_LIT:U+0020>' * <NUM_LIT:8> <EOL> for func in self . top_level : <EOL> print >> self . stream , indent , func_get_function_name ( func ) <EOL> print >> self . stream , indent , self . total_calls , "<STR_LIT>" , <EOL> if self . total_calls != self . prim_calls : <EOL> print >> self . stream , "<STR_LIT>" % self . prim_calls , <EOL> print >> self . stream , "<STR_LIT>" % self . total_tt <EOL> print >> self . stream <EOL> width , list = self . get_print_list ( amount ) <EOL> if list : <EOL> self . print_title ( ) <EOL> for func in list : <EOL> self . print_line ( func ) <EOL> print >> self . stream <EOL> print >> self . stream <EOL> return self <EOL> def print_callees ( self , * amount ) : <EOL> width , list = self . get_print_list ( amount ) <EOL> if list : <EOL> self . calc_callees ( ) <EOL> self . print_call_heading ( width , "<STR_LIT>" ) <EOL> for func in list : <EOL> if func in self . all_callees : <EOL> self . print_call_line ( width , func , self . all_callees [ func ] ) <EOL> else : <EOL> self . print_call_line ( width , func , { } ) <EOL> print >> self . stream <EOL> print >> self . stream <EOL> return self <EOL> def print_callers ( self , * amount ) : <EOL> width , list = self . get_print_list ( amount ) <EOL> if list : <EOL> self . print_call_heading ( width , "<STR_LIT>" ) <EOL> for func in list : <EOL> cc , nc , tt , ct , callers = self . stats [ func ] <EOL> self . print_call_line ( width , func , callers , "<STR_LIT>" ) <EOL> print >> self . stream <EOL> print >> self . stream <EOL> return self <EOL> def print_call_heading ( self , name_size , column_title ) : <EOL> print >> self . stream , "<STR_LIT>" . ljust ( name_size ) + column_title <EOL> subheader = False <EOL> for cc , nc , tt , ct , callers in self . stats . itervalues ( ) : <EOL> if callers : <EOL> value = callers . itervalues ( ) . next ( ) <EOL> subheader = isinstance ( value , tuple ) <EOL> break <EOL> if subheader : <EOL> print >> self . stream , "<STR_LIT:U+0020>" * name_size + "<STR_LIT>" <EOL> def print_call_line ( self , name_size , source , call_dict , arrow = "<STR_LIT>" ) : <EOL> print >> self . stream , func_std_string ( source ) . ljust ( name_size ) + arrow , <EOL> if not call_dict : <EOL> print >> self . stream <EOL> return <EOL> clist = call_dict . keys ( ) <EOL> clist . sort ( ) <EOL> indent = "<STR_LIT>" <EOL> for func in clist : <EOL> name = func_std_string ( func ) <EOL> value = call_dict [ func ] <EOL> if isinstance ( value , tuple ) : <EOL> nc , cc , tt , ct = value <EOL> if nc != cc : <EOL> substats = '<STR_LIT>' % ( nc , cc ) <EOL> else : <EOL> substats = '<STR_LIT>' % ( nc , ) <EOL> substats = '<STR_LIT>' % ( substats . rjust ( <NUM_LIT:7> + <NUM_LIT:2> * len ( indent ) ) , <EOL> f8 ( tt ) , f8 ( ct ) , name ) <EOL> left_width = name_size + <NUM_LIT:1> <EOL> else : <EOL> substats = '<STR_LIT>' % ( name , value , f8 ( self . stats [ func ] [ <NUM_LIT:3> ] ) ) <EOL> left_width = name_size + <NUM_LIT:3> <EOL> print >> self . stream , indent * left_width + substats <EOL> indent = "<STR_LIT:U+0020>" <EOL> def print_title ( self ) : <EOL> print >> self . stream , '<STR_LIT>' , <EOL> print >> self . stream , '<STR_LIT>' <EOL> def print_line ( self , func ) : <EOL> cc , nc , tt , ct , callers = self . stats [ func ] <EOL> c = str ( nc ) <EOL> if nc != cc : <EOL> c = c + '<STR_LIT:/>' + str ( cc ) <EOL> print >> self . stream , c . rjust ( <NUM_LIT:9> ) , <EOL> print >> self . stream , f8 ( tt ) , <EOL> if nc == <NUM_LIT:0> : <EOL> print >> self . stream , '<STR_LIT:U+0020>' * <NUM_LIT:8> , <EOL> else : <EOL> print >> self . stream , f8 ( float ( tt ) / nc ) , <EOL> print >> self . stream , f8 ( ct ) , <EOL> if cc == <NUM_LIT:0> : <EOL> print >> self . stream , '<STR_LIT:U+0020>' * <NUM_LIT:8> , <EOL> else : <EOL> print >> self . stream , f8 ( float ( ct ) / cc ) , <EOL> print >> self . stream , func_std_string ( func ) <EOL> class TupleComp : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , comp_select_list ) : <EOL> self . comp_select_list = comp_select_list <EOL> def compare ( self , left , right ) : <EOL> for index , direction in self . comp_select_list : <EOL> l = left [ index ] <EOL> r = right [ index ] <EOL> if l < r : <EOL> return - direction <EOL> if l > r : <EOL> return direction <EOL> return <NUM_LIT:0> <EOL> def CmpToKey ( mycmp ) : <EOL> """<STR_LIT>""" <EOL> class K ( object ) : <EOL> def __init__ ( self , obj ) : <EOL> self . obj = obj <EOL> def __lt__ ( self , other ) : <EOL> return mycmp ( self . obj , other . obj ) == - <NUM_LIT:1> <EOL> return K <EOL> def func_strip_path ( func_name ) : <EOL> filename , line , name = func_name <EOL> return os . path . basename ( filename ) , line , name <EOL> def func_get_function_name ( func ) : <EOL> return func [ <NUM_LIT:2> ] <EOL> def func_std_string ( func_name ) : <EOL> if func_name [ : <NUM_LIT:2> ] == ( '<STR_LIT>' , <NUM_LIT:0> ) : <EOL> name = func_name [ <NUM_LIT:2> ] <EOL> if name . startswith ( '<STR_LIT:<>' ) and name . endswith ( '<STR_LIT:>>' ) : <EOL> return '<STR_LIT>' % name [ <NUM_LIT:1> : - <NUM_LIT:1> ] <EOL> else : <EOL> return name <EOL> else : <EOL> return "<STR_LIT>" % func_name <EOL> def add_func_stats ( target , source ) : <EOL> """<STR_LIT>""" <EOL> cc , nc , tt , ct , callers = source <EOL> t_cc , t_nc , t_tt , t_ct , t_callers = target <EOL> return ( cc + t_cc , nc + t_nc , tt + t_tt , ct + t_ct , <EOL> add_callers ( t_callers , callers ) ) <EOL> def add_callers ( target , source ) : <EOL> """<STR_LIT>""" <EOL> new_callers = { } <EOL> for func , caller in target . iteritems ( ) : <EOL> new_callers [ func ] = caller <EOL> for func , caller in source . iteritems ( ) : <EOL> if func in new_callers : <EOL> if isinstance ( caller , tuple ) : <EOL> new_callers [ func ] = tuple ( [ i [ <NUM_LIT:0> ] + i [ <NUM_LIT:1> ] for i in <EOL> zip ( caller , new_callers [ func ] ) ] ) <EOL> else : <EOL> new_callers [ func ] += caller <EOL> else : <EOL> new_callers [ func ] = caller <EOL> return new_callers <EOL> def count_calls ( callers ) : <EOL> """<STR_LIT>""" <EOL> nc = <NUM_LIT:0> <EOL> for calls in callers . itervalues ( ) : <EOL> nc += calls <EOL> return nc <EOL> def f8 ( x ) : <EOL> return "<STR_LIT>" % x <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> import cmd <EOL> try : <EOL> import readline <EOL> except ImportError : <EOL> pass <EOL> class ProfileBrowser ( cmd . Cmd ) : <EOL> def __init__ ( self , profile = None ) : <EOL> cmd . Cmd . __init__ ( self ) <EOL> self . prompt = "<STR_LIT>" <EOL> if profile is not None : <EOL> self . stats = Stats ( profile ) <EOL> self . stream = self . stats . stream <EOL> else : <EOL> self . stats = None <EOL> self . stream = sys . stdout <EOL> def generic ( self , fn , line ) : <EOL> args = line . split ( ) <EOL> processed = [ ] <EOL> for term in args : <EOL> try : <EOL> processed . append ( int ( term ) ) <EOL> continue <EOL> except ValueError : <EOL> pass <EOL> try : <EOL> frac = float ( term ) <EOL> if frac > <NUM_LIT:1> or frac < <NUM_LIT:0> : <EOL> print >> self . stream , "<STR_LIT>" <EOL> continue <EOL> processed . append ( frac ) <EOL> continue <EOL> except ValueError : <EOL> pass <EOL> processed . append ( term ) <EOL> if self . stats : <EOL> getattr ( self . stats , fn ) ( * processed ) <EOL> else : <EOL> print >> self . stream , "<STR_LIT>" <EOL> return <NUM_LIT:0> <EOL> def generic_help ( self ) : <EOL> print >> self . stream , "<STR_LIT>" <EOL> print >> self . stream , "<STR_LIT>" <EOL> print >> self . stream , "<STR_LIT>" <EOL> print >> self . stream , "<STR_LIT>" <EOL> print >> self . stream , "<STR_LIT>" <EOL> print >> self . stream , "<STR_LIT>" <EOL> def do_add ( self , line ) : <EOL> if self . stats : <EOL> self . stats . add ( line ) <EOL> else : <EOL> print >> self . stream , "<STR_LIT>" <EOL> return <NUM_LIT:0> <EOL> def help_add ( self ) : <EOL> print >> self . stream , "<STR_LIT>" <EOL> def do_callees ( self , line ) : <EOL> return self . generic ( '<STR_LIT>' , line ) <EOL> def help_callees ( self ) : <EOL> print >> self . stream , "<STR_LIT>" <EOL> self . generic_help ( ) <EOL> def do_callers ( self , line ) : <EOL> return self . generic ( '<STR_LIT>' , line ) <EOL> def help_callers ( self ) : <EOL> print >> self . stream , "<STR_LIT>" <EOL> self . generic_help ( ) <EOL> def do_EOF ( self , line ) : <EOL> print >> self . stream , "<STR_LIT>" <EOL> return <NUM_LIT:1> <EOL> def help_EOF ( self ) : <EOL> print >> self . stream , "<STR_LIT>" <EOL> def do_quit ( self , line ) : <EOL> return <NUM_LIT:1> <EOL> def help_quit ( self ) : <EOL> print >> self . stream , "<STR_LIT>" <EOL> def do_read ( self , line ) : <EOL> if line : <EOL> try : <EOL> self . stats = Stats ( line ) <EOL> except IOError , args : <EOL> print >> self . stream , args [ <NUM_LIT:1> ] <EOL> return <EOL> except Exception as err : <EOL> print >> self . stream , err . __class__ . __name__ + '<STR_LIT::>' , err <EOL> return <EOL> self . prompt = line + "<STR_LIT>" <EOL> elif len ( self . prompt ) > <NUM_LIT:2> : <EOL> line = self . prompt [ : - <NUM_LIT:2> ] <EOL> self . do_read ( line ) <EOL> else : <EOL> print >> self . stream , "<STR_LIT>" <EOL> return <NUM_LIT:0> <EOL> def help_read ( self ) : <EOL> print >> self . stream , "<STR_LIT>" <EOL> print >> self . stream , "<STR_LIT>" <EOL> def do_reverse ( self , line ) : <EOL> if self . stats : <EOL> self . stats . reverse_order ( ) <EOL> else : <EOL> print >> self . stream , "<STR_LIT>" <EOL> return <NUM_LIT:0> <EOL> def help_reverse ( self ) : <EOL> print >> self . stream , "<STR_LIT>" <EOL> def do_sort ( self , line ) : <EOL> if not self . stats : <EOL> print >> self . stream , "<STR_LIT>" <EOL> return <EOL> abbrevs = self . stats . get_sort_arg_defs ( ) <EOL> if line and not filter ( lambda x , a = abbrevs : x not in a , line . split ( ) ) : <EOL> self . stats . sort_stats ( * line . split ( ) ) <EOL> else : <EOL> print >> self . stream , "<STR_LIT>" <EOL> for ( key , value ) in Stats . sort_arg_dict_default . iteritems ( ) : <EOL> print >> self . stream , "<STR_LIT>" % ( key , value [ <NUM_LIT:1> ] ) <EOL> return <NUM_LIT:0> <EOL> def help_sort ( self ) : <EOL> print >> self . stream , "<STR_LIT>" <EOL> print >> self . stream , "<STR_LIT>" <EOL> def complete_sort ( self , text , * args ) : <EOL> return [ a for a in Stats . sort_arg_dict_default if a . startswith ( text ) ] <EOL> def do_stats ( self , line ) : <EOL> return self . generic ( '<STR_LIT>' , line ) <EOL> def help_stats ( self ) : <EOL> print >> self . stream , "<STR_LIT>" <EOL> self . generic_help ( ) <EOL> def do_strip ( self , line ) : <EOL> if self . stats : <EOL> self . stats . strip_dirs ( ) <EOL> else : <EOL> print >> self . stream , "<STR_LIT>" <EOL> def help_strip ( self ) : <EOL> print >> self . stream , "<STR_LIT>" <EOL> def help_help ( self ) : <EOL> print >> self . stream , "<STR_LIT>" <EOL> def postcmd ( self , stop , line ) : <EOL> if stop : <EOL> return stop <EOL> return None <EOL> import sys <EOL> if len ( sys . argv ) > <NUM_LIT:1> : <EOL> initprofile = sys . argv [ <NUM_LIT:1> ] <EOL> else : <EOL> initprofile = None <EOL> try : <EOL> browser = ProfileBrowser ( initprofile ) <EOL> print >> browser . stream , "<STR_LIT>" <EOL> browser . cmdloop ( ) <EOL> print >> browser . stream , "<STR_LIT>" <EOL> except KeyboardInterrupt : <EOL> pass </s>
