]> code.ossystems Code Review - openembedded-core.git/commitdiff
libc-package.bbclass: Use with to manage filehandle in do_spit_gconvs
authorOla x Nilsson <ola.x.nilsson@axis.com>
Mon, 21 Oct 2019 10:30:34 +0000 (12:30 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 23 Oct 2019 15:26:14 +0000 (16:26 +0100)
Tweak the write loop slightly to avoid dict lookups that can easily be
done in the for loop.

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

index a66e540884721244cd2fea34b8dffadfe5b3aa48..de816bcec1d8d44c195f80999a89843d8b18ec74 100644 (file)
@@ -346,14 +346,13 @@ python package_do_split_gconvs () {
 
     if use_bin == "compile":
         makefile = oe.path.join(d.getVar("WORKDIR"), "locale-tree", "Makefile")
-        m = open(makefile, "w")
-        m.write("all: %s\n\n" % " ".join(commands.keys()))
-        total = len(commands)
-        for i, cmd in enumerate(commands):
-            m.write(cmd + ":\n")
-            m.write("\t@echo 'Progress %d/%d'\n" % (i, total))
-            m.write("\t" + commands[cmd] + "\n\n")
-        m.close()
+        with open(makefile, "w") as m:
+            m.write("all: %s\n\n" % " ".join(commands.keys()))
+            total = len(commands)
+            for i, (maketarget, makerecipe) in enumerate(commands.items()):
+                m.write(maketarget + ":\n")
+                m.write("\t@echo 'Progress %d/%d'\n" % (i, total))
+                m.write("\t" + makerecipe + "\n\n")
         d.setVar("EXTRA_OEMAKE", "-C %s ${PARALLEL_MAKE}" % (os.path.dirname(makefile)))
         d.setVarFlag("oe_runmake", "progress", "outof:Progress\s(\d+)/(\d+)")
         bb.note("Executing binary locale generation makefile")