• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.is_DM函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中turses.models.is_DM函数的典型用法代码示例。如果您正苦于以下问题:Python is_DM函数的具体用法?Python is_DM怎么用?Python is_DM使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_is_DM

    def test_is_DM(self):
        # status is NOT a DM
        status = create_status()
        self.failIf(is_DM(status))

        dm = create_direct_message()
        self.failUnless(is_DM(dm))
开发者ID:battlemidget,项目名称:turses,代码行数:7,代码来源:test_models.py


示例2: test_is_DM

    def test_is_DM(self):
        # status is NOT a DM
        status = create_status()
        self.assertFalse(is_DM(status))

        dm = create_direct_message()
        self.assertTrue(is_DM(dm))
开发者ID:fmartingr,项目名称:turses,代码行数:7,代码来源:test_models.py


示例3: append_thread_timeline

    def append_thread_timeline(self):
        status = self.timelines.active_status

        timeline_fetched = partial(self.info_message,
                                   _('Thread fetched'))
        timeline_not_fetched = partial(self.error_message,
                                       _('Failed to fetch thread'))

        if is_DM(status):
            participants = [status.sender_screen_name,
                            status.recipient_screen_name]
            name = _('DM thread: %s' % ', '.join(participants))
            update_function = self.api.get_message_thread
        else:
            participants = status.mentioned_usernames
            author = status.authors_username
            if author not in participants:
                participants.insert(0, author)

            name = _('thread: %s' % ', '.join(participants))
            update_function = self.api.get_thread

        self.append_timeline(name=name,
                             update_function=update_function,
                             update_args=status,
                             on_error=timeline_not_fetched,
                             on_success=timeline_fetched)
开发者ID:battlemidget,项目名称:turses,代码行数:27,代码来源:core.py


示例4: retweet

    def retweet(self):
        status = self.timelines.active_status

        if is_DM(status):
            self.error_message(_('You can\'t retweet direct messages'))
            return

        self._retweet(status)
开发者ID:battlemidget,项目名称:turses,代码行数:8,代码来源:core.py


示例5: __init__

    def __init__(self, status):
        self.status = status

        header_text = self._create_header(status)
        text = map_attributes(status, hashtag="hashtag", attag="attag", url="url")

        is_favorite = not is_DM(status) and status.is_favorite
        widget = self._build_widget(header_text, text, is_favorite)

        self.__super.__init__(widget)
开发者ID:rnhmjoj,项目名称:turses,代码行数:10,代码来源:ui.py


示例6: open_status_url

    def open_status_url(self):
        """
        Open the focused tweet in a browser.
        """
        status = self.timelines.active_status

        if is_DM(status):
            message = _('You only can open regular statuses in a browser')
            self.info_message(message)
            return

        self.open_urls_in_browser([status.url])
开发者ID:battlemidget,项目名称:turses,代码行数:12,代码来源:core.py


示例7: __init__

    def __init__(self, status, configuration):
        self.status = status
        self.configuration = configuration

        header_text = self._create_header(status)
        text = status.map_attributes(hashtag='hashtag',
                                     attag='attag',
                                     url='url')

        is_favorite = not is_DM(status) and status.is_favorite
        widget = self._build_widget(header_text, text, is_favorite)

        self.__super.__init__(widget)
开发者ID:1reza,项目名称:turses,代码行数:13,代码来源:ui.py


示例8: __init__

    def __init__ (self, status, configuration):
        self.status = status
        self.configuration = configuration

        text = self.apply_attributes(status.text)
        status_content = Padding(AttrMap(Text(text), 'body'), left=1, right=1)
        header = self._create_header(status)
        box = BoxDecoration(status_content, title=header)

        if not is_DM(status) and status.is_favorite:
            widget = AttrMap(box, 'favorited', 'focus')
        else:
            widget = AttrMap(box, 'line', 'focus')
        self.__super.__init__(widget)
开发者ID:gigigi,项目名称:turses,代码行数:14,代码来源:ui.py


示例9: retweet

    def retweet(self):
        status = self.timelines.active_status

        if is_DM(status):
            self.error_message(_('You can\'t retweet direct messages'))
            return

        retweet_posted = partial(self.info_message,
                                 _('Retweet posted'))
        retweet_post_failed = partial(self.error_message,
                                      _('Failed to post retweet'))
        self.api.retweet(on_error=retweet_post_failed,
                         on_success=retweet_posted,
                         status=status,)
开发者ID:floppym,项目名称:turses,代码行数:14,代码来源:core.py


示例10: open_status_url

    def open_status_url(self):
        """
        Display URL for the focused tweet.
        """
        status = self.timelines.active_status

        if is_DM(status):
            message = _('You only can open regular statuses in a browser')
            self.info_message(message)
            return

        if configuration.styles['no_webbrowser']:
            self.ui.show_status_info(status)
            self.status_info_mode()
        else:
            self.open_urls_in_browser([status.url]) 
开发者ID:ripperbone,项目名称:turses,代码行数:16,代码来源:core.py


示例11: reply

    def reply(self):
        status = self.timelines.get_active_status()
        if status is None:
            return
        if is_DM(status):
            self.direct_message()
            return

        author = get_authors_username(status)
        mentioned = get_mentioned_for_reply(status)
        try:
            mentioned.remove('@%s' % self.user.screen_name)
        except ValueError:
            pass

        self.ui.show_tweet_editor(prompt=_('Reply to %s' % author),
                                  content=' '.join(mentioned),
                                  done_signal_handler=self.tweet_handler)
开发者ID:gigigi,项目名称:turses,代码行数:18,代码来源:core.py


示例12: reply

    def reply(self):
        status = self.timelines.active_status

        if is_DM(status):
            self.direct_message()
            return

        author = status.authors_username
        mentioned = status.mentioned_for_reply
        try:
            mentioned.remove('@%s' % self.user.screen_name)
        except ValueError:
            pass

        handler = self.reply_handler
        editor = self.ui.show_tweet_editor(prompt=_('Reply to %s' % author),
                                           content=' '.join(mentioned),
                                           done_signal_handler=handler)
        self.editor_mode(editor)
开发者ID:battlemidget,项目名称:turses,代码行数:19,代码来源:core.py


示例13: _create_header

    def _create_header(self, status):
        """
        Return the header text for the status associated with this widget.
        """
        if is_DM(status):
            return self._dm_header(status)

        reply = ''
        retweeted = ''
        retweet_count = ''
        retweeter = ''
        username = status.user
        relative_created_at = status.relative_created_at

        # reply
        if status.is_reply:
            reply = surround_with_spaces(
                configuration.styles['reply_indicator'])

        # retweet
        if status.is_retweet:
            retweeted = surround_with_spaces(
                configuration.styles['retweet_indicator'])
            # `username` is the author of the original tweet
            username = status.author
            # `retweeter` is the user who made the RT
            retweeter = status.user
            retweet_count = str(status.retweet_count)

        # create header
        styles = configuration.styles
        header_template = ' ' + styles.get('header_template') + ' '
        header = str(header_template).format(
            username=username,
            retweeted=retweeted,
            retweeter=retweeter,
            time=relative_created_at,
            reply=reply,
            retweet_count=retweet_count,
        )

        return encode(header)
开发者ID:ripperbone,项目名称:turses,代码行数:42,代码来源:ui.py


示例14: delete_tweet

    def delete_tweet(self):
        status = self.timelines.active_status

        if is_DM(status):
            self.delete_dm()
            return

        author = status.authors_username
        if author != self.user.screen_name and status.user != self.user.screen_name:
            self.error_message(_('You can only delete your own tweets'))
            return

        status_deleted = partial(self.info_message,
                                 _('Tweet deleted'))
        status_not_deleted = partial(self.error_message,
                                     _('Failed to delete tweet'))

        self.api.destroy_status(status=status,
                                on_error=status_not_deleted,
                                on_success=status_deleted)
开发者ID:Erik-k,项目名称:turses,代码行数:20,代码来源:core.py


示例15: _create_header

    def _create_header(self, status):
        """
        Return the header text for the status associated with this widget.
        """
        if is_DM(status):
            return self._dm_header(status)

        reply = ""
        retweeted = ""
        retweet_count = ""
        retweeter = ""
        username = status.user
        relative_created_at = status.relative_created_at

        # reply
        if status.is_reply:
            reply = u" \u2709"

        # retweet
        if status.is_retweet:
            retweeted = u" \u267b "
            # `username` is the author of the original tweet
            username = status.author
            # `retweeter` is the user who made the RT
            retweeter = status.user
            retweet_count = str(status.retweet_count)

        # create header
        styles = self.configuration.styles
        header_template = " " + styles.get("header_template") + " "
        header = unicode(header_template).format(
            username=username,
            retweeted=retweeted,
            retweeter=retweeter,
            time=relative_created_at,
            reply=reply,
            retweet_count=retweet_count,
        )

        return encode(header)
开发者ID:ivanov,项目名称:turses,代码行数:40,代码来源:ui.py


示例16: thread

    def thread(self, status):
        """
        Create a timeline with the conversation to which `status` belongs.
        `status` can be a regular status or a direct message.
        """
        if is_DM(status):
            participants = [status.sender_screen_name,
                            status.recipient_screen_name]
            name = _('DM thread: %s' % ', '.join(participants))
            update_function = self.api.get_message_thread
        else:
            participants = status.mentioned_usernames
            author = status.authors_username
            if author not in participants:
                participants.insert(0, author)

            name = _('thread: %s' % ', '.join(participants))
            update_function = self.api.get_thread

        return Timeline(name=name,
                        update_function=update_function,
                        update_function_args=status,)
开发者ID:floppym,项目名称:turses,代码行数:22,代码来源:helpers.py


示例17: _create_header

    def _create_header(self, status):
        """Return the header text for the status associated with this widget."""
        if is_DM(status):
            return self._dm_header(status)

        # tweet or retweet
        reply = ''
        retweeted = ''
        retweet_count = ''
        retweeter = ''
        username = status.user
        relative_created_at = status.get_relative_created_at()

        # reply
        if status.is_reply:
            reply = u' \u2709'

        # retweet
        if status.is_retweet:
            retweeted = u" \u267b "
            # `username` is the author of the original tweet
            username = status.author
            # `retweeter` is the user who made the RT
            retweeter = status.user
            retweet_count = str(status.retweet_count)

        # create header
        header_template = ' ' + self.configuration.styles['header_template'] + ' '
        header = unicode(header_template).format(
            username=username,
            retweeted=retweeted,
            retweeter=retweeter,
            time=relative_created_at,
            reply=reply,
            retweet_count=retweet_count,
        )

        return encode(header)
开发者ID:apg,项目名称:turses,代码行数:38,代码来源:ui.py


示例18: delete_tweet

    def delete_tweet(self):
        status = self.timelines.get_active_status()
        if status is None:
            return
        if is_DM(status): 
            self.delete_dm()
            return

        author = get_authors_username(status)
        if author != self.user.screen_name:
            self.error_message(_('You can only delete your own tweets'))
            return

        # TODO: check if DM and delete DM if is

        status_deleted = partial(self.info_message, 
                                 _('Tweet deleted'))
        status_not_deleted = partial(self.error_message, 
                                     _('Failed to delete tweet'))

        self.api.destroy_status(status=status, 
                                on_error=status_not_deleted,
                                on_success=status_deleted)
开发者ID:gigigi,项目名称:turses,代码行数:23,代码来源:core.py


示例19: append_thread_timeline

    def append_thread_timeline(self):
        status = self.timelines.active_status

        timeline_fetched = partial(self.info_message,
                                   _('Thread fetched'))
        timeline_not_fetched = partial(self.error_message,
                                       _('Failed to fetch thread'))

        if is_DM(status):
            self.error_message(_('Doesn\'t look like a public conversation'))
            return

        participants = status.mentioned_usernames
        author = status.authors_username
        if author not in participants:
            participants.insert(0, author)

        name = _('thread: %s' % ', '.join(participants))
        self.append_timeline(name=name,
                             update_function=self.api.get_thread,
                             update_args=status,
                             on_error=timeline_not_fetched,
                             on_success=timeline_fetched)
开发者ID:tazjel,项目名称:turses,代码行数:23,代码来源:core.py


示例20: create_favorite

 def create_favorite(self, status):
     if is_DM(status) or status.is_favorite:
         raise Exception
     args = status,
     favorite_thread = Thread(target=self._api.create_favorite, args=args)
     favorite_thread.start()
开发者ID:gigigi,项目名称:turses,代码行数:6,代码来源:base.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Timeline类代码示例发布时间:2022-05-27
下一篇:
Python i18n.get函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap