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


Python ObjectDict.description方法代码示例

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


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

示例1: post

# 需要导入模块: from tornado.util import ObjectDict [as 别名]
# 或者: from tornado.util.ObjectDict import description [as 别名]
    def post(self):
        o = ObjectDict()
        o.title = self.get_argument("title", None)
        o.slug = self.get_argument("slug", None)
        o.avatar = self.get_argument("avatar", None)
        o.description = self.get_argument("description", None)
        o.fgcolor = self.get_argument("fgcolor", None)
        o.bgcolor = self.get_argument("bgcolor", None)
        o.header = self.get_argument("header", None)
        o.sidebar = self.get_argument("sidebar", None)
        o.footer = self.get_argument("footer", None)
        try:
            o.limit_reputation = int(self.get_argument("reputation", 0))
        except:
            o.limit_reputation = 0

        try:
            o.limit_role = int(self.get_argument("role", 0))
        except:
            o.limit_role = 0

        if not (o.slug and o.title and o.description):
            self._context.message = "Please fill the required field"
            self.render("dashboard_node.html", node=o)
            return
        node = Node(**o)
        self.db.add(node)
        self.db.commit()
        self.redirect("/node/%s" % o.slug)
开发者ID:eth2net,项目名称:june,代码行数:31,代码来源:dashboard.py

示例2: parse_msg

# 需要导入模块: from tornado.util import ObjectDict [as 别名]
# 或者: from tornado.util.ObjectDict import description [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

示例3: respond

# 需要导入模块: from tornado.util import ObjectDict [as 别名]
# 或者: from tornado.util.ObjectDict import description [as 别名]
def respond(data, msg=None):
    parser = feedparser.parse(options.feed_url)
    articles = []
    i = 0
    for entry in parser.entries:
        if i > 9:
            break
        article = ObjectDict()
        article.title = entry.title
        article.description = entry.description[0:100]
        article.url = entry.link
        article.picurl = ''
        articles.append(article)
        i += 1
    return articles
开发者ID:eclipse2x,项目名称:wechat-bot,代码行数:17,代码来源:feed.py

示例4: respond

# 需要导入模块: from tornado.util import ObjectDict [as 别名]
# 或者: from tornado.util.ObjectDict import description [as 别名]
def respond(data, msg=None):
    res = requests.get("http://www.v2ex.com/api/topics/latest.json")
    topics = json_decode(res.text)
    articles = []
    i = 0
    while i < 10:
        article = ObjectDict()
        article.title = topics[i]['title']
        article.url = topics[i]['url']
        if i == 0:
            article.picurl = 'http://openoceans.de/img/v2ex_logo_uranium.png'
        else:
            article.picurl = ''
        article.description = topics[i]['content_rendered'][0:100]
        articles.append(article)
        i += 1
    return articles
开发者ID:glovebx,项目名称:wechat-bot,代码行数:19,代码来源:v2ex.py

示例5: respond

# 需要导入模块: from tornado.util import ObjectDict [as 别名]
# 或者: from tornado.util.ObjectDict import description [as 别名]
def respond(data, msg=None, bot=None, handler=None):
    myfus = handler.get_user_follows(msg.fromuser)
    post_query = handler.db.query(CoePost).filter(
        CoePost.username.in_(myfus)
        ).order_by(CoePost.created.desc()).limit(9)
    articles = []
    for post in post_query:
        if post.is_ignore == 1:
            continue        
        article = ObjectDict()
        article.title = post.topic
        article.description = rtitle(post.content,79)
        article.url = "%s/mps/post/%s?otoken=%s" % (handler.settings['server_base'],
                 post.post_id,handler.encrypt_otoken(bot.id))
        article.picurl = handler.get_1img_from_content(post.content) or handler.settings['mps_default_bg']
        articles.append(article)

    return articles
开发者ID:talkincode,项目名称:comeonever,代码行数:20,代码来源:myfollows.py

示例6: parse_msg

# 需要导入模块: from tornado.util import ObjectDict [as 别名]
# 或者: from tornado.util.ObjectDict import description [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

示例7: respond

# 需要导入模块: from tornado.util import ObjectDict [as 别名]
# 或者: from tornado.util.ObjectDict import description [as 别名]
def respond(data, msg=None, bot=None, handler=None):
    nodes = handler.db.query(CoeNode).filter(
        CoeNode.is_top == 1).order_by(CoeNode.created.asc()).limit(9)
    articles = []
    for node in nodes:
        if node.is_hide == 1:
            continue        
        article = ObjectDict()
        article.title = node.node_desc
        article.description = rtitle(node.node_intro,79)
        article.url = "%s/mps/post/new/%s?otoken=%s" % (
            handler.settings['server_base'],
            node.node_name,
            handler.encrypt_otoken(bot.id))
        article.picurl = ''
        articles.append(article)

    if len(articles)>1:
        articles[0].picurl = handler.settings['mps_default_bg']

    return articles
开发者ID:talkincode,项目名称:comeonever,代码行数:23,代码来源:post.py

示例8: respond

# 需要导入模块: from tornado.util import ObjectDict [as 别名]
# 或者: from tornado.util.ObjectDict import description [as 别名]
def respond(data, msg=None, bot=None):
    headers = {
        'Host' : 'www.oschina.net',
        'Connection' : 'Keep-Alive',
        'User-Agent' : 'OSChina.NET/1.7.4_1/Android/4.1/Nexus S/12345678'
    }
    res = requests.get("http://www.oschina.net/action/api/news_list",
                       headers=headers)
    parser = ElementTree.fromstring(res.content)
    news_list = parser.find('newslist')
    articles = []
    i = 0
    for news in news_list.iter('news'):
        if i > 9:
            break
        article = ObjectDict()
        article.title = news.find('title').text
        article.description = article.title
        article.url = "http://www.oschina.net/news/%s" % news.find('id').text
        article.picurl = ''
        articles.append(article)
        i += 1

    return articles
开发者ID:Dordorgum,项目名称:wechat-bot,代码行数:26,代码来源:oschina.py


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