Skip to content

Commit f60e065

Browse files
committed
Cleanup main plugin module's globals
1 parent 1c1499c commit f60e065

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

plugin.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
if module_name.startswith(prefix) and module_name != __spec__.name
99
]:
1010
del sys.modules[module_name]
11-
12-
from .latextools.utils.logging import logger, init_logger, shutdown_logger
11+
del globals()["module_name"]
12+
del globals()["prefix"]
1313

1414
from .latextools.auto_label import (
1515
LatextoolsAutoInsertLabelCommand,
@@ -132,18 +132,21 @@
132132
)
133133

134134

135-
def _filter_func(name):
136-
return name.startswith(prefix) and name != __spec__.name
137-
138-
139135
def plugin_loaded():
136+
from .latextools.utils.logging import init_logger
140137
init_logger()
138+
139+
prefix = __spec__.parent + "."
140+
141+
def _filter_func(name):
142+
return name.startswith(prefix) and name != __spec__.name
143+
141144
for name in sorted(filter(_filter_func, sys.modules)):
142145
module = sys.modules[name]
143146
if hasattr(module, "latextools_plugin_loaded"):
144-
logger.debug("calling %s.latextools_plugin_loaded()", name)
145147
module.latextools_plugin_loaded()
146148

147149

148150
def plugin_unloaded():
151+
from .latextools.utils.logging import shutdown_logger
149152
shutdown_logger()

0 commit comments

Comments
 (0)