#7395: fix traceback in do_add() when no stats are loaded. Apply same fix for do_sort() and do_reverse().
This commit is contained in:
parent
0941012325
commit
3e4f2ec704
|
@ -576,7 +576,10 @@ if __name__ == '__main__':
|
||||||
print(" that match it are printed.", file=self.stream)
|
print(" that match it are printed.", file=self.stream)
|
||||||
|
|
||||||
def do_add(self, line):
|
def do_add(self, line):
|
||||||
self.stats.add(line)
|
if self.stats:
|
||||||
|
self.stats.add(line)
|
||||||
|
else:
|
||||||
|
print("No statistics object is loaded.", file=self.stream)
|
||||||
return 0
|
return 0
|
||||||
def help_add(self):
|
def help_add(self):
|
||||||
print("Add profile info from given file to current statistics object.", file=self.stream)
|
print("Add profile info from given file to current statistics object.", file=self.stream)
|
||||||
|
@ -621,12 +624,18 @@ if __name__ == '__main__':
|
||||||
print("Read in profile data from a specified file.", file=self.stream)
|
print("Read in profile data from a specified file.", file=self.stream)
|
||||||
|
|
||||||
def do_reverse(self, line):
|
def do_reverse(self, line):
|
||||||
self.stats.reverse_order()
|
if self.stats:
|
||||||
|
self.stats.reverse_order()
|
||||||
|
else:
|
||||||
|
print("No statistics object is loaded.", file=self.stream)
|
||||||
return 0
|
return 0
|
||||||
def help_reverse(self):
|
def help_reverse(self):
|
||||||
print("Reverse the sort order of the profiling report.", file=self.stream)
|
print("Reverse the sort order of the profiling report.", file=self.stream)
|
||||||
|
|
||||||
def do_sort(self, line):
|
def do_sort(self, line):
|
||||||
|
if not self.stats:
|
||||||
|
print("No statistics object is loaded.", file=self.stream)
|
||||||
|
return
|
||||||
abbrevs = self.stats.get_sort_arg_defs()
|
abbrevs = self.stats.get_sort_arg_defs()
|
||||||
if line and all((x in abbrevs) for x in line.split()):
|
if line and all((x in abbrevs) for x in line.split()):
|
||||||
self.stats.sort_stats(*line.split())
|
self.stats.sort_stats(*line.split())
|
||||||
|
@ -648,8 +657,10 @@ if __name__ == '__main__':
|
||||||
self.generic_help()
|
self.generic_help()
|
||||||
|
|
||||||
def do_strip(self, line):
|
def do_strip(self, line):
|
||||||
self.stats.strip_dirs()
|
if self.stats:
|
||||||
return 0
|
self.stats.strip_dirs()
|
||||||
|
else:
|
||||||
|
print("No statistics object is loaded.", file=self.stream)
|
||||||
def help_strip(self):
|
def help_strip(self):
|
||||||
print("Strip leading path information from filenames in the report.", file=self.stream)
|
print("Strip leading path information from filenames in the report.", file=self.stream)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue