transformers.py 文件源码

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

项目:async2rewrite 作者: TheTrain2000 项目源码 文件源码
def stateful_send_file(self, call):
        if isinstance(call.func, ast.Attribute):
            if call.func.attr == 'send_file':
                if self.interactive and not prompt_change(
                        'A possible change was found to change send_file to send.'
                ):
                    return call
                dest = call.args[0]
                send_as = call.args[1]
                content = None
                filename = None
                for kw in list(call.keywords):
                    if kw.arg == 'filename':
                        filename = kw
                    if kw.arg == 'content':
                        content = kw
                if filename is None:
                    filename = ast.keyword(arg='filename', value=send_as)
                call.func.value = dest
                call.func.attr = 'send'
                call.args = []
                if content:
                    call.args.append(content.value)
                call.keywords = []
                file_kw = ast.keyword()
                file_kw.arg = 'file'
                discord_file_call = ast.Call()
                discord_file_call.func = ast.Attribute(value=ast.Name(id='discord', ctx=ast.Load()), attr='File',
                                                       ctx=ast.Load())
                discord_file_call.args = [send_as, filename.value]
                discord_file_call.keywords = []
                file_kw.value = discord_file_call
                call.keywords.append(file_kw)
                stats_counter['call_changes'] += 1

        return call
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号