Package SCons :: Module Environment :: Class SubstitutionEnvironment
[hide private]
[frames] | no frames]

Class SubstitutionEnvironment

source code

object --+
         |
        SubstitutionEnvironment
Known Subclasses:

Base class for different flavors of construction environments.

This class contains a minimal set of methods that handle contruction variable expansion and conversion of strings to Nodes, which may or may not be actually useful as a stand-alone class. Which methods ended up in this class is pretty arbitrary right now. They're basically the ones which we've empirically determined are common to the different construction environment subclasses, and most of the others that use or touch the underlying dictionary of construction variables.

Eventually, this class should contain all the methods that we determine are necessary for a "minimal" interface to the build engine. A full "native Python" SCons environment has gotten pretty heavyweight with all of the methods and Tools and construction variables we've jammed in there, so it would be nice to have a lighter weight alternative for interfaces that don't need all of the bells and whistles. (At some point, we'll also probably rename this class "Base," since that more reflects what we want this class to become, but because we've released comments that tell people to subclass Environment.Base to create their own flavors of construction environment, we'll save that for a future refactoring when this class actually becomes useful.)

Instance Methods [hide private]
 
__init__(self, **kw)
Initialization of an underlying SubstitutionEnvironment class.
source code
 
_init_special(self)
Initial the dispatch tables for special handling of special construction variables.
source code
 
__cmp__(self, other) source code
 
__delitem__(self, key) source code
 
__getitem__(self, key) source code
 
__setitem__(self, key, value) source code
 
get(self, key, default=None)
Emulates the get() method of dictionaries.
source code
 
has_key(self, key) source code
 
__contains__(self, key) source code
 
items(self) source code
 
arg2nodes(self, args, node_factory=<class 'SCons.Environment._Null'>, lookup_list=<class 'SCons.Environment._Null'>, **kw) source code
 
gvars(self) source code
 
lvars(self) source code
 
subst(self, string, raw=0, target=None, source=None, conv=None, executor=None)
Recursively interpolates construction variables from the Environment into the specified string, returning the expanded result. Construction variables are specified by a $ prefix in the string and begin with an initial underscore or alphabetic character followed by any number of underscores or alphanumeric characters. The construction variable names may be surrounded by curly braces to separate the name from trailing characters.
source code
 
subst_kw(self, kw, raw=0, target=None, source=None) source code
 
subst_list(self, string, raw=0, target=None, source=None, conv=None, executor=None)
Calls through to SCons.Subst.scons_subst_list(). See the documentation for that function.
source code
 
subst_path(self, path, target=None, source=None)
Substitute a path list, turning EntryProxies into Nodes and leaving Nodes (and other objects) as-is.
source code
 
subst_target_source(self, string, raw=0, target=None, source=None, conv=None, executor=None)
Recursively interpolates construction variables from the Environment into the specified string, returning the expanded result. Construction variables are specified by a $ prefix in the string and begin with an initial underscore or alphabetic character followed by any number of underscores or alphanumeric characters. The construction variable names may be surrounded by curly braces to separate the name from trailing characters.
source code
 
backtick(self, command) source code
 
AddMethod(self, function, name=None)
Adds the specified function as a method of this construction environment with the specified name. If the name is omitted, the default name is the name of the function itself.
source code
 
RemoveMethod(self, function)
Removes the specified function's MethodWrapper from the added_methods list, so we don't re-bind it when making a clone.
source code
 
Override(self, overrides)
Produce a modified environment whose variables are overriden by the overrides dictionaries. "overrides" is a dictionary that will override the variables of this environment.
source code
 
ParseFlags(self, *flags)
Parse the set of flags and return a dict with the flags placed in the appropriate entry. The flags are treated as a typical set of command-line flags for a GNU-like toolchain and used to populate the entries in the dict immediately below. If one of the flag strings begins with a bang (exclamation mark), it is assumed to be a command and the rest of the string is executed; the result of that evaluation is then added to the dict.
source code
 
MergeFlags(self, args, unique=1, dict=None)
Merge the dict in args into the construction variables of this env, or the passed-in dict. If args is not a dict, it is converted into a dict using ParseFlags. If unique is not set, the flags are appended rather than merged.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, **kw)
(Constructor)

source code 
Initialization of an underlying SubstitutionEnvironment class.
Overrides: object.__init__

Override(self, overrides)

source code 

Produce a modified environment whose variables are overriden by the overrides dictionaries. "overrides" is a dictionary that will override the variables of this environment.

This function is much more efficient than Clone() or creating a new Environment because it doesn't copy the construction environment dictionary, it just wraps the underlying construction environment, and doesn't even create a wrapper object if there are no overrides.