From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40098) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daNWh-0000Tg-DH for qemu-devel@nongnu.org; Wed, 26 Jul 2017 10:43:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1daNWe-0006IR-8M for qemu-devel@nongnu.org; Wed, 26 Jul 2017 10:43:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:23247) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1daNWe-0006Hw-2N for qemu-devel@nongnu.org; Wed, 26 Jul 2017 10:43:00 -0400 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= Date: Wed, 26 Jul 2017 16:42:20 +0200 Message-Id: <20170726144226.6913-5-ldoktor@redhat.com> In-Reply-To: <20170726144226.6913-1-ldoktor@redhat.com> References: <20170726144226.6913-1-ldoktor@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v4 04/10] qemu.py: Simplify QMP key-conversion List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: ldoktor@redhat.com, famz@redhat.com, ehabkost@redhat.com, apahim@redhat.com, armbru@redhat.com, mreitz@redhat.com, jsnow@redhat.com, f4bug@amsat.org 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=C3=A1=C5=A1 Doktor Reviewed-by: Eduardo Habkost --- scripts/qemu.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts/qemu.py b/scripts/qemu.py index 7e95c25..5948e19 100644 --- a/scripts/qemu.py +++ b/scripts/qemu.py @@ -13,7 +13,6 @@ # =20 import errno -import string import os import sys import subprocess @@ -180,14 +179,12 @@ class QEMUMachine(object): self._load_io_log() self._post_shutdown() =20 - underscore_to_dash =3D string.maketrans('_', '-') - def qmp(self, cmd, conv_keys=3DTrue, **args): '''Invoke a QMP command and return the result dict''' qmp_args =3D dict() for key, value in args.iteritems(): if conv_keys: - qmp_args[key.translate(self.underscore_to_dash)] =3D val= ue + qmp_args[key.replace('_', '-')] =3D value else: qmp_args[key] =3D value =20 --=20 2.9.4