Package SCons :: Module Subst
[hide private]
[frames] | no frames]

Module Subst

source code

SCons.Subst

SCons string substitution.

Classes [hide private]
  Literal
A wrapper for a string. If you use this object wrapped around a string, then it will be interpreted as literal. When passed to the command interpreter, all special characters will be escaped.
  SpecialAttrWrapper
This is a wrapper for what we call a 'Node special attribute.' This is any of the attributes of a Node that we can reference from Environment variable substitution, such as $TARGET.abspath or $SOURCES[1].filebase. We implement the same methods as Literal so we can handle special characters, plus a for_signature method, such that we can return some canonical string during signature calculation to avoid unnecessary rebuilds.
  CmdStringHolder
This is a special class used to hold strings generated by scons_subst() and scons_subst_list(). It defines a special method escape(). When passed a function with an escape algorithm for a particular platform, it will return the contained string with the proper escape sequences inserted.
  NLWrapper
A wrapper class that delays turning a list of sources or targets into a NodeList until it's needed. The specified function supplied when the object is initialized is responsible for turning raw nodes into proxies that implement the special attributes like .abspath, .source, etc. This way, we avoid creating those proxies just "in case" someone is going to use $TARGET or the like, and only go through the trouble if we really have to.
  Targets_or_Sources
A class that implements $TARGETS or $SOURCES expansions by in turn wrapping a NLWrapper. This class handles the different methods used to access the list, calling the NLWrapper to create proxies on demand.
  Target_or_Source
A class that implements $TARGET or $SOURCE expansions by in turn wrapping a NLWrapper. This class handles the different methods used to access an individual proxy Node, calling the NLWrapper to create a proxy on demand.
  NullNodeList
Functions [hide private]
 
SetAllowableExceptions(*excepts) source code
 
raise_exception(exception, target, s) source code
 
quote_spaces(arg)
Generic function for putting double quotes around any string that has white space in it.
source code
 
escape_list(mylist, escape_func)
Escape a list of arguments by running the specified escape_func on every object in the list that has an escape() method.
source code
 
subst_dict(target, source)
Create a dictionary for substitution of special construction variables.
source code
 
_rm_list(list) source code
 
_remove_list(list) source code
 
scons_subst(strSubst, env, mode=1, target=None, source=None, gvars={}, lvars={}, conv=None)
Expand a string or list containing construction variable substitutions.
source code
 
scons_subst_list(strSubst, env, mode=1, target=None, source=None, gvars={}, lvars={}, conv=None)
Substitute construction variables in a string (or list or other object) and separate the arguments into a command list.
source code
 
scons_subst_once(strSubst, env, key)
Perform single (non-recursive) substitution of a single construction variable keyword.
source code
Variables [hide private]
  __revision__ = 'src/engine/SCons/Subst.py rel_2.4.1:3453:73fef...
  _strconv = [SCons.Util.to_String_for_subst, SCons.Util.to_Stri...
  AllowableExceptions = (<type 'exceptions.IndexError'>, <type '...
  NullNodesList = Null(0xB6B0B6EC)
  SUBST_CMD = 0
  SUBST_RAW = 1
  SUBST_SIG = 2
  _rm = re.compile(r'\$[\(\)]')
  _remove = re.compile(r'\$\([^\$]*(\$[^\)][^\$]*)*\$\)')
  _regex_remove = [re.compile(r'\$[\(\)]'), None, re.compile(r'\...
  _list_remove = [_rm_list, None, _remove_list]
  _dollar_exps_str = '\\$[\\$\\(\\)]|\\$[_a-zA-Z][\\.\\w]*|\\${[...
  _dollar_exps = re.compile(r'(\$[\$\(\)]|[_a-zA-Z][\.\w]*|\{[^\...
  _separate_args = re.compile(r'(\$[\$\(\)]|\$[_a-zA-Z][\.\w]*|\...
  _space_sep = re.compile(r'[\t ]+(?![^\{]*\})')
  __package__ = 'SCons'
Function Details [hide private]

subst_dict(target, source)

source code 

Create a dictionary for substitution of special construction variables.

This translates the following special arguments:

target - the target (object or array of objects),
used to generate the TARGET and TARGETS construction variables
source - the source (object or array of objects),
used to generate the SOURCES and SOURCE construction variables

scons_subst(strSubst, env, mode=1, target=None, source=None, gvars={}, lvars={}, conv=None)

source code 

Expand a string or list containing construction variable substitutions.

This is the work-horse function for substitutions in file names and the like. The companion scons_subst_list() function (below) handles separating command lines into lists of arguments, so see that function if that's what you're looking for.

scons_subst_list(strSubst, env, mode=1, target=None, source=None, gvars={}, lvars={}, conv=None)

source code 

Substitute construction variables in a string (or list or other object) and separate the arguments into a command list.

The companion scons_subst() function (above) handles basic substitutions within strings, so see that function instead if that's what you're looking for.

scons_subst_once(strSubst, env, key)

source code 

Perform single (non-recursive) substitution of a single construction variable keyword.

This is used when setting a variable when copying or overriding values in an Environment. We want to capture (expand) the old value before we override it, so people can do things like:

env2 = env.Clone(CCFLAGS = '$CCFLAGS -g')

We do this with some straightforward, brute-force code here...


Variables Details [hide private]

__revision__

Value:
'src/engine/SCons/Subst.py rel_2.4.1:3453:73fefd3ea0b0 2015/11/09 03:2\
5:05 bdbaddog'

_strconv

Value:
[SCons.Util.to_String_for_subst, SCons.Util.to_String_for_subst, SCons\
.Util.to_String_for_signature]

AllowableExceptions

Value:
(<type 'exceptions.IndexError'>, <type 'exceptions.NameError'>)

_regex_remove

Value:
[re.compile(r'\$[\(\)]'),
 None,
 re.compile(r'\$\([^\$]*(\$[^\)][^\$]*)*\$\)')]

_dollar_exps_str

Value:
'\\$[\\$\\(\\)]|\\$[_a-zA-Z][\\.\\w]*|\\${[^}]*}'

_dollar_exps

Value:
re.compile(r'(\$[\$\(\)]|[_a-zA-Z][\.\w]*|\{[^\}]*\})')

_separate_args

Value:
re.compile(r'(\$[\$\(\)]|\$[_a-zA-Z][\.\w]*|\$\{[^\}]*\}|\s+|[^\s\$]+|\
\$)')