[bitbake-devel] [PATCH] cooker: remove some redundant file manipulation code

Voicu, Cristiana cristiana.voicu at intel.com
Tue Nov 12 15:44:27 UTC 2013


It’s my mistake. I remember I sent more similar methods, some of them modifying the contents. Hope this is a good excuse ☺
I will send a patch that uses append.
Cristiana
From: bitbake-devel-bounces at lists.openembedded.org [mailto:bitbake-devel-bounces at lists.openembedded.org] On Behalf Of Chris Larson
Sent: Tuesday, November 12, 2013 5:18 PM
To: Stanacar, StefanX
Cc: bitbake-devel at lists.openembedded.org
Subject: Re: [bitbake-devel] [PATCH] cooker: remove some redundant file manipulation code


On Tue, Nov 12, 2013 at 7:07 AM, Stefan Stanacar <stefanx.stanacar at intel.com<mailto:stefanx.stanacar at intel.com>> wrote:
+        total = ''
         with open(default_file, 'r') as f:
-            contents = f.readlines()
-        f.close()
-
-        total = ""
-        for c in contents:
-            total += c
+            for line in f:
+                total += line

         total += "#added by hob"
         total += "\n%s += \"%s\"\n" % (var, val)

         with open(default_file, 'w') as f:
             f.write(total)
-        f.close()

This is weird. Have they ever heard of opening a file in append mode? :) And obviously, splitting the contents into lines, then re-concatenating those lines into a string blob makes no sense either.
--
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openembedded.org/pipermail/bitbake-devel/attachments/20131112/be800f6c/attachment-0002.html>


More information about the bitbake-devel mailing list