From patchwork Mon Apr 30 11:06:30 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 155837 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 45515B6FA1 for ; Mon, 30 Apr 2012 21:07:38 +1000 (EST) Received: from localhost ([::1]:33509 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SOoS7-00044a-Vv for incoming@patchwork.ozlabs.org; Mon, 30 Apr 2012 07:07:35 -0400 Received: from eggs.gnu.org ([208.118.235.92]:33533) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SOoRv-0003w4-8g for qemu-devel@nongnu.org; Mon, 30 Apr 2012 07:07:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SOoRs-0004h6-M4 for qemu-devel@nongnu.org; Mon, 30 Apr 2012 07:07:22 -0400 Received: from e06smtp14.uk.ibm.com ([195.75.94.110]:58542) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SOoRs-0004gB-Di for qemu-devel@nongnu.org; Mon, 30 Apr 2012 07:07:20 -0400 Received: from /spool/local by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 30 Apr 2012 12:07:16 +0100 Received: from d06nrmr1307.portsmouth.uk.ibm.com (9.149.38.129) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 30 Apr 2012 12:07:13 +0100 Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by d06nrmr1307.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q3UB7CTr2682992 for ; Mon, 30 Apr 2012 12:07:12 +0100 Received: from d06av02.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q3UB7BPJ008005 for ; Mon, 30 Apr 2012 05:07:12 -0600 Received: from localhost (stefanha-thinkpad.manchester-maybrook.uk.ibm.com [9.174.219.241]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id q3UB77tw007833; Mon, 30 Apr 2012 05:07:09 -0600 From: Stefan Hajnoczi To: Date: Mon, 30 Apr 2012 12:06:30 +0100 Message-Id: <1335783992-25149-4-git-send-email-stefanha@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1335783992-25149-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1335783992-25149-1-git-send-email-stefanha@linux.vnet.ibm.com> x-cbid: 12043011-1948-0000-0000-000001A97EDC X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 195.75.94.110 Cc: Peter Maydell , Anthony Liguori , Stefan Hajnoczi , Erik Rull , Andreas Faerber , =?UTF-8?q?Llu=C3=ADs=20Vilanova?= Subject: [Qemu-devel] [PATCH v2 3/5] tracetool: avoid str.rpartition() Python 2.5 function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The str.rpartition() function is related to str.split() and is used for splitting strings. It was introduced in Python 2.5 and therefore cannot be used in tracetool as Python 2.4 compatibility is required. Replace the code using str.rsplit(). Signed-off-by: Stefan Hajnoczi --- scripts/tracetool/__init__.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py index 49858c9..175df08 100644 --- a/scripts/tracetool/__init__.py +++ b/scripts/tracetool/__init__.py @@ -64,14 +64,17 @@ class Arguments: res = [] for arg in arg_str.split(","): arg = arg.strip() - parts = arg.split() - head, sep, tail = parts[-1].rpartition("*") - parts = parts[:-1] - if tail == "void": - assert len(parts) == 0 and sep == "" + if arg == 'void': continue - arg_type = " ".join(parts + [ " ".join([head, sep]).strip() ]).strip() - res.append((arg_type, tail)) + + if '*' in arg: + arg_type, identifier = arg.rsplit('*', 1) + arg_type += '*' + identifier = identifier.strip() + else: + arg_type, identifier = arg.rsplit(None, 1) + + res.append((arg_type, identifier)) return Arguments(res) def __iter__(self):