]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
qemu.py: Simplify QMP key-conversion
authorLukáš Doktor <ldoktor@redhat.com>
Fri, 18 Aug 2017 14:26:07 +0000 (16:26 +0200)
committerEduardo Habkost <ehabkost@redhat.com>
Fri, 15 Sep 2017 23:12:00 +0000 (20:12 -0300)
The QMP key conversion consist of '_'s to be replaced with '-'s, which
can easily be done by a single `str.replace` method which is faster and
does not require `string` module import.

Signed-off-by: Lukáš Doktor <ldoktor@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Message-Id: <20170818142613.32394-5-ldoktor@redhat.com>
Reviewed-by: Cleber Rosa <crosa@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
scripts/qemu.py

index d8c169b31e999a9f958fccc6c553c4ac834e0a75..bde8da8fe7b5667386b06cea5b04d7af78955f94 100644 (file)
@@ -13,7 +13,6 @@
 #
 
 import errno
-import string
 import os
 import sys
 import subprocess
@@ -195,14 +194,12 @@ class QEMUMachine(object):
             self._load_io_log()
             self._post_shutdown()
 
-    underscore_to_dash = string.maketrans('_', '-')
-
     def qmp(self, cmd, conv_keys=True, **args):
         '''Invoke a QMP command and return the response dict'''
         qmp_args = dict()
         for key, value in args.iteritems():
             if conv_keys:
-                qmp_args[key.translate(self.underscore_to_dash)] = value
+                qmp_args[key.replace('_', '-')] = value
             else:
                 qmp_args[key] = value