From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37941) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZguWX-0003Tn-VL for qemu-devel@nongnu.org; Tue, 29 Sep 2015 09:00:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZguWT-0005D9-E7 for qemu-devel@nongnu.org; Tue, 29 Sep 2015 09:00:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55805) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZguWS-00059r-Ka for qemu-devel@nongnu.org; Tue, 29 Sep 2015 09:00:45 -0400 References: <1443497249-15361-1-git-send-email-eblake@redhat.com> <1443497249-15361-5-git-send-email-eblake@redhat.com> <87vbatmqzt.fsf@blackfin.pond.sub.org> From: Eric Blake Message-ID: <560A8B75.60802@redhat.com> Date: Tue, 29 Sep 2015 07:00:37 -0600 MIME-Version: 1.0 In-Reply-To: <87vbatmqzt.fsf@blackfin.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="4SFCPTc1rBqdNG36Ce8D4RUbnFRnWqBXG" Subject: Re: [Qemu-devel] [PATCH v6 04/16] qapi: Clean up qapi.py per pep8 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: marcandre.lureau@redhat.com, qemu-devel@nongnu.org, ehabkost@redhat.com, Michael Roth This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --4SFCPTc1rBqdNG36Ce8D4RUbnFRnWqBXG Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 09/29/2015 04:58 AM, Markus Armbruster wrote: > Eric Blake writes: >=20 >> Silence pep8, and make pylint a bit happier. Just style cleanups, >> plus killing a useless comment in camel_to_upper(); no semantic >> changes. >> >> Signed-off-by: Eric Blake > [...] >> diff --git a/scripts/qapi.py b/scripts/qapi.py >> index a2d869e..7e8a99d 100644 >> --- a/scripts/qapi.py >> +++ b/scripts/qapi.py > [...] >> @@ -667,22 +695,23 @@ def check_keys(expr_elem, meta, required, option= al=3D[]): >> if not isinstance(name, str): >> raise QAPIExprError(info, >> "'%s' key must have a string value" % met= a) >> - required =3D required + [ meta ] >> + required =3D required + [meta] >> for (key, value) in expr.items(): >> - if not key in required and not key in optional: >> + if key not in required + optional: >=20 > The purely mechanical cleanup would be >=20 > if key not in required and key not in optional: >=20 > Yours is a bit more concise, but I'm not sure it's actually easier to > read. It's also less efficient unless a sufficiently smart compiler > transforms it back. Not that efficiency matters here. The purely mechanical version still fits the line, so I'm not strongly attached to the concise version. >> @@ -1307,14 +1338,14 @@ def camel_to_upper(value): >> c =3D c_fun_str[i] >> # When c is upper and no "_" appears before, do more checks >> if c.isupper() and (i > 0) and c_fun_str[i - 1] !=3D "_": >> - # Case 1: next string is lower >> - # Case 2: previous string is digit >> - if (i < (l - 1) and c_fun_str[i + 1].islower()) or \ >> - c_fun_str[i - 1].isdigit(): >> + if i < (l - 1) and c_fun_str[i + 1].islower(): >=20 > I doubt we need the parenthesis around (l - 1). Probably not; I was just preserving the existing text. >=20 >> + new_name +=3D '_' >> + elif c_fun_str[i - 1].isdigit(): >> new_name +=3D '_' >> new_name +=3D c >> return new_name.lstrip('_').upper() >> >> + >> def c_enum_const(type_name, const_name, prefix=3DNone): >> if prefix is not None: >> type_name =3D prefix > [...] >=20 > Happy to touch up on commit to my tree. Or, since you want a respin of 5, I can catch them. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --4SFCPTc1rBqdNG36Ce8D4RUbnFRnWqBXG 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/ iQEcBAEBCAAGBQJWCot2AAoJEKeha0olJ0Nq+pMH+wT29rXjXThcJ5pEsuR9H7Fq KFZ1cwoCdV8Kw0ZjNZ2pq8j7UPRJSjQ53qZ3GL+eNElvmI/v86cpF/tBaRDTNG8P c6MD5+m1m9fvSVJSRxUzL9GlW+7AxUSzE3wK30oteuHUGP1tdTfXTmuViHZeUg4m klobY+AAYRDX3Aiq/BzZJlLvpLPH1Ot5Wz05k+Ozuhekd3nS7e3wdHmqBMe6cG5g z18nIOsa9/JNUbDuotRkSjlpnPOIU1FOqdrrh5o0a90N07UUVSbjBt65VSK2meNF +iaL4mGIyxncfpsj0dOFveTwGBpA7tv4oR5HTNj46d5XhMr0K5h+CEFZlyV3Rac= =Lobu -----END PGP SIGNATURE----- --4SFCPTc1rBqdNG36Ce8D4RUbnFRnWqBXG--