diff options
author | Markus Armbruster <armbru@redhat.com> | 2018-02-11 10:35:52 +0100 |
---|---|---|
committer | Eric Blake <eblake@redhat.com> | 2018-03-02 13:14:09 -0600 |
commit | 4257053083775c1f670fa828003915e25d13e9d7 (patch) | |
tree | 2f11ade8c335552d8fd2ff9eb75b2b5ab90f21ef /scripts/qapi | |
parent | 181feaf3555136dd7883e2434c4498ca1939bf1a (diff) | |
download | qemu-4257053083775c1f670fa828003915e25d13e9d7.zip qemu-4257053083775c1f670fa828003915e25d13e9d7.tar.gz qemu-4257053083775c1f670fa828003915e25d13e9d7.tar.bz2 |
qapi: Concentrate QAPISchemaParser.exprs updates in .__init__()
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20180211093607.27351-15-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'scripts/qapi')
-rw-r--r-- | scripts/qapi/common.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index 4cc4d3e..1d0d30f9 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -290,8 +290,12 @@ class QAPISchemaParser(object): if not isinstance(include, str): raise QAPISemError(info, "Value of 'include' must be a string") - self._include(include, info, os.path.dirname(self.fname), - previously_included) + exprs_include = self._include(include, info, + os.path.dirname(self.fname), + previously_included) + if exprs_include: + self.exprs.extend(exprs_include.exprs) + self.docs.extend(exprs_include.docs) elif "pragma" in expr: self.reject_expr_doc(cur_doc) if len(expr) != 1: @@ -334,14 +338,13 @@ class QAPISchemaParser(object): # skip multiple include of the same file if incl_abs_fname in previously_included: - return + return None + try: fobj = open(incl_fname, 'r') except IOError as e: raise QAPISemError(info, '%s: %s' % (e.strerror, incl_fname)) - exprs_include = QAPISchemaParser(fobj, previously_included, info) - self.exprs.extend(exprs_include.exprs) - self.docs.extend(exprs_include.docs) + return QAPISchemaParser(fobj, previously_included, info) def _pragma(self, name, value, info): global doc_required, returns_whitelist, name_case_whitelist |