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

Chris Larson clarson at kergoth.com
Tue Nov 12 15:17:34 UTC 2013


On Tue, Nov 12, 2013 at 7:07 AM, Stefan Stanacar <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/610005e9/attachment-0002.html>


More information about the bitbake-devel mailing list