本文整理匯總了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))
示例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)
示例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