parameters: (strSubst, env, mode=SUBST_RAW, target=None, source=None, gvars={}, lvars={}, conv=None)
return_statement: return result
docstring: 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.
docstring_summary: Expand a string or list containing construction variable
      substitutions.
docstring_tokens: Expand a string or list containing construction variable substitutions .
function: def scons_subst(strSubst, env, mode=SUBST_RAW, target=None, source=None, gvars={}, lvars={}, conv=None):
      """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.
      """
      if (isinstance(strSubst, str) and '$' not in strSubst) or isinstance(strSubst, CmdStringHolder):
          return strSubst
  
      if conv is None:
          conv = _strconv[mode]
  
      # Doing this every time is a bit of a waste, since the Executor
      # has typically already populated the OverrideEnvironment with
      # $TARGET/$SOURCE variables.  We're keeping this (for now), though,
      # because it supports existing behavior that allows us to call
      # an Action directly with an arbitrary target+source pair, which
      # we use in Tool/tex.py to handle calling $BIBTEX when necessary.
      # If we dropped that behavior (or found another way to cover it),
      # we could get rid of this call completely and just rely on the
      # Executor setting the variables.
      if 'TARGET' not in lvars:
          d = subst_dict(target, source)
          if d:
              lvars = lvars.copy()
              lvars.update(d)
  
      # We're (most likely) going to eval() things.  If Python doesn't
      # find a __builtins__ value in the global dictionary used for eval(),
      # it copies the current global values for you.  Avoid this by
      # setting it explicitly and then deleting, so we don't pollute the
      # construction environment Dictionary(ies) that are typically used
      # for expansion.
      gvars['__builtins__'] = __builtins__
  
      ss = StringSubber(env, mode, conv, gvars)
      result = ss.substitute(strSubst, lvars)
  
      try:
          del gvars['__builtins__']
      except KeyError:
          pass
  
      res = result
      if is_String(result):
          # Remove $(-$) pairs and any stuff in between,
          # if that's appropriate.
          remove = _regex_remove[mode]
          if remove:
              if mode == SUBST_SIG:
                  result = _list_remove[mode](remove.split(result))
                  if result is None:
                      raise SCons.Errors.UserError("Unbalanced $(/$) in: " + res)
                  result = ' '.join(result)
              else:
                  result = remove.sub('', result)
          if mode != SUBST_RAW:
              # Compress strings of white space characters into
              # a single space.
              result = _space_sep.sub(' ', result).strip()
  
          # Now replace escaped $'s currently "$$"
          # This is needed because we now retain $$ instead of
          # replacing them during substition to avoid
          # improperly trying to escape "$$(" as being "$("
          result = result.replace('$$','$')
      elif is_Sequence(result):
          remove = _list_remove[mode]
          if remove:
              result = remove(result)
              if result is None:
                  raise SCons.Errors.UserError("Unbalanced $(/$) in: " + str(res))
  
      return result
function_tokens: def scons_subst ( strSubst , env , mode = SUBST_RAW , target = None , source = None , gvars = { } , lvars = { } , conv = None ) : if ( isinstance ( strSubst , str ) and '$' not in strSubst ) or isinstance ( strSubst , CmdStringHolder ) : return strSubst if conv is None : conv = _strconv [ mode ] # Doing this every time is a bit of a waste, since the Executor # has typically already populated the OverrideEnvironment with # $TARGET/$SOURCE variables.  We're keeping this (for now), though, # because it supports existing behavior that allows us to call # an Action directly with an arbitrary target+source pair, which # we use in Tool/tex.py to handle calling $BIBTEX when necessary. # If we dropped that behavior (or found another way to cover it), # we could get rid of this call completely and just rely on the # Executor setting the variables. if 'TARGET' not in lvars : d = subst_dict ( target , source ) if d : lvars = lvars . copy ( ) lvars . update ( d ) # We're (most likely) going to eval() things.  If Python doesn't # find a __builtins__ value in the global dictionary used for eval(), # it copies the current global values for you.  Avoid this by # setting it explicitly and then deleting, so we don't pollute the # construction environment Dictionary(ies) that are typically used # for expansion. gvars [ '__builtins__' ] = __builtins__ ss = StringSubber ( env , mode , conv , gvars ) result = ss . substitute ( strSubst , lvars ) try : del gvars [ '__builtins__' ] except KeyError : pass res = result if is_String ( result ) : # Remove $(-$) pairs and any stuff in between, # if that's appropriate. remove = _regex_remove [ mode ] if remove : if mode == SUBST_SIG : result = _list_remove [ mode ] ( remove . split ( result ) ) if result is None : raise SCons . Errors . UserError ( "Unbalanced $(/$) in: " + res ) result = ' ' . join ( result ) else : result = remove . sub ( '' , result ) if mode != SUBST_RAW : # Compress strings of white space characters into # a single space. result = _space_sep . sub ( ' ' , result ) . strip ( ) # Now replace escaped $'s currently "$$" # This is needed because we now retain $$ instead of # replacing them during substition to avoid # improperly trying to escape "$$(" as being "$(" result = result . replace ( '$$' , '$' ) elif is_Sequence ( result ) : remove = _list_remove [ mode ] if remove : result = remove ( result ) if result is None : raise SCons . Errors . UserError ( "Unbalanced $(/$) in: " + str ( res ) ) return result