-
Notifications
You must be signed in to change notification settings - Fork 5
/
BaseThread.py
48 lines (37 loc) · 1.15 KB
/
BaseThread.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
41
42
43
44
45
46
47
48
import sublime
import threading
import os
import sys
if sys.version_info < (3,):
from lib.printer import p
from lib.show_error import *
else:
from .lib.printer import p
from .lib.show_error import *
class BaseThread(threading.Thread):
"""
A thread to prevent the jump to dependency from freezing the UI
"""
def __init__(self, window, view):
self.window = window
self.view = view
threading.Thread.__init__(self)
def run(self):
pass
def open_file(self, filename):
"""
Opens the passed file or shows an error error message
if the file cannot be found
"""
p('Opening:', filename)
location_less = filename
location_colon_index = filename.find(':')
if location_colon_index != -1:
location_less = filename[:location_colon_index]
p('Location-less filename: ' + location_less)
if not filename or not os.path.isfile(location_less):
cant_find_file()
return
def open():
self.window.open_file(filename, sublime.ENCODED_POSITION)
sublime.set_timeout(open, 10)