]> Git Repo - qemu.git/commitdiff
tracetool: avoid str.rpartition() Python 2.5 function
authorStefan Hajnoczi <[email protected]>
Fri, 27 Apr 2012 14:12:04 +0000 (15:12 +0100)
committerStefan Hajnoczi <[email protected]>
Tue, 1 May 2012 19:15:28 +0000 (20:15 +0100)
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 <[email protected]>
Reviewed-by: LluĂ­s Vilanova <[email protected]>
scripts/tracetool/__init__.py

index 49858c9e33db2a2ad0ceb5f8c27ac5a1792ce31d..175df0800529c80272479e8e210ebbffd4c7cd52 100644 (file)
@@ -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):
This page took 0.027281 seconds and 4 git commands to generate.