[Python-checkins] CVS: python/dist/src/Lib pstats.py,1.15,1.16

Eric S. Raymond esr@users.sourceforge.net
Thu, 26 Apr 2001 00:32:40 -0700


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv9060

Modified Files:
	pstats.py 
Log Message:
Added more help, and recovery from misspelled sort key arguments.


Index: pstats.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/pstats.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -r1.15 -r1.16
*** pstats.py	2001/04/14 15:16:05	1.15
--- pstats.py	2001/04/26 07:32:38	1.16
***************
*** 569,572 ****
--- 569,579 ----
                  print "No statistics object is loaded."
              return 0
+         def generic_help(self):
+             print "Arguments may be:"
+             print "* An integer maximum number of entries to print."
+             print "* A decimal fractional number between 0 and 1, controlling"
+             print "  what fraction of selected entries to print."
+             print "* A regular expression; only entries with function names"
+             print "  that match it are printed."
  
          def do_add(self, line):
***************
*** 574,578 ****
              return 0
          def help_add(self):
!             print "Add profile info from given file to current stastics object."
  
          def do_callees(self, line):
--- 581,585 ----
              return 0
          def help_add(self):
!             print "Add profile info from given file to current statistics object."
  
          def do_callees(self, line):
***************
*** 580,583 ****
--- 587,591 ----
          def help_callees(self):
              print "Print callees statistics from the current stat object."
+             self.generic_help()
  
          def do_callers(self, line):
***************
*** 585,588 ****
--- 593,597 ----
          def help_callers(self):
              print "Print callers statistics from the current stat object."
+             self.generic_help()
  
          def do_EOF(self, line):
***************
*** 620,627 ****
  
          def do_sort(self, line):
!             apply(self.stats.sort_stats, line.split())
              return 0
          def help_sort(self):
              print "Sort profile data according to specified keys."
  
          def do_stats(self, line):
--- 629,643 ----
  
          def do_sort(self, line):
!             abbrevs = self.stats.get_sort_arg_defs().keys()
!             if line and not filter(lambda x,a=abbrevs: x not in a,line.split()):
!                 apply(self.stats.sort_stats, line.split())
!             else:
!                 print "Valid sort keys (unique prefixes are accepted):"
!                 for (key, value) in Stats.sort_arg_dict_default.items():
!                     print "%s -- %s" % (key, value[1])
              return 0
          def help_sort(self):
              print "Sort profile data according to specified keys."
+             print "(Typing `sort' without arguments lists valid keys.)"
  
          def do_stats(self, line):
***************
*** 629,632 ****
--- 645,649 ----
          def help_stats(self):
              print "Print statistics from the current stat object."
+             self.generic_help()
  
          def do_strip(self, line):