提交 41f714b1 编写于 作者: L Lukáš Doktor 提交者: Eduardo Habkost

qemu.py: Simplify QMP key-conversion

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: NLukáš Doktor <ldoktor@redhat.com>
Reviewed-by: NEduardo Habkost <ehabkost@redhat.com>
Message-Id: <20170818142613.32394-5-ldoktor@redhat.com>
Reviewed-by: NCleber Rosa <crosa@redhat.com>
Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
上级 7f33ca78
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册