提交 c57b5675 编写于 作者: R Radostin Stoyanov 提交者: Daniel P. Berrangé

apibuild: Simplify strip_lead_star()

The method strip_lead_star() removes a single leading asterisk
character from a string by ignoring leading whitespace, otherwise it
returns the original string.

This could be achieved with a single if-statement followed by replace.
Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
Signed-off-by: NRadostin Stoyanov <rstoyanov1@gmail.com>
上级 eb327e6c
......@@ -721,15 +721,8 @@ class CParser:
self.index.info = res
def strip_lead_star(self, line):
l = len(line)
i = 0
while i < l:
if line[i] == ' ' or line[i] == '\t':
i += 1
elif line[i] == '*':
return line[:i] + line[i + 1:]
else:
return line
if line.lstrip().startswith('*'):
line = line.replace('*', '', 1)
return line
def cleanupComment(self):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册