diff options
author | Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> | 2012-04-27 15:12:04 +0100 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> | 2012-05-01 20:15:28 +0100 |
commit | b3ef0ade57ff29e33d3204ca2f48b1e36108116e (patch) | |
tree | 6b1521b7005e526d5a260658b325ee6beff6430c /scripts | |
parent | 45d6c787751650ac332447444c192201dfc526af (diff) |
tracetool: avoid str.rpartition() Python 2.5 function
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 <stefanha@linux.vnet.ibm.com>
Reviewed-by: LluĂs Vilanova <vilanova@ac.upc.edu>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/tracetool/__init__.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py index 49858c9e33..175df08005 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): |