From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40528) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YnXbx-0000xk-7d for qemu-devel@nongnu.org; Wed, 29 Apr 2015 15:25:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YnXbs-0007tm-UV for qemu-devel@nongnu.org; Wed, 29 Apr 2015 15:25:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48611) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YnXbs-0007tL-O3 for qemu-devel@nongnu.org; Wed, 29 Apr 2015 15:25:28 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t3TJPR2Y007138 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 29 Apr 2015 15:25:27 -0400 Message-ID: <55413026.7010604@redhat.com> Date: Wed, 29 Apr 2015 13:25:26 -0600 From: Eric Blake MIME-Version: 1.0 References: <1430334844-7015-1-git-send-email-jsnow@redhat.com> <1430334844-7015-3-git-send-email-jsnow@redhat.com> In-Reply-To: <1430334844-7015-3-git-send-email-jsnow@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="jqox87sGRH7vqpAMQrutJrI6lsp1GtGuk" Subject: Re: [Qemu-devel] [PATCH v4 2/4] scripts: qmp-shell: Expand support for QMP expressions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: John Snow , qemu-devel@nongnu.org Cc: kchamart@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --jqox87sGRH7vqpAMQrutJrI6lsp1GtGuk Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 04/29/2015 01:14 PM, John Snow wrote: > This includes support for [] expressions, single-quotes in > QMP expressions (which is not strictly a part of JSON), and > the ability to use "True", "False" and "None" literals instead > of JSON's equivalent true, false, and null literals. >=20 > qmp-shell currently allows you to describe values as > JSON expressions: > key=3D{"key":{"key2":"val"}} >=20 > But it does not currently support arrays, which are needed > for serializing and deserializing transactions: > key=3D[{"type":"drive-backup","data":{...}}] >=20 > qmp-shell also only currently accepts doubly quoted strings > as-per JSON spec, but QMP allows single quotes. >=20 > Lastly, python allows you to utilize "True" or "False" as > boolean literals, but JSON expects "true" or "false". Expand > qmp-shell to allow the user to type either, converting to the > correct type. >=20 > As a consequence of the above, the key=3Dval parsing is also improved > to give better error messages if a key=3Dval token is not provided. >=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 | 63 ++++++++++++++++++++++++++++++++++++++-----= -------- > 1 file changed, 47 insertions(+), 16 deletions(-) >=20 > =20 > +class FuzzyJSON(ast.NodeTransformer): > + '''This extension of ast.NodeTransformer filters literal "true/fal= se/null" > + values in an AST and replaces them by proper "True/False/None" val= ues that > + Python can properly evaluate.''' > + def visit_Name(self, node): > + if node.id =3D=3D 'true': > + node.id =3D 'True' > + if node.id =3D=3D 'false': > + node.id =3D 'False' > + if node.id =3D=3D 'null': > + node.id =3D 'None' > + return node Cute! Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --jqox87sGRH7vqpAMQrutJrI6lsp1GtGuk 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/ iQEcBAEBCAAGBQJVQTAmAAoJEKeha0olJ0Nq0NgH/Rhrsjr8i17fDpVEwL1Yoso5 jGxoBNusefH+i659eBVHOQRHiuhLokomsn67gUiVTInomKuu88hTx2bmjsdRVz00 RSMuYmxaA+u1yvPcd8lDi8EKWtEvBP/pEg1eAy6JltFPpnCCfzkArLdPO8LcxB7W v5PRBsx9ApZTQyGKtoCb1mA4ZpzYX/8+wl/2WgGhbJswrs94Urg8Ka2zzHmubs+O 1ibAc1b1smscREeh0UsQDMMg1ydimh5OiYwbRi8+4V9djWh7eIh/J4f7M2YrTO58 aeHtt8nk0Md977+ujruM/qOnuN1xDgTLtm6LaPPumz+rxRYrO9SSSyLnWp+o92I= =r6r4 -----END PGP SIGNATURE----- --jqox87sGRH7vqpAMQrutJrI6lsp1GtGuk--