Replacements¶
-
class
sconstool.util.
Replacements
[source]¶ Enables one to temporarily replace variables in a dict-like object (SCons
Environment
).The
Replacements
are designed to be used withReplacingBuilder
orReplacingAction
.-
apply
(subj, include_unmapped=False)[source]¶ Apply replacements to subj.
Returns a dictionary of variables from subj set to their replacement values. By default, only variables having their replacements are extracted. If include_unmapped is
True
, remaining variables from subj will also be added to the returned dictionary.Parameters: Return dict: replaced variables from subj*.
-
inject
(dest, setter='__setitem__', only_present=False)[source]¶ Inject replacement variables into the dest.
This method is supposed to be used to initialize replacement variables in the dictionary dest. For each mapping
{'FOO': 'BAR'}
inReplacements
dest['BAR'] = '$FOO'
assignment will be performed using the provided setter. If only_present isTrue
, the assignment will be performed only if the variabledest['FOO']
is already defined.Parameters: - dest (dict) – destination dictionary to be modified,
- setter (str,callable) – a method (or method name) of dest that sets items in dest,
should be a function with prototype
dest.setter(name, value)
, except forSetDefault
,Replace
,Append
,Prepend
,AppendUnique
,PrependUnique
methods of SCons environment where the prototype isdest.setter(**kw)
, - only_present (bool) – if
True
, only the replacements for variables already present in dest will be set.
-