From patchwork Tue May 1 19:28:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [3/5] tracetool: avoid str.rpartition() Python 2.5 function Date: Tue, 01 May 2012 09:28:36 -0000 From: Stefan Hajnoczi X-Patchwork-Id: 156191 Message-Id: <1335900518-6730-4-git-send-email-stefanha@linux.vnet.ibm.com> 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):