:param plugin: A plugin to initialize. :returns: An initialized plugin with all default methods set.
(self, plugin)
| 16 | raise NotImplementedError("Subclasses must implement load") |
| 17 | |
| 18 | def _initialize_plugin(self, plugin): |
| 19 | """ |
| 20 | :param plugin: A plugin to initialize. |
| 21 | :returns: An initialized plugin with all default methods set. |
| 22 | """ |
| 23 | # Load default attributes |
| 24 | for attr in defaults.DEFAULTS + ['ORDER']: |
| 25 | if not hasattr(plugin, attr): |
| 26 | setattr(plugin, attr, getattr(defaults, attr)) |
| 27 | |
| 28 | # Name the plugin |
| 29 | if not hasattr(plugin, "plugin_name"): |
| 30 | if hasattr(plugin, "__name__"): |
| 31 | plugin.plugin_name = plugin.__name__ |
| 32 | elif hasattr(plugin, "__class__"): |
| 33 | plugin.plugin_name = plugin.__class__.__name__ |
| 34 | else: |
| 35 | plugin.plugin_name = "anonymous" |
| 36 | |
| 37 | |
| 38 | class ObjectsPluginLoader(BasePluginsLoader): |