提交 b3ef0ade 编写于 作者: S Stefan Hajnoczi

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: NStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Reviewed-by: NLluís Vilanova <vilanova@ac.upc.edu>
上级 45d6c787
......@@ -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):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册