From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:46831) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPIle-0000sR-IK for qemu-devel@nongnu.org; Tue, 01 May 2012 15:29:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SPIlb-00057o-A3 for qemu-devel@nongnu.org; Tue, 01 May 2012 15:29:46 -0400 Received: from e06smtp16.uk.ibm.com ([195.75.94.112]:59830) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPIlb-00057E-1x for qemu-devel@nongnu.org; Tue, 01 May 2012 15:29:43 -0400 Received: from /spool/local by e06smtp16.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 1 May 2012 20:29:39 +0100 Received: from d06av10.portsmouth.uk.ibm.com (d06av10.portsmouth.uk.ibm.com [9.149.37.251]) by d06nrmr1507.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q41JTaEw1933528 for ; Tue, 1 May 2012 20:29:37 +0100 Received: from d06av10.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q41JPAGR003165 for ; Tue, 1 May 2012 15:25:11 -0400 From: Stefan Hajnoczi Date: Tue, 1 May 2012 20:28:36 +0100 Message-Id: <1335900518-6730-4-git-send-email-stefanha@linux.vnet.ibm.com> In-Reply-To: <1335900518-6730-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1335900518-6730-1-git-send-email-stefanha@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH 3/5] tracetool: avoid str.rpartition() Python 2.5 function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-devel@nongnu.org, Stefan Hajnoczi 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 Reviewed-by: LluĂ­s Vilanova --- 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): -- 1.7.10