[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 16/28] qapi: Factor out QAPISchemaParser._check_pragma_list_of_st
From: |
Markus Armbruster |
Subject: |
[PATCH 16/28] qapi: Factor out QAPISchemaParser._check_pragma_list_of_str() |
Date: |
Tue, 23 Mar 2021 10:40:13 +0100 |
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
scripts/qapi/parser.py | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py
index 116afe549a..8eed69333f 100644
--- a/scripts/qapi/parser.py
+++ b/scripts/qapi/parser.py
@@ -119,6 +119,13 @@ def _include(self, include, info, incl_fname,
previously_included):
return QAPISchemaParser(incl_fname, previously_included, info)
+ def _check_pragma_list_of_str(self, name, value, info):
+ if (not isinstance(value, list)
+ or any([not isinstance(elt, str) for elt in value])):
+ raise QAPISemError(
+ info,
+ "pragma %s must be a list of strings" % name)
+
def _pragma(self, name, value, info):
if name == 'doc-required':
if not isinstance(value, bool):
@@ -126,18 +133,10 @@ def _pragma(self, name, value, info):
"pragma 'doc-required' must be boolean")
info.pragma.doc_required = value
elif name == 'returns-whitelist':
- if (not isinstance(value, list)
- or any([not isinstance(elt, str) for elt in value])):
- raise QAPISemError(
- info,
- "pragma returns-whitelist must be a list of strings")
+ self._check_pragma_list_of_str(name, value, info)
info.pragma.returns_whitelist = value
elif name == 'name-case-whitelist':
- if (not isinstance(value, list)
- or any([not isinstance(elt, str) for elt in value])):
- raise QAPISemError(
- info,
- "pragma name-case-whitelist must be a list of strings")
+ self._check_pragma_list_of_str(name, value, info)
info.pragma.name_case_whitelist = value
else:
raise QAPISemError(info, "unknown pragma '%s'" % name)
--
2.26.3
- Re: [PATCH 06/28] tests/qapi-schema: Tweak to demonstrate buggy member name check, (continued)
- [PATCH 05/28] tests/qapi-schema: Drop TODO comment on simple unions, Markus Armbruster, 2021/03/23
- [PATCH 04/28] tests/qapi-schema: Belatedly update comment on alternate clash, Markus Armbruster, 2021/03/23
- [PATCH 24/28] qapi: Enforce command naming rules, Markus Armbruster, 2021/03/23
- [PATCH 25/28] tests/qapi-schema: Switch member name clash test to struct, Markus Armbruster, 2021/03/23
- [PATCH 16/28] qapi: Factor out QAPISchemaParser._check_pragma_list_of_str(),
Markus Armbruster <=
- [PATCH 27/28] qapi: Enforce enum member naming rules, Markus Armbruster, 2021/03/23
- [PATCH 23/28] qapi: Enforce feature naming rules, Markus Armbruster, 2021/03/23
- [PATCH 21/28] tests-qmp-cmds: Drop unused and incorrect qmp_TestIfCmd(), Markus Armbruster, 2021/03/23
- [PATCH 18/28] tests/qapi-schema: Rename returns-whitelist to returns-bad-type, Markus Armbruster, 2021/03/23
- [PATCH 28/28] qapi: Enforce union and alternate branch naming rules, Markus Armbruster, 2021/03/23