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)
#
#
#
评论列表
文章目录