aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2021-09-08 06:54:25 +0200
committerMarkus Armbruster <armbru@redhat.com>2021-09-08 15:30:10 +0200
commit916fca17c7445c17d4be37610c80c1f68784ef28 (patch)
treeae15b4baf34862e64e65ca8ba541b37704279f99 /scripts
parent7b275cdd69d5e6af0b95f4e6440d4664fe1c3674 (diff)
downloadqemu-916fca17c7445c17d4be37610c80c1f68784ef28.zip
qemu-916fca17c7445c17d4be37610c80c1f68784ef28.tar.gz
qemu-916fca17c7445c17d4be37610c80c1f68784ef28.tar.bz2
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>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/qapi/common.py9
1 files changed, 3 insertions, 6 deletions
diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
index c4d11b9..1d62c27 100644
--- a/scripts/qapi/common.py
+++ b/scripts/qapi/common.py
@@ -142,10 +142,6 @@ class Indentation:
"""Return the current indentation as a string of spaces."""
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:
"""Increase the indentation level by ``amount``, default 4."""
self._level += amount
@@ -169,8 +165,9 @@ def cgen(code: str, **kwds: object) -> str:
Obey `indent`, and strip `EATSPACE`.
"""
raw = code % kwds
- if indent:
- raw = re.sub(r'^(?!(#|$))', str(indent), raw, flags=re.MULTILINE)
+ pfx = str(indent)
+ if pfx:
+ raw = re.sub(r'^(?!(#|$))', pfx, raw, flags=re.MULTILINE)
return re.sub(re.escape(EATSPACE) + r' *', '', raw)