mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
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: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Radostin Stoyanov <rstoyanov1@gmail.com>
This commit is contained in:
committed by
Daniel P. Berrangé
parent
eb327e6c61
commit
c57b56756a
@@ -721,15 +721,8 @@ class CParser:
|
|||||||
self.index.info = res
|
self.index.info = res
|
||||||
|
|
||||||
def strip_lead_star(self, line):
|
def strip_lead_star(self, line):
|
||||||
l = len(line)
|
if line.lstrip().startswith('*'):
|
||||||
i = 0
|
line = line.replace('*', '', 1)
|
||||||
while i < l:
|
|
||||||
if line[i] == ' ' or line[i] == '\t':
|
|
||||||
i += 1
|
|
||||||
elif line[i] == '*':
|
|
||||||
return line[:i] + line[i + 1:]
|
|
||||||
else:
|
|
||||||
return line
|
|
||||||
return line
|
return line
|
||||||
|
|
||||||
def cleanupComment(self):
|
def cleanupComment(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user