yagwr.rules
: Rules container
- class yagwr.rules.Rule(condition, action)
Bases:
object
This class reprents a rule. A rule is the cobination of a condition and action. If the condition matches, the action can be executed.
- Parameters
condition (checker.Node) – A Node object that holds the condition
action (any) – the action. This object just stores the action, it doesn’t manipulate it. Hence you can set any object you like.
- matches(obj)
Return whether the condition matches the object
- classmethod from_dict(obj)
Generates a new
Rule
object from a dictionary.The dictionary must have two key:
condition: see The condition dictionary for more information
- action: an object (usually string) with the action to be taken
when the condition matches
- Returns
A new rule
- Return type
- Raises
checker.InvalidExpression – when parsing the condition fails