]> code.ossystems Code Review - openembedded-core.git/commitdiff
devtool-source.bbclass: Use with to manage file handle lifetime
authorOla x Nilsson <ola.x.nilsson@axis.com>
Mon, 21 Oct 2019 10:30:33 +0000 (12:30 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 23 Oct 2019 15:26:14 +0000 (16:26 +0100)
Replace copy-and-if with a filtering list comprehension.

Signed-off-by: Ola x Nilsson <olani@axis.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/devtool-source.bbclass

index a8110006fbc0c1f4cf8226f7ccce192b8fe75aaa..280d6009f3c2d807567035ae9cb0b887f132b8ec 100644 (file)
@@ -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)