compile.py 文件源码

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

项目:Real-Time-LaTeX 作者: stevenengler 项目源码 文件源码
def fix_synctex(self, project_directory, compiled_path_relative_to_project_path, filename):
        old_synctex = project_directory+'/'+compiled_path_relative_to_project_path+'/'+filename+'.synctex'
        new_synctex = project_directory+'/'+compiled_path_relative_to_project_path+'/'+filename+'.synctex.new'
        #
        if os.path.isfile(old_synctex):
            f1 = open(old_synctex, 'r')
            f2 = open(new_synctex, 'w')
            #
            project_path_relative_to_compiled_path = os.path.relpath(project_directory, project_directory+'/'+compiled_path_relative_to_project_path)
            for line in f1:
                f2.write(line.replace(os.path.abspath(project_directory), project_path_relative_to_compiled_path))
            #
            f1.close()
            f2.close()
            os.remove(old_synctex)
            #os.rename(new_synctex, old_synctex)
            #
            with open(new_synctex, 'rb') as f_in, gzip.open(old_synctex+'.gz', 'wb') as f_out:
                shutil.copyfileobj(f_in, f_out)
            #
            os.remove(new_synctex)
        #
    #
#
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号