Re: [PATCH v2 10/11] tools/kvm_stat: sort '-f help' output

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Here's a new version of this patch, addressing the feedback.

Ciao,
Stefan


--------------------------------------------

From: Stefan Raspl <stefan.raspl@xxxxxxxxxx>

    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@xxxxxxxxxxxxxxxxxx>

diff --git a/tools/kvm/kvm_stat/kvm_stat b/tools/kvm/kvm_stat/kvm_stat
index e37ea70..99c81e0 100755
--- a/tools/kvm/kvm_stat/kvm_stat
+++ b/tools/kvm/kvm_stat/kvm_stat
@@ -1579,17 +1579,13 @@ def main():

     stats = Stats(options)

-    if options.fields == "help":
+    if options.fields == 'help':
         stats.fields_filter = None
-        event_list = "\n"
-        s = stats.get()
-        for key in s.keys():
-            if key.find('(') != -1:
-                key = key[0:key.find('(')]
-            if event_list.find('\n' + key + '\n') == -1:
-                event_list += key + '\n'
-        sys.stdout.write(event_list)
-        return ""
+        event_list = []
+        for key in stats.get().keys():
+            event_list.append(key.split('(', 1)[0])
+        sys.stdout.write('  ' + '\n  '.join(sorted(set(event_list))) + '\n')
+        sys.exit(0)

     if options.log:
         log(stats)




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux