当前位置: 首页>>代码示例>>Python>>正文


Python Rule.addCondition方法代码示例

本文整理汇总了Python中Rule.Rule.addCondition方法的典型用法代码示例。如果您正苦于以下问题:Python Rule.addCondition方法的具体用法?Python Rule.addCondition怎么用?Python Rule.addCondition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Rule.Rule的用法示例。


在下文中一共展示了Rule.addCondition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getRule

# 需要导入模块: from Rule import Rule [as 别名]
# 或者: from Rule.Rule import addCondition [as 别名]
    def getRule(self, rid):
        dbRule = self.db.read("SELECT rid, name, enabled FROM rule r WHERE r.rid = :rid", { "rid": int(rid) })

        if dbRule == None:
            return False

        dbRule = dbRule.fetchone()

        if not dbRule:
            return False

        rule = Rule(dbRule['rid'], dbRule['name'], dbRule['enabled'])

        dbResConditions = self.db.read("SELECT c.cid, c.rule_rid, c.device_did, c.device_value_vid, c.operator, c.value, d.name FROM condition c LEFT JOIN device d ON d.did = c.device_did WHERE rule_rid = :rid", {"rid": rule.rid})

        for (cid, rule_rid, device_did, device_value_vid, operator, value, device_name) in dbResConditions.fetchall():
            rule.addCondition({
                "cid": cid,
                "rule_rid": rule_rid,
                "device_did": device_did,
                "device_name": device_name,
                "device_value_vid": device_value_vid,
                "operator": operator,
                "value": value
            })

        dbResActions = self.db.read("SELECT a.aid, a.rule_rid, a.device_did, a.device_action_aid, a.value, d.name FROM action a LEFT JOIN device d ON d.did = a.device_did WHERE a.rule_rid = :rid", {"rid": rule.rid})

        for (aid, rule_rid, device_did, device_action_aid, value, device_name) in dbResActions.fetchall():
            rule.addAction({
                "aid": aid,
                "rule_rid": rule_rid,
                "device_did": device_did,
                "device_name": device_name,
                "device_action_aid": device_action_aid,
                "value": value
            })

        return rule
开发者ID:theNailz,项目名称:drw,代码行数:41,代码来源:RuleManager.py


注:本文中的Rule.Rule.addCondition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。