pysession.py 文件源码

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

项目:pysession 作者: FallibleInc 项目源码 文件源码
def before_exit():
    lines_of_code = process_history()

    if not PySession.save or len(lines_of_code) == 0:
        stdout.write(DO_NOTHING)
        return

    filename = expanduser(os.getenv('PYSESSION_FILENAME', 'session.py'))

    if PySession.save_locally:
        stdout.write(SAVING_FILE.format(filename=filename))
        PySession.save_to_file('\n'.join(lines_of_code), filename)
        stdout.write(SUCCESS)
        return

    try:
        stdout.write(SAVING_GIST.format(filename=filename))
        gist_response = PySession.save_to_gist('\n'.join(lines_of_code), filename)
        gist_url = gist_response['html_url']
        PySession.save_gist_url(gist_url)
        webbrowser.open_new_tab(gist_url)
        stdout.write(SUCCESS)
    except:
        stdout.write(FAILED)
        PySession.save_to_file('\n'.join(lines_of_code), filename)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号