ConditionalEmitter¶
-
class
sconstool.util.
ConditionalEmitter
(predicate, emitter_if=None, emitter_else=None)[source]¶ A callable object, which calls user-provided emitter when a predefined condition is meet.
Parameters: - predicate – a callable object (function) of type
pred(target, source, env)
; the function should return a boolean value; ifpred()
returns true, theConditionalEmitter`
will dispatch control to emitter_if, otherwise it will call emitter_else, - emitter_if – an emitter function of the form
emitter(target, source, env)
which gets called whenpred()
returnsTrue
, - emitter_else – an emitter function of the form
emitter(target, source, env)
which gets called whenpred()
returnsFalse
,
-
default_emitter
(target, source, env)[source]¶ Default emitter, just returns the tuple
(target, source)
.
-
emitter_else
¶ The value of emitter_else parameter passed in to the constructor at object creation, or
default_emitter
if emitter_else was omitted.
-
emitter_if
¶ The value of emitter_if parameter passed in to the constructor at object creation, or
default_emitter
if emitter_if was omitted.
-
predicate
¶ The value of predicate parameter passed in to the constructor at object creation
- predicate – a callable object (function) of type