aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2021-03-23 10:40:13 +0100
committerMarkus Armbruster <armbru@redhat.com>2021-03-23 22:31:05 +0100
commit4a67bd31a4a45773ed1e33ebd06ff949ff9525d7 (patch)
tree6998e6dfe6b0fa82842e3d6a53848da3d6eba2ea /scripts
parent492db12ec3b42be6f971ba8436e080bc096b58b5 (diff)
qapi: Factor out QAPISchemaParser._check_pragma_list_of_str()
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210323094025.3569441-17-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/qapi/parser.py19
1 files 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 @@ class QAPISchemaParser:
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 @@ class QAPISchemaParser:
"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)