forked from nfantone/zz-file-icons
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathA File Icon.py
100 lines (81 loc) · 2.87 KB
/
A File Icon.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import sublime
if int(sublime.version()) >= 3114:
from .common import settings
from .common.utils import cleaning
from .common.utils import logging
from .core import icons
from .core import aliases
from .common.utils.environment import AfiEnvironmentCommand
from .common.utils.changelog import AfiChangelogCommand
from .common.utils.reloader import AfiReloadListener
from .common.utils.reloader import AfiReloadCommand
from .common.utils.cleaning import AfiCleanCommand
from .common.utils.cleaning import AfiRevertCommand
from .core.aliases import AfiCheckAliasesCommand
from .core.themes import AfiPatchThemesCommand
from .common.settings import PACKAGE_NAME
NOPC_MSG = "It seems like you don't have Package Control installed"
def main():
"""
The main routine.
"""
settings.init()
icons.init()
def ensure_reload():
"""
Ensure all modules reload to initialize plugin successfully.
"""
start_upgrade_msg = "Do not close the Sublime Text. Upgrading {}".format(
PACKAGE_NAME
)
finish_upgrade_msg = "{} upgrade finished.".format(PACKAGE_NAME)
active_view = sublime.active_window().active_view()
active_view.set_status("afi_status", start_upgrade_msg)
def erase_status():
active_view.erase_status("afi_status")
def reload():
sublime.run_command("afi_reload")
active_view.set_status("afi_status", finish_upgrade_msg)
sublime.set_timeout(erase_status, 2000)
sublime.set_timeout_async(reload, 5000)
def plugin_loaded():
"""
A File Icon loaded.
Raises:
ImportError: If `Package Control` is not installed.
"""
was_upgraded = False
try:
from package_control import events
except ImportError as error:
logging.log(NOPC_MSG)
logging.dump(error)
else:
was_upgraded = events.post_upgrade(PACKAGE_NAME)
finally:
if was_upgraded:
ensure_reload()
else:
main()
def plugin_unloaded():
"""
A File Icon unloaded.
Raises:
ImportError: If `Package Control` is not installed.
"""
is_upgrading = False
was_removed = False
settings.clear_listener()
try:
from package_control import events
except ImportError as error:
logging.log(NOPC_MSG)
logging.dump(error)
else:
is_upgrading = events.pre_upgrade(PACKAGE_NAME)
was_removed = events.remove(PACKAGE_NAME)
finally:
if is_upgrading or was_removed:
cleaning.clean_all()
else:
raise ImportWarning("Doesn't support Sublime Text versions prior to 3114")