formatter.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:deep-learning-nlp-rl-papers 作者: madrugado 项目源码 文件源码
def _twitting(self):
        url = shorten_url(self.buf[3] if self.buf[3][:8] != "**URL:**" else self.buf[3][9:])
        text = self.buf[4] if self.buf[4][:10] != "**Notes:**" else self.buf[4][11:]
        if len(text) > TWEET_LIMIT - len(url) - 1 - 3:  # one symbol for space, three symbols more
            premature_ending = "... "
            # FIXME: for some reason twitter counts for three symbols more, than len()
            while len(text) > TWEET_LIMIT - len(premature_ending) - len(url) - 3:
                text = str.rsplit(text, " ", 1)[0]

            twit = "\"" + text + premature_ending + url + "\""
        else:
            twit = "\"" + text + " " + url + "\""

        cmd.getstatusoutput(self.twitter_command + " " + twit)
        return twit
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号