Return-Path: Received: from bastet.se.axis.com (bastet.se.axis.com [195.60.68.11]) by mail.openembedded.org (Postfix) with ESMTP id A0DD27F360 for ; Mon, 21 Oct 2019 10:30:39 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id 65718182BB for ; Mon, 21 Oct 2019 12:30:40 +0200 (CEST) X-Axis-User: NO X-Axis-NonUser: YES X-Virus-Scanned: Debian amavisd-new at bastet.se.axis.com Received: from bastet.se.axis.com ([IPv6:::ffff:127.0.0.1]) by localhost (bastet.se.axis.com [::ffff:127.0.0.1]) (amavisd-new, port 10024) with LMTP id 6IWFYeRVNYYy for ; Mon, 21 Oct 2019 12:30:35 +0200 (CEST) Received: from boulder02.se.axis.com (boulder02.se.axis.com [10.0.8.16]) by bastet.se.axis.com (Postfix) with ESMTPS id BA4C618358 for ; Mon, 21 Oct 2019 12:30:34 +0200 (CEST) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9D7591A06D for ; Mon, 21 Oct 2019 12:30:34 +0200 (CEST) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8F5F91A070 for ; Mon, 21 Oct 2019 12:30:34 +0200 (CEST) Received: from seth.se.axis.com (unknown [10.0.2.172]) by boulder02.se.axis.com (Postfix) with ESMTP for ; Mon, 21 Oct 2019 12:30:34 +0200 (CEST) Received: from lnxolani1.se.axis.com (lnxolani1.se.axis.com [10.88.130.9]) by seth.se.axis.com (Postfix) with ESMTP id 82255E2F for ; Mon, 21 Oct 2019 12:30:34 +0200 (CEST) Received: by lnxolani1.se.axis.com (Postfix, from userid 20853) id 7F10B40AA1; Mon, 21 Oct 2019 12:30:34 +0200 (CEST) From: Ola x Nilsson To: openembedded-core@lists.openembedded.org Date: Mon, 21 Oct 2019 12:30:33 +0200 Message-Id: <20191021103034.12200-8-olani@axis.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20191021103034.12200-1-olani@axis.com> References: <20191021103034.12200-1-olani@axis.com> X-TM-AS-GCONF: 00 Subject: [PATCH 8/9] devtool-source.bbclass: Use with to manage file handle lifetime X-BeenThere: openembedded-core@lists.openembedded.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Patches and discussions about the oe-core layer List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Oct 2019 10:30:40 -0000 Replace copy-and-if with a filtering list comprehension. Signed-off-by: Ola x Nilsson --- meta/classes/devtool-source.bbclass | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/meta/classes/devtool-source.bbclass b/meta/classes/devtool-source.bbclass index a8110006fb..280d6009f3 100644 --- a/meta/classes/devtool-source.bbclass +++ b/meta/classes/devtool-source.bbclass @@ -97,17 +97,15 @@ python devtool_post_unpack() { local_files = oe.recipeutils.get_recipe_local_files(d) if is_kernel_yocto: - for key in local_files.copy(): - if key.endswith('scc'): - sccfile = open(local_files[key], 'r') + for key in [f for f in local_files if f.endswith('scc')]: + with open(local_files[key], 'r') as sccfile: for l in sccfile: line = l.split() if line and line[0] in ('kconf', 'patch'): cfg = os.path.join(os.path.dirname(local_files[key]), line[-1]) - if not cfg in local_files.values(): + if cfg not in local_files.values(): local_files[line[-1]] = cfg shutil.copy2(cfg, workdir) - sccfile.close() # Ignore local files with subdir={BP} srcabspath = os.path.abspath(srcsubdir) -- 2.11.0