aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 c4d11b9637..1d62c27fb7 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)