Add emit_env to the oedata stuff.
authorChris Larson <clarson@kergoth.com>
Sat, 14 Jun 2003 03:52:35 +0000 (03:52 +0000)
committerChris Larson <clarson@kergoth.com>
Sat, 14 Jun 2003 03:52:35 +0000 (03:52 +0000)
bin/data
bin/oedata.py

index 010f92a..25c8391 100644 (file)
--- a/bin/data
+++ b/bin/data
@@ -29,3 +29,6 @@ expandData()
 print "after expansion:"
 niftyPrint()
 
+
+print "env:"
+emit_env()
index 44e4fb6..342d353 100644 (file)
@@ -167,3 +167,34 @@ def inheritFromOS(pos, d = _data):
                                setVar(s, os.environ[s], d)
                except KeyError:
                        pass
+
+import sys
+
+def emit_env(o=sys.__stdout__, d = _data):
+       """This prints the data so that it can later be sourced by a shell
+       Normally, it prints to stdout, but this it can be redirectory to some open file handle
+
+       It is used by exec_shell_func().
+       """
+
+#      o.write('\nPATH="' + os.path.join(projectdir, 'bin/build') + ':${PATH}"\n')
+
+       env = d.keys()
+
+       for e in env:
+               if getVarFlag(e, "func", d):
+                       continue
+               if getVarFlag(e, "python", d):
+                       continue
+               o.write('\n')
+               if getVarFlag(e, "export", d):
+                       o.write('export ')
+               o.write(e+'="'+getVar(e, d) + '"\n')    
+
+       for e in env:
+               if not getVarFlag(e, "func", d):
+                       continue
+               if getVarFlag(e, "python", d):
+                       continue
+               o.write("\n" + e + '() {\n' + getenv(e, d) + '}\n')
+