forked from SublimeText/LaTeXTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete_temp_files.py
40 lines (31 loc) · 1.04 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
39
40
# ST2/ST3 compat
from __future__ import print_function
import sublime
if sublime.version() < '3000':
_ST3 = False
# we are on ST2 and Python 2.X
import getTeXRoot
else:
_ST3 = True
from . import getTeXRoot
import 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")