summaryrefslogtreecommitdiffstats
path: root/lib/bb/data.py
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2010-04-20 13:51:35 -0700
committerChris Larson <chris_larson@mentor.com>2010-04-20 14:36:49 -0700
commitdb718ec6f67c7c0d0efb4ba0b5b24384f707dcf5 (patch)
tree3eab1cca16242259d97c17472519e2facf1429ab /lib/bb/data.py
parent9cb52edf9198fe6db735abbb61d0c4026c97a8d9 (diff)
downloadbitbake-db718ec6f67c7c0d0efb4ba0b5b24384f707dcf5.tar.gz
emit_env: clean up, iterate once
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Diffstat (limited to 'lib/bb/data.py')
-rw-r--r--lib/bb/data.py18
1 files changed, 7 insertions, 11 deletions
diff --git a/lib/bb/data.py b/lib/bb/data.py
index ba496c9d9..3ff1ac811 100644
--- a/lib/bb/data.py
+++ b/lib/bb/data.py
@@ -43,6 +43,7 @@ if sys.argv[0][-5:] == "pydoc":
else:
path = os.path.dirname(os.path.dirname(sys.argv[0]))
sys.path.insert(0, path)
+from itertools import groupby
from bb import data_smart
import bb
@@ -226,17 +227,12 @@ def emit_var(var, o=sys.__stdout__, d = init(), all=False):
def emit_env(o=sys.__stdout__, d = init(), all=False):
"""Emits all items in the data store in a format such that it can be sourced by a shell."""
- env = keys(d)
-
- for e in env:
- if getVarFlag(e, "func", d):
- continue
- emit_var(e, o, d, all) and o.write('\n')
-
- for e in env:
- if not getVarFlag(e, "func", d):
- continue
- emit_var(e, o, d) and o.write('\n')
+ isfunc = lambda key: bool(d.getVarFlag(key, "func"))
+ keys = sorted(d.keys(), key=isfunc)
+ grouped = groupby(keys, isfunc)
+ for isfunc, keys in grouped:
+ for key in keys:
+ emit_var(key, o, d, all and not isfunc) and o.write('\n')
def update_data(d):
"""Performs final steps upon the datastore, including application of overrides"""