summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2004-08-30 21:46:36 (GMT)
committerSteven Knight <knight@baldmt.com>2004-08-30 21:46:36 (GMT)
commit96cb20e235d66ab6ca7f50e2a1a9dc60d34d85db (patch)
tree884320473c7701f608c59c14458eec4a55ff0e31 /src/engine/SCons
parentc1315083b2616e381a8ec5b73cab554a98eb54ae (diff)
downloadSCons-96cb20e235d66ab6ca7f50e2a1a9dc60d34d85db.zip
SCons-96cb20e235d66ab6ca7f50e2a1a9dc60d34d85db.tar.gz
SCons-96cb20e235d66ab6ca7f50e2a1a9dc60d34d85db.tar.bz2
Add an Environment.Dump() method. (Gary Oberbrunner)
Diffstat (limited to 'src/engine/SCons')
-rw-r--r--src/engine/SCons/Environment.py18
-rw-r--r--src/engine/SCons/EnvironmentTests.py7
2 files changed, 25 insertions, 0 deletions
diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py
index 32fa1e6..03f2e38 100644
--- a/src/engine/SCons/Environment.py
+++ b/src/engine/SCons/Environment.py
@@ -663,6 +663,24 @@ class Base:
dlist = dlist[0]
return dlist
+ def Dump(self, key = None):
+ """
+ Using the standard Python pretty printer, dump the contents of the
+ scons build environment to stdout.
+
+ If the key passed in is anything other than None, then that will
+ be used as an index into the build environment dictionary and
+ whatever is found there will be fed into the pretty printer. Note
+ that this key is case sensitive.
+ """
+ import pprint
+ pp = pprint.PrettyPrinter(indent=2)
+ if key:
+ dict = self.Dictionary(key)
+ else:
+ dict = self.Dictionary()
+ return pp.pformat(dict)
+
def FindIxes(self, paths, prefix, suffix):
"""
Search a list of paths for something that matches the prefix and suffix.
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py
index 810f307..a6b8645 100644
--- a/src/engine/SCons/EnvironmentTests.py
+++ b/src/engine/SCons/EnvironmentTests.py
@@ -1994,6 +1994,13 @@ class EnvironmentTestCase(unittest.TestCase):
d = env.Dir('${BAR}_$BAR')
assert d == 'Dir(bardir_bardir)', d
+ def test_Dump(self):
+ """Test the Dump() method"""
+
+ env = Environment(FOO = 'foo')
+ assert env.Dump('FOO') == "'foo'", env.Dump('FOO')
+ assert len(env.Dump()) > 200, env.Dump() # no args version
+
def test_Environment(self):
"""Test the Environment() method"""
env = Environment(FOO = 'xxx', BAR = 'yyy')