def while_action_to_code(config, action_id, arg_type, template_arg): for conditions in build_conditions(config[CONF_CONDITION], arg_type): yield None rhs = WhileAction.new(template_arg, conditions) type = WhileAction.template(template_arg) action = Pvariable(action_id, rhs, type=type) for actions in build_actions(config[CONF_THEN], arg_type): yield None add(action.add_then(actions)) yield action
def if_action_to_code(config, action_id, arg_type, template_arg): for conditions in build_conditions(config[CONF_CONDITION], arg_type): yield None rhs = IfAction.new(template_arg, conditions) type = IfAction.template(template_arg) action = Pvariable(action_id, rhs, type=type) if CONF_THEN in config: for actions in build_actions(config[CONF_THEN], arg_type): yield None add(action.add_then(actions)) if CONF_ELSE in config: for actions in build_actions(config[CONF_ELSE], arg_type): yield None add(action.add_else(actions)) yield action