def execute_rule(rule, matches, context):
 if rule.enabled(context):
  log(rule.log_level, 'Checking rule condition: %s', rule)
  when_response = rule.when(matches, context)
  if when_response:
   log(rule.log_level, 'Rule was triggered: %s', when_response)
   log(rule.log_level, 'Running rule consequence: %s %s', rule, when_response)
   rule.then(matches, when_response, context)
   return when_response
 else:
  log(rule.log_level, 'Rule is disabled: %s', rule)

def execute_rule ( rule , matches , context ) : if rule . enabled ( context ) : log ( rule . log_level , 'Checking rule condition: %s' , rule ) when_response = rule . when ( matches , context ) if when_response : log ( rule . log_level , 'Rule was triggered: %s' , when_response ) log ( rule . log_level , 'Running rule consequence: %s %s' , rule , when_response ) rule . then ( matches , when_response , context ) return when_response else : log ( rule . log_level , 'Rule is disabled: %s' , rule )
execute the given rule .