當前位置: 首頁>>代碼示例>>Python>>正文


Python Rule.convert方法代碼示例

本文整理匯總了Python中rule.Rule.convert方法的典型用法代碼示例。如果您正苦於以下問題:Python Rule.convert方法的具體用法?Python Rule.convert怎麽用?Python Rule.convert使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rule.Rule的用法示例。


在下文中一共展示了Rule.convert方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: reply

# 需要導入模塊: from rule import Rule [as 別名]
# 或者: from rule.Rule import convert [as 別名]
    def reply(self, data, cb):
        info = data
        if not isinstance(data, Info):
            info = Info(data)

        if not self.config.get('keepBlank', False) and info.text:
            info.text = info.text.trim()

        rule_list = self.routes
        waiter = self.wait_rules.get(info.user, None)

        if waiter:
            rule_list = [].extend(waiter).extend(self.routes)
            self.last_wait_rules[info.user] = waiter
            self.wait_rules[info.user] = None

        for i in range(0, len(rule_list)):
            rule = rule_list[i]
            if Rule.is_match(info, rule):
                weixinlogger.info("match %s" % rule.name)
                conversationlogger.info("match %s" % rule.name)
                rule.count = i
                result = Rule.execute(info, rule, cb)
                if isinstance(result, (str, unicode)):
                    result = BuildConfig(MessageBuilder.TYPE_RAW_TEXT, None, result)
                if result:
                    if rule.replies:
                        self.wait(info.user, Rule.convert(rule.replies, rule.name))
                    return cb(None, result)

            else:
                logger.debug("not match %s" % rule.name)

        return cb('404', BuildConfig(MessageBuilder.TYPE_RAW_TEXT, None, self.get_status('404') + info.text))
開發者ID:,項目名稱:,代碼行數:36,代碼來源:

示例2: set

# 需要導入模塊: from rule import Rule [as 別名]
# 或者: from rule.Rule import convert [as 別名]
 def set(self, pattern, handler=None, replies=None):    
     if pattern and handler is None and replies is None:
         r = pattern
     else:
         r = {
             'name' : pattern,
             'pattern' : pattern,
             'handler' : handler,
             'replies' : replies
         }
     if r is not None:
         r = Rule.convert(r)
         self.routes.extend(r)
開發者ID:,項目名稱:,代碼行數:15,代碼來源:

示例3: wait

# 需要導入模塊: from rule import Rule [as 別名]
# 或者: from rule.Rule import convert [as 別名]
 def wait(self, uid, rule):
     if rule is not None:
         rule = Rule.convert(rule)
         self.wait_rules[uid] = rule
開發者ID:,項目名稱:,代碼行數:6,代碼來源:


注:本文中的rule.Rule.convert方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。