[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 04/10] qemu.py: Simplify QMP key-conversion
From: |
Lukáš Doktor |
Subject: |
[Qemu-devel] [PATCH v4 04/10] qemu.py: Simplify QMP key-conversion |
Date: |
Wed, 26 Jul 2017 16:42:20 +0200 |
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 <address@hidden>
Reviewed-by: Eduardo Habkost <address@hidden>
---
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 @@
#
import errno
-import string
import os
import sys
import subprocess
@@ -180,14 +179,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 result 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
--
2.9.4
- [Qemu-devel] [PATCH v4 00/10] qemu.py: Pylint/style fixes, Lukáš Doktor, 2017/07/26
- [Qemu-devel] [PATCH v4 01/10] qemu.py: Pylint/style fixes, Lukáš Doktor, 2017/07/26
- [Qemu-devel] [PATCH v4 02/10] qemu|qtest: Avoid dangerous arguments, Lukáš Doktor, 2017/07/26
- [Qemu-devel] [PATCH v4 03/10] qemu.py: Use iteritems rather than keys(), Lukáš Doktor, 2017/07/26
- [Qemu-devel] [PATCH v4 04/10] qemu.py: Simplify QMP key-conversion,
Lukáš Doktor <=
- [Qemu-devel] [PATCH v4 05/10] qemu.py: Use custom exceptions rather than Exception, Lukáš Doktor, 2017/07/26
- [Qemu-devel] [PATCH v4 06/10] qmp.py: Couple of pylint/style fixes, Lukáš Doktor, 2017/07/26
- [Qemu-devel] [PATCH v4 07/10] qmp.py: Use object-based class for QEMUMonitorProtocol, Lukáš Doktor, 2017/07/26
- [Qemu-devel] [PATCH v4 08/10] qmp.py: Avoid "has_key" usage, Lukáš Doktor, 2017/07/26
- [Qemu-devel] [PATCH v4 09/10] qmp.py: Avoid overriding a builtin object, Lukáš Doktor, 2017/07/26
- [Qemu-devel] [PATCH v4 10/10] qtest.py: Few pylint/style fixes, Lukáš Doktor, 2017/07/26