/
delete_temp_files.py
38 lines (29 loc) · 1.03 KB
/
delete_temp_files.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# ST2/ST3 compat
from __future__ import print_function
import sys
if sys.version_info[0] == 2:
# we are on ST2 and Python 2.X
import getTeXRoot
else:
import LaTeXTools.getTeXRoot
import sublime, sublime_plugin
import os
class Delete_temp_filesCommand(sublime_plugin.WindowCommand):
def run(self):
# Retrieve file and dirname.
view = self.window.active_view()
self.file_name = getTeXRoot.get_tex_root(view)
if not os.path.isfile(self.file_name):
sublime.error_message(self.file_name + ": file not found.")
return
self.tex_base, self.tex_ext = os.path.splitext(self.file_name)
# Delete the files.
temp_exts = ['.blg','.bbl','.aux','.log','.brf','.nlo','.out','.dvi','.ps',
'.lof','.toc','.fls','.fdb_latexmk','.pdfsync','.synctex.gz','.ind','.ilg','.idx']
for temp_ext in temp_exts:
file_name_to_del = self.tex_base + temp_ext
#print file_name_to_del
if os.path.exists(file_name_to_del):
#print ' deleted '
os.remove(file_name_to_del)
sublime.status_message("Deleted the temp files")