Skip to content

Commit 647c35b

Browse files
author
deathaxe
authored
Replace AutomaticPackageReloader by Kiss Reloader (#224)
* Drop AutomaticPackageReloader requirements 1. Remove all existing modules from sys.modules[] cache to force them being reloaded in correct order. This strategy is battle proved by A File Icon, GitGutter and PackageDev. 2. Drop obsolete AutomaticPackageReloader dependencies. - Reloading ut.py always reloads all submodules. - Recreating UnitTesting33 each time is acceptable. * Add support for Kiss Reloader see: https://github.com/kaste/KissReloader
1 parent 2158887 commit 647c35b

File tree

2 files changed

+14
-23
lines changed

2 files changed

+14
-23
lines changed

.package_reloader.json

-4
This file was deleted.

ut.py

+14-19
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@
33
import sys
44
import shutil
55

6+
# Clear module cache to force reloading all modules of this package.
7+
8+
# kiss-reloader:
9+
prefix = __package__ + "." # don't clear the base package
10+
for module_name in [
11+
module_name
12+
for module_name in sys.modules
13+
if module_name.startswith(prefix) and module_name != __name__
14+
]:
15+
del sys.modules[module_name]
16+
prefix = None
617

718
if sys.version_info >= (3, 8):
819
coverage_prefix = "st4"
@@ -91,15 +102,6 @@ def plugin_loaded():
91102
except FileExistsError:
92103
pass
93104

94-
try:
95-
with open(os.path.join(UT33, ".package_reloader.json"), 'x') as f:
96-
f.write(json.dumps({
97-
"dependencies": ["UnitTesting"],
98-
"extra_modules": ["unittesting.helpers"]
99-
}))
100-
except FileExistsError:
101-
pass
102-
103105
try:
104106
with open(os.path.join(UT33, "dependencies.json"), 'x') as f:
105107
f.write(json.dumps({"*": {">3000": ["coverage"]}}))
@@ -120,13 +122,6 @@ def plugin_unloaded():
120122
if sys.version_info >= (3, 8):
121123
UT33 = os.path.join(sublime.packages_path(), "UnitTesting33")
122124
try:
123-
from AutomaticPackageReloader.package_reloader import reload_lock
124-
reloading = not reload_lock.acquire(blocking=False)
125-
except ImportError:
126-
reloading = False
127-
128-
if not reloading:
129-
try:
130-
shutil.rmtree(UT33)
131-
except Exception:
132-
pass
125+
shutil.rmtree(UT33)
126+
except Exception:
127+
pass

0 commit comments

Comments
 (0)