forked from DisposaBoy/GoSublime
-
Notifications
You must be signed in to change notification settings - Fork 3
/
GoSublime.py
86 lines (72 loc) · 1.9 KB
/
GoSublime.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import os
import sublime
import sys
import traceback
st2 = (sys.version_info[0] == 2)
dist_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, dist_dir)
ANN = ''
VERSION = ''
MARGO_EXE = ''
fn = os.path.join(dist_dir, 'gosubl', 'about.py')
execErr = ''
try:
with open(fn) as f:
code = compile(f.read(), fn, 'exec')
exec(code)
except Exception:
execErr = "Error: failed to exec about.py: Exception: %s" % traceback.format_exc()
print("GoSublime: %s" % execErr)
def plugin_loaded():
from gosubl import about
from gosubl import sh
from gosubl import ev
from gosubl import gs
from gosubl import mg9
if VERSION != about.VERSION:
gs.show_output('GoSublime-main', '\n'.join([
'GoSublime has been updated.',
'New version: `%s`, current version: `%s`' % (VERSION, about.VERSION),
'Please restart Sublime Text to complete the update.',
execErr,
]))
return
if gs.attr('about.version'):
gs.show_output('GoSublime-main', '\n'.join([
'GoSublime appears to have been updated.',
'New ANNOUNCE: `%s`, current ANNOUNCE: `%s`' % (ANN, about.ANN),
'You may need to restart Sublime Text.',
]))
return
mods = [
('gs', gs),
('sh', sh),
('mg9', mg9),
]
gs.set_attr('about.version', VERSION)
gs.set_attr('about.ann', ANN)
for mod_name, mod in mods:
print('GoSublime %s: init mod(%s)' % (VERSION, mod_name))
try:
mod.gs_init({
'version': VERSION,
'ann': ANN,
'margo_exe': MARGO_EXE,
})
except TypeError:
# old versions didn't take an arg
mod.gs_init()
ev.init.post_add = lambda e, f: f()
ev.init()
def cb():
aso = gs.aso()
old_version = aso.get('version', '')
old_ann = aso.get('ann', '')
if about.VERSION > old_version or about.ANN > old_ann:
aso.set('version', about.VERSION)
aso.set('ann', about.ANN)
gs.save_aso()
gs.focus(gs.dist_path('CHANGELOG.md'))
sublime.set_timeout(cb, 0)
if st2:
sublime.set_timeout(plugin_loaded, 0)