Prevent plugin classes from being loaded twice

This commit is contained in:
Thomas Scholtes 2014-03-12 14:17:16 +01:00
parent 2dc0e4998d
commit e2718d792e

View file

@ -170,7 +170,7 @@ class BeetsPlugin(object):
return func
return helper
_classes = []
_classes = set()
def load_plugins(names=()):
"""Imports the modules for a sequence of plugin names. Each name
must be the name of a Python module under the "beetsplug" namespace
@ -191,8 +191,8 @@ def load_plugins(names=()):
else:
for obj in getattr(namespace, name).__dict__.values():
if isinstance(obj, type) and issubclass(obj, BeetsPlugin) \
and obj != BeetsPlugin:
_classes.append(obj)
and obj != BeetsPlugin and obj not in _classes:
_classes.add(obj)
except:
log.warn('** error loading plugin %s' % name)