From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56713) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ykve2-0003CO-31 for qemu-devel@nongnu.org; Wed, 22 Apr 2015 10:28:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ykvdx-0004ZO-VC for qemu-devel@nongnu.org; Wed, 22 Apr 2015 10:28:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47878) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ykvdx-0004Yo-Mq for qemu-devel@nongnu.org; Wed, 22 Apr 2015 10:28:49 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t3MESnsi012725 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 22 Apr 2015 10:28:49 -0400 Message-ID: <5537B020.4000408@redhat.com> Date: Wed, 22 Apr 2015 08:28:48 -0600 From: Eric Blake MIME-Version: 1.0 References: <1429668155-1606-1-git-send-email-jsnow@redhat.com> <1429668155-1606-3-git-send-email-jsnow@redhat.com> In-Reply-To: <1429668155-1606-3-git-send-email-jsnow@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="akFa66uObJjffvrKt22M6qtwN4iWOjMnp" Subject: Re: [Qemu-devel] [PATCH 2/5] scripts: qmp-shell: add support for [] expressions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: John Snow , qemu-devel@nongnu.org Cc: kchamart@redhat.com, lcapitulino@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --akFa66uObJjffvrKt22M6qtwN4iWOjMnp Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 04/21/2015 08:02 PM, John Snow wrote: > qmp-shell currently allows you to describe values as > JSON expressions: >=20 > key=3D{"key":{"key2":"val"}} >=20 > But it does not currently support arrays, which are needed > for serializing and deserializing transactions: >=20 > key=3D[{"type":"drive-backup","data":{...}}] >=20 > Add support for arrays. >=20 > CAVEAT: The parser is still extremely rudimentary and does not > expect to find spaces in {} nor [] expressions. This patch does > not improve this functionality. >=20 > Signed-off-by: John Snow > --- > scripts/qmp/qmp-shell | 2 ++ > 1 file changed, 2 insertions(+) >=20 > diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell > index a9632ec..5347f89 100755 > --- a/scripts/qmp/qmp-shell > +++ b/scripts/qmp/qmp-shell > @@ -102,6 +102,8 @@ class QMPShell(qmp.QEMUMonitorProtocol): > value =3D False > elif opt[1].startswith('{'): > value =3D json.loads(opt[1]) > + elif opt[1].startswith('['): > + value =3D json.loads(opt[1]) Why not: elif opt[1].startswith('{'} or opt[1].startswith('['): for a one-line change instead of two-line addition? And I'm no python expert, but I think you can write that with fewer characters. Untested, but does this work? elif opt[1][0] in "{[": --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --akFa66uObJjffvrKt22M6qtwN4iWOjMnp Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJVN7AgAAoJEKeha0olJ0Nq+hIH/2DcWS77liS0Mf7vygITmMT+ vEsyA+tf5Na62Jy3g7dqf2gaDNZVmsohH20dCyCoOx0Ec2I1kEu1snnysu/uY+0H l0JIC+D9KLMdQRkmOgH6X8IBcamkQtMhNnPP9/46AopglGHzYPF9B9tdrpm1STFw 7DGfTsiNKOkkoemFhPpHAHe4zdEWL+zO/5UnUIPXgLrferjBfaeWoov1NmZDYFjh XO5ATl8ElaXWdxqhcsnh7M5tiKx2YZc8AvXaG9lQ/DZTxk2N5n9sFzwhGz2IGJ/T xyTTKQ94p8IjwI8L5Q/zx6buVyENkLF0t2duGFENJ9x0X14/7xhXMQTnChhR3HA= =i20H -----END PGP SIGNATURE----- --akFa66uObJjffvrKt22M6qtwN4iWOjMnp--