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

Class SubstitutionEnvironment

source code

Known Subclasses:
Base

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=False)
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 at 0x855905c>, lookup_list=<class SCons.Environment._Null at 0x855905c>, **kw) source code
 
gvars(self) source code
 
lvars(self) source code
 
subst(self, string, raw=0, target=False, source=False, conv=False)
Recursively interpolates construction variables from the Environment into the specified string, returning the expanded result.
source code
 
subst_kw(self, kw, raw=0, target=False, source=False) source code
 
subst_list(self, string, raw=0, target=False, source=False, conv=False)
Calls through to SCons.Subst.scons_subst_list().
source code
 
subst_path(self, path, target=False, source=False)
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=False, source=False, conv=False)
Recursively interpolates construction variables from the Environment into the specified string, returning the expanded result.
source code
 
backtick(self, command) source code
 
AddMethod(self, function, name=False)
Adds the specified function as a method of this construction environment with the specified name.
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.
source code
 
ParseFlags(self, *flags)
Parse the set of flags and return a dict with the flags placed in the appropriate entry.
source code
 
MergeFlags(self, args, unique=False, dict=False)
Merge the dict in args into the construction variables of this env, or the passed-in dict.
source code
Class Variables [hide private]
  __metaclass__ = SCons.Memoize.Memoized_Metaclass
Method Details [hide private]

subst(self, string, raw=0, target=False, source=False, conv=False)

source code 
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.

subst_list(self, string, raw=0, target=False, source=False, conv=False)

source code 
Calls through to SCons.Subst.scons_subst_list().  See
the documentation for that function.

subst_target_source(self, string, raw=0, target=False, source=False, conv=False)

source code 
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.

AddMethod(self, function, name=False)

source code 

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.

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.

ParseFlags(self, *flags)

source code 

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.

MergeFlags(self, args, unique=False, dict=False)

source code 

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.