File tree Expand file tree Collapse file tree 1 file changed +4
-10
lines changed Expand file tree Collapse file tree 1 file changed +4
-10
lines changed Original file line number Diff line number Diff line change 22
22
import traceback
23
23
from collections import defaultdict
24
24
from functools import wraps
25
+ from importlib import import_module
25
26
from typing import TYPE_CHECKING
26
27
27
28
import mediafile
@@ -269,10 +270,8 @@ def load_plugins(names=()):
269
270
BeetsPlugin subclasses desired.
270
271
"""
271
272
for name in names :
272
- modname = f"{ PLUGIN_NAMESPACE } .{ name } "
273
-
274
273
try :
275
- namespace = __import__ ( modname , None , None )
274
+ mod = import_module ( name , package = PLUGIN_NAMESPACE )
276
275
except ModuleNotFoundError :
277
276
log .warning ("** plugin {} not found" , name )
278
277
continue
@@ -284,13 +283,8 @@ def load_plugins(names=()):
284
283
)
285
284
continue
286
285
287
- for obj in getattr (namespace , name ).__dict__ .values ():
288
- if (
289
- isinstance (obj , type )
290
- and issubclass (obj , BeetsPlugin )
291
- and obj != BeetsPlugin
292
- and obj not in _classes
293
- ):
286
+ for _name , obj in inspect .getmembers (mod , inspect .isclass ):
287
+ if issubclass (obj , BeetsPlugin ) and obj != BeetsPlugin :
294
288
_classes .add (obj )
295
289
296
290
You can’t perform that action at this time.
0 commit comments