translate_to_legacy.py 文件源码

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

项目:translate_to_legacy 作者: almarklein 项目源码 文件源码
def fix_future(self, token):
        """ Fix print_function, absolute_import, with_statement.
        """

        status = getattr(self, '_future_status', 0)
        if status == 2:
            return  # Done

        if status == 0 and token.type == 'string':
            self._future_status = 1  # docstring
        elif token.type != 'comment':
            self._future_status = 2  # done
            i = max(0, token.find_backward('\n'))
            t = Token(token.total_text, '', i, i)
            t.fix = '\nfrom __future__ import %s\n' % (', '.join(self.FUTURES))
            return t
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号