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


Python ObjectDict.event_key方法代码示例

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


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

示例1: parse_msg

# 需要导入模块: from tornado.util import ObjectDict [as 别名]
# 或者: from tornado.util.ObjectDict import event_key [as 别名]
def parse_msg(xml):
    if not xml:
        return None
    parser = ElementTree.fromstring(xml)
    id_node = parser.find('MsgId')
    msg_id = id_node and int(id_node.text) or 0
    msg_type = decode(parser.find('MsgType').text)
    touser = decode(parser.find('ToUserName').text)
    fromuser = decode(parser.find('FromUserName').text)
    create_at = int(parser.find('CreateTime').text)
    msg = ObjectDict(
        mid=msg_id,
        type=msg_type,
        touser=touser,
        fromuser=fromuser,
        time=create_at
    )
    if msg_type == MSG_TYPE_TEXT:
        msg.content = decode(parser.find('Content').text)
    elif msg_type == MSG_TYPE_LOCATION:
        msg.location_x = decode(parser.find('Location_X').text)
        msg.location_y = decode(parser.find('Location_Y').text)
        msg.scale = int(parser.find('Scale').text)
        msg.label = decode(parser.find('Label').text)
    elif msg_type == MSG_TYPE_IMAGE:
        msg.picurl = decode(parser.find('PicUrl').text)
    elif msg_type == MSG_TYPE_LINK:
        msg.title = decode(parser.find('Title').text)
        msg.description = decode(parser.find('Description').text)
        msg.url = decode(parser.find('Url').text)
    elif msg_type == MSG_TYPE_EVENT:
        msg.event = decode(parser.find('Event').text)
        msg.event_key = decode(parser.find('EventKey').text)
    return msg
开发者ID:jamiesun,项目名称:talkincode_mp,代码行数:36,代码来源:sender.py

示例2: parse_msg

# 需要导入模块: from tornado.util import ObjectDict [as 别名]
# 或者: from tornado.util.ObjectDict import event_key [as 别名]
def parse_msg(xml):
    if not xml:
        return None
    parser = ElementTree.fromstring(xml)
    msg_id = parse_node(parser, 'MsgId', get_uuid())
    msg_type = parse_node(parser, 'MsgType')
    touser = parse_node(parser, 'ToUserName')
    fromuser = parse_node(parser, 'FromUserName')
    create_at = int(parse_node(parser, 'CreateTime', 0))
    msg = ObjectDict(
        mid=msg_id,
        type=msg_type,
        touser=touser,
        fromuser=fromuser,
        time=create_at
    )
    if msg_type == MSG_TYPE_TEXT:
        msg.content = parse_node(parser, 'Content')
    elif msg_type == MSG_TYPE_LOCATION:
        msg.location_x = parse_node(parser, 'Location_X')
        msg.location_y = parse_node(parser, 'Location_Y')
        msg.scale = int(parse_node(parser, 'Scale'))
        msg.label = parse_node(parser, 'Label')
    elif msg_type == MSG_TYPE_IMAGE:
        msg.picurl = parse_node(parser, 'PicUrl')
    elif msg_type == MSG_TYPE_VOICE:
        msg.media_id = parse_node(parser, 'MediaId')
        msg.format = parse_node(parser, 'Format')
    elif msg_type == MSG_TYPE_VIDEO:
        msg.media_id = parse_node(parser, 'MediaId')
        msg.thumb = parse_node(parser, 'ThumbMediaId')
    elif msg_type == MSG_TYPE_LINK:
        msg.title = parse_node(parser, 'Title')
        msg.description = parser.find('Description').text
        msg.url = parse_node(parser, 'Url')
    elif msg_type == MSG_TYPE_EVENT:
        msg.event = parse_node(parser, 'Event')
        msg.event_key = parse_node(parser, 'EventKey')
        msg.ticket = parse_node(parser, 'Ticket')
        if msg.event == 'LOCATION':
            msg.latitude = parse_node(parser, 'Latitude')
            msg.longitude = parse_node(parser, 'Longitude')
            msg.precision = parse_node(parser, 'Precision')
    return msg
开发者ID:talkincode,项目名称:comeonever,代码行数:46,代码来源:mpsmsg.py


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