From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: Andre McCurdy <armccurdy@gmail.com>,
bitbake-devel@lists.openembedded.org
Subject: Re: [PATCH 3/3] data.py: sort variables being output by emit_func()
Date: Fri, 29 Jan 2016 00:01:05 +0000 [thread overview]
Message-ID: <1454025665.10340.56.camel@linuxfoundation.org> (raw)
In-Reply-To: <1453941798-11670-4-git-send-email-armccurdy@gmail.com>
On Wed, 2016-01-27 at 16:43 -0800, Andre McCurdy wrote:
> Sorting variables and separating those being exported from those
> being
> unset greatly improves the readability of OE run.do_configure, etc,
> shell scripts.
>
> Signed-off-by: Andre McCurdy <armccurdy@gmail.com>
> ---
> lib/bb/data.py | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/lib/bb/data.py b/lib/bb/data.py
> index 70ba56b..07f4bba 100644
> --- a/lib/bb/data.py
> +++ b/lib/bb/data.py
> @@ -270,7 +270,13 @@ def exported_vars(d):
> def emit_func(func, o=sys.__stdout__, d = init()):
> """Emits all items in the data store in a format such that it
> can be sourced by a shell."""
>
> - keys = (key for key in d.keys() if not key.startswith("__") and
> not d.getVarFlag(key, "func"))
> + o.write('\n')
> + keys = sorted(key for key in d.keys() if not
> key.startswith("__") and not d.getVarFlag(key, "func") and not
> d.getVarFlag(key, 'unexport'))
> + for key in keys:
> + emit_var(key, o, d, False)
> +
> + o.write('\n')
> + keys = sorted(key for key in d.keys() if not
> key.startswith("__") and not d.getVarFlag(key, "func") and
> d.getVarFlag(key, 'unexport'))
> for key in keys:
> emit_var(key, o, d, False)
FWIW d.keys() is very slow and best avoided if we can.
Since this code only generally runs at execution time rather than
parsing, its probably not a big deal but thought I'd mention it.
Cheers,
Richard
prev parent reply other threads:[~2016-01-29 0:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-28 0:43 [PATCH 0/3] improve formatting of OE run.do_configure etc scripts Andre McCurdy
2016-01-28 0:43 ` [PATCH 1/3] build.py: minor shell_trap_code() formatting tweaks Andre McCurdy
2016-01-28 0:43 ` [PATCH 2/3] data.py: avoid double newlines at the end of functions in emit_var() Andre McCurdy
2016-01-28 0:43 ` [PATCH 3/3] data.py: sort variables being output by emit_func() Andre McCurdy
2016-01-29 0:01 ` Richard Purdie [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1454025665.10340.56.camel@linuxfoundation.org \
--to=richard.purdie@linuxfoundation.org \
--cc=armccurdy@gmail.com \
--cc=bitbake-devel@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.