qapi: Drop Indentation.__bool__()
Intentation.__bool__() is not worth its keep: it has just one user, which can just as well check .__str__() instead. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210908045428.2689093-3-armbru@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
parent
7b275cdd69
commit
916fca17c7
@ -142,10 +142,6 @@ class Indentation:
|
|||||||
"""Return the current indentation as a string of spaces."""
|
"""Return the current indentation as a string of spaces."""
|
||||||
return ' ' * self._level
|
return ' ' * self._level
|
||||||
|
|
||||||
def __bool__(self) -> bool:
|
|
||||||
"""True when there is a non-zero indentation."""
|
|
||||||
return bool(self._level)
|
|
||||||
|
|
||||||
def increase(self, amount: int = 4) -> None:
|
def increase(self, amount: int = 4) -> None:
|
||||||
"""Increase the indentation level by ``amount``, default 4."""
|
"""Increase the indentation level by ``amount``, default 4."""
|
||||||
self._level += amount
|
self._level += amount
|
||||||
@ -169,8 +165,9 @@ def cgen(code: str, **kwds: object) -> str:
|
|||||||
Obey `indent`, and strip `EATSPACE`.
|
Obey `indent`, and strip `EATSPACE`.
|
||||||
"""
|
"""
|
||||||
raw = code % kwds
|
raw = code % kwds
|
||||||
if indent:
|
pfx = str(indent)
|
||||||
raw = re.sub(r'^(?!(#|$))', str(indent), raw, flags=re.MULTILINE)
|
if pfx:
|
||||||
|
raw = re.sub(r'^(?!(#|$))', pfx, raw, flags=re.MULTILINE)
|
||||||
return re.sub(re.escape(EATSPACE) + r' *', '', raw)
|
return re.sub(re.escape(EATSPACE) + r' *', '', raw)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user