Commits

Travis Shirk  committed 0e4dedc

Got rid of the weak PLUGINS member requirement.

  • Participants
  • Parent commits ae36a98

Comments (0)

Files changed (7)

File src/eyed3/plugins/__init__.py

 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #
 ################################################################################
-import os, sys, logging, exceptions
+import os, sys, logging, exceptions, types
 from collections import OrderedDict
 from eyed3 import core, utils
 from eyed3.utils.cli import printMsg, printError
                 mod = __import__(mod_name, globals=globals(),
                                  locals=locals())
 
-                for PluginClass in mod.PLUGINS:
-                    log.debug("loading plugin '%s' fron '%s%s%s'",
-                              mod, d, os.path.sep, f)
-                    # Setting the main name outside the loop to ensure there
-                    # is at least one, otherwise a KeyError is thrown.
-                    main_name = PluginClass.NAMES[0]
-                    _PLUGINS[main_name] = PluginClass
-                    for name in PluginClass.NAMES[1:]:
-                        # Add alternate names
-                        _PLUGINS[name] = PluginClass
+                for attr in [getattr(mod, a) for a in dir(mod)]:
+                    if (type(attr) == types.TypeType and
+                            issubclass(attr, Plugin)):
+                        # This is a eyed3.plugins.Plugin
+                        PluginClass = attr
+                        if (PluginClass not in _PLUGINS.values() and
+                                len(PluginClass.NAMES)):
+                            log.debug("loading plugin '%s' fron '%s%s%s'",
+                                      mod, d, os.path.sep, f)
+                            # Setting the main name outside the loop to ensure
+                            # there is at least one, otherwise a KeyError is
+                            # thrown.
+                            main_name = PluginClass.NAMES[0]
+                            _PLUGINS[main_name] = PluginClass
+                            for name in PluginClass.NAMES[1:]:
+                                # Add alternate names
+                                _PLUGINS[name] = PluginClass
 
-                    # If 'plugin' is found return it immediately
-                    if plugin and plugin in PluginClass.NAMES:
-                        return PluginClass
+                            # If 'plugin' is found return it immediately
+                            if plugin and plugin in PluginClass.NAMES:
+                                return PluginClass
 
         except exceptions.Exception as ex:
             import traceback

File src/eyed3/plugins/default.py

                     "variables: " + _getTemplateKeys(),
 }
 
-
-PLUGINS = [DefaultPlugin]

File src/eyed3/plugins/examples.py

             print(c1 + (u" " * (40 - len(c1))) + c2)
         print(u"")
 
-
-PLUGINS = [EchoPlugin, Mp3InfoPlugin, MimeTypesPlugin, GenreListPlugin]

File src/eyed3/plugins/lameinfo.py

         for v in values:
             printMsg(format % (v))
 
-PLUGINS = [LameInfoPlugin]
-

File src/eyed3/plugins/nfo.py

                      "http://eyeD3.nicfit.net/")
             printMsg("=" * 78)
 
-PLUGINS = [NfoPlugin]
-

File src/eyed3/plugins/statistics.py

         for v in ID3_VERSIONS:
             v_count = self.versions[v]
             v_percent = (float(v_count) / float(self.count)) * 100
-            print "\t%s : %d \t%.2f%%" % (id3.versionToString(v),
-                                          v_count, v_percent)
+            print("\t%s : %d \t%.2f%%" % (id3.versionToString(v),
+                                          v_count, v_percent))
 
 
-PLUGINS = [StatisticsPlugin]

File src/eyed3/plugins/xep_118.py

 
         return xml
 
-PLUGINS = [Xep118Plugin]
-