ConditionalEmitter¶
Description¶
ConditionalEmitter
is a callable object which dispatches control
between two user-provided functions: emitter_if
and emitter_else
, both
having the following prototype:
emitter(target, source, env)
The ConditionalEmitter
object is designed to be used as a SCons
emitter. The decision, which of the user-provided functions shall be called,
is made based on a user-defined condition, which, again, is provided by user in
the form of a predicate
function
predicate(target, source, env)
The predicate
shall return a boolean value.
In short, the following conditional emitter
em = ConditionalEmitter(predicate, emitter_if, emitter_else)
when used as
res = em(target, source, env)
will return the result of emitter_if(target, source, env)
if
predicate(target, source, env)
is True
, or will return the result of
emitter_else(target, source, env)
otherwise.