From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37767) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VF01E-00015V-3Z for qemu-devel@nongnu.org; Thu, 29 Aug 2013 07:04:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VF018-0007Gz-Iq for qemu-devel@nongnu.org; Thu, 29 Aug 2013 07:04:04 -0400 Received: from mail6.webfaction.com ([74.55.86.74]:58675 helo=smtp.webfaction.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VF018-0007Gv-Db for qemu-devel@nongnu.org; Thu, 29 Aug 2013 07:03:58 -0400 From: Charlie Shepherd Date: Thu, 29 Aug 2013 12:03:40 +0100 Message-Id: <1377774220-16016-1-git-send-email-charlie@ctshepherd.com> In-Reply-To: References: Subject: [Qemu-devel] [PATCH v2] Remove Python 2.5 syntax from scripts/qapi-visit.py List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, aliguori@us.ibm.com, mdroth@linux.vnet.ibm.com, Charlie Shepherd The syntax `var = a if b else c` was added in Python 2.5, but QEMU has a minimum Python version of 2.4, which chokes on this syntax. This patch converts the new syntax to Python 2.4 compatible syntax. Signed-off-by: Charlie Shepherd --- scripts/qapi-visit.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py index 597cca4..cdf40c9 100644 --- a/scripts/qapi-visit.py +++ b/scripts/qapi-visit.py @@ -20,7 +20,10 @@ import errno def generate_visit_struct_fields(name, field_prefix, fn_prefix, members): substructs = [] ret = '' - full_name = name if not fn_prefix else "%s_%s" % (name, fn_prefix) + if not fn_prefix: + full_name = name + else: + full_name = "%s_%s" % (name, fn_prefix) for argname, argentry, optional, structured in parse_args(members): if structured: @@ -84,7 +87,10 @@ if (!error_is_set(errp)) { ''') push_indent() - full_name = name if not field_prefix else "%s_%s" % (field_prefix, name) + if not field_prefix: + full_name = name + else: + full_name = "%s_%s" % (field_prefix, name) if len(field_prefix): ret += mcgen(''' @@ -270,7 +276,7 @@ void visit_type_%(name)s(Visitor *m, %(name)s ** obj, const char *name, Error ** if (!err) { switch ((*obj)->kind) { ''', - name=name, type="type" if not discriminator else discriminator) + name=name, type=(discriminator or "type")) for key in members: if not discriminator: -- 1.7.9.5