qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v6 04/10] qemu.py: Simplify QMP key-conversion


From: Cleber Rosa
Subject: Re: [Qemu-devel] [PATCH v6 04/10] qemu.py: Simplify QMP key-conversion
Date: Thu, 24 Aug 2017 18:59:48 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1


On 08/18/2017 10:26 AM, Lukáš Doktor wrote:
> 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 db21407..19cbd34 100644
> --- a/scripts/qemu.py
> +++ b/scripts/qemu.py
> @@ -13,7 +13,6 @@
>  #
>  
>  import errno
> -import string
>  import os
>  import sys
>  import subprocess
> @@ -181,14 +180,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
>  
> 

Right, this would only make sense if multiple (different) substitutions
were necessary.

Reviewed-by: Cleber Rosa <address@hidden>

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]