Skip to content

Commit f59f9c7

Browse files
authored
Drop reloader (#189)
Fixes #169 Reloading modules is performed by clearing `sys.modules` cache before (re-)importing. That common strategy works well for various packages for several years.
1 parent 24adc56 commit f59f9c7

File tree

2 files changed

+11
-71
lines changed

2 files changed

+11
-71
lines changed

AdvancedNewFile.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
import sublime
22
import sys
33

4-
VERSION = int(sublime.version())
5-
6-
reloader = "advanced_new_file.reloader"
7-
8-
if VERSION > 3000:
9-
reloader = 'AdvancedNewFile.' + reloader
10-
from imp import reload
11-
4+
# Clear module cache to force reloading all modules of this package.
125

13-
# Make sure all dependencies are reloaded on upgrade
14-
if reloader in sys.modules:
15-
reload(sys.modules[reloader])
6+
# kiss-reloader:
7+
prefix = __package__ + "." # don't clear the base package
8+
for module_name in [
9+
module_name
10+
for module_name in sys.modules
11+
if module_name.startswith(prefix) and module_name != __name__
12+
]:
13+
del sys.modules[module_name]
14+
prefix = None
1615

16+
VERSION = int(sublime.version())
1717
if VERSION > 3000:
18-
from .advanced_new_file import reloader
1918
from .advanced_new_file.commands import *
2019
else:
21-
from advanced_new_file import reloader
2220
from advanced_new_file.commands import *

advanced_new_file/reloader.py

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)