[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 10/14] qapi/gen.py: Add __bool__ dunder method to QAPIGen
From: |
John Snow |
Subject: |
[PATCH 10/14] qapi/gen.py: Add __bool__ dunder method to QAPIGen |
Date: |
Tue, 22 Sep 2020 17:17:58 -0400 |
Falseish when there is no body or preamble; Trueish when there is.
Header and footer are excluded for now, because they are assumed to be
dynamic and always present.
Signed-off-by: John Snow <jsnow@redhat.com>
---
scripts/qapi/gen.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py
index ed498397ad..892d7d772e 100644
--- a/scripts/qapi/gen.py
+++ b/scripts/qapi/gen.py
@@ -40,6 +40,9 @@ def __init__(self, fname: Optional[str]):
self._preamble = ''
self._body = ''
+ def __bool__(self) -> bool:
+ return bool(self._preamble or self._body)
+
def preamble_add(self, text: str) -> None:
self._preamble += text
--
2.26.2
- [PATCH 00/14] qapi: static typing conversion, pt3, John Snow, 2020/09/22
- [PATCH 01/14] qapi/doc.py: stash long temporary locals in named locals, John Snow, 2020/09/22
- [PATCH 02/14] qapi/doc.py: avoid unnecessary keyword arguments, John Snow, 2020/09/22
- [PATCH 03/14] qapi/doc.py: Add assertion on section.member, John Snow, 2020/09/22
- [PATCH 07/14] qapi/doc.py: enable mypy checks, John Snow, 2020/09/22
- [PATCH 10/14] qapi/gen.py: Add __bool__ dunder method to QAPIGen,
John Snow <=
- [PATCH 12/14] qapi/doc.py: Assert tag member is Enum type, John Snow, 2020/09/22
- [PATCH 13/14] qapi/doc.py: Assert type of object variant, John Snow, 2020/09/22
- [PATCH 11/14] qapi/doc.py: Don't use private attributes of QAPIGen property, John Snow, 2020/09/22
- [PATCH 14/14] qapi/doc.py: enable pylint checks, John Snow, 2020/09/22
- [PATCH 04/14] qapi/doc.py: assert correct types in member_func callbacks, John Snow, 2020/09/22