From patchwork Fri Feb 2 13:03:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 10197171 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6735A60362 for ; Fri, 2 Feb 2018 16:33:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 56B3F28ED3 for ; Fri, 2 Feb 2018 16:33:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A34928ED5; Fri, 2 Feb 2018 16:33:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DB39428ED3 for ; Fri, 2 Feb 2018 16:33:42 +0000 (UTC) Received: from localhost ([::1]:38994 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eheHW-0004Kn-12 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 02 Feb 2018 11:33:42 -0500 Received: from eggs.gnu.org ([208.118.235.92]:59855) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ehdNm-0004cN-PK for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:37:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ehdMi-0006NP-LE for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:36:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49022) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ehdMh-0006LD-TQ for qemu-devel@nongnu.org; Fri, 02 Feb 2018 10:35:00 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CF33D7B004; Fri, 2 Feb 2018 13:04:58 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-148.ams2.redhat.com [10.36.116.148]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BC7FD7CD9C; Fri, 2 Feb 2018 13:04:32 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id CA01D1138662; Fri, 2 Feb 2018 14:03:36 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Fri, 2 Feb 2018 14:03:27 +0100 Message-Id: <20180202130336.24719-13-armbru@redhat.com> In-Reply-To: <20180202130336.24719-1-armbru@redhat.com> References: <20180202130336.24719-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 02 Feb 2018 13:04:58 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH RFC 12/21] qapi: Concentrate QAPISchemaParser.exprs updates in .__init__() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: marcandre.lureau@redhat.com, mdroth@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Markus Armbruster Reviewed-by: Marc-André Lureau --- scripts/qapi/common.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index d334e1db5a..7a327bfe9f 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -286,8 +286,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: @@ -330,14 +334,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