Skip to content

Commit aa12f59

Browse files
Stefan-Rasplbonzini
authored andcommitted
tools/kvm_stat: sort '-f help' output
Sort the fields returned by specifying '-f help' on the command line. While at it, simplify the code a bit, indent the output and eliminate an extra blank line at the beginning. Signed-off-by: Stefan Raspl <raspl@linux.vnet.ibm.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent fae1a3e commit aa12f59

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

tools/kvm/kvm_stat/kvm_stat

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,17 +1579,13 @@ def main():
15791579

15801580
stats = Stats(options)
15811581

1582-
if options.fields == "help":
1582+
if options.fields == 'help':
15831583
stats.fields_filter = None
1584-
event_list = "\n"
1585-
s = stats.get()
1586-
for key in s.keys():
1587-
if key.find('(') != -1:
1588-
key = key[0:key.find('(')]
1589-
if event_list.find('\n' + key + '\n') == -1:
1590-
event_list += key + '\n'
1591-
sys.stdout.write(event_list)
1592-
return ""
1584+
event_list = []
1585+
for key in stats.get().keys():
1586+
event_list.append(key.split('(', 1)[0])
1587+
sys.stdout.write(' ' + '\n '.join(sorted(set(event_list))) + '\n')
1588+
sys.exit(0)
15931589

15941590
if options.log:
15951591
log(stats)

0 commit comments

Comments
 (0)