diff options
| author | Steven Knight <knight@baldmt.com> | 2004-08-30 21:46:36 (GMT) |
|---|---|---|
| committer | Steven Knight <knight@baldmt.com> | 2004-08-30 21:46:36 (GMT) |
| commit | 96cb20e235d66ab6ca7f50e2a1a9dc60d34d85db (patch) | |
| tree | 884320473c7701f608c59c14458eec4a55ff0e31 /src | |
| parent | c1315083b2616e381a8ec5b73cab554a98eb54ae (diff) | |
| download | SCons-96cb20e235d66ab6ca7f50e2a1a9dc60d34d85db.zip SCons-96cb20e235d66ab6ca7f50e2a1a9dc60d34d85db.tar.gz SCons-96cb20e235d66ab6ca7f50e2a1a9dc60d34d85db.tar.bz2 | |
Add an Environment.Dump() method. (Gary Oberbrunner)
Diffstat (limited to 'src')
| -rw-r--r-- | src/CHANGES.txt | 9 | ||||
| -rw-r--r-- | src/engine/SCons/Environment.py | 18 | ||||
| -rw-r--r-- | src/engine/SCons/EnvironmentTests.py | 7 |
3 files changed, 34 insertions, 0 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index b8a3628..f3b5778 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -10,6 +10,15 @@ RELEASE 0.97 - XXX + From Gary Oberbrunner: + + - Add an Environment.Dump() method to print the contents of a + construction environment. + + + +RELEASE 0.96.1 - XXX + From Craig Bachelor: - Handle white space in the executable Python path name within in MSVS 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') |
