openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #00367
[Merge] lp:~trb143/openlp/audit into lp:openlp
Tim Bentley has proposed merging lp:~trb143/openlp/audit into lp:openlp.
Requested reviews:
openlp.org Core (openlp-core)
Clean up Plugin status code following last review
--
https://code.launchpad.net/~trb143/openlp/audit/+merge/12080
Your team openlp.org Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/lib/__init__.py'
--- openlp/core/lib/__init__.py 2009-09-14 22:10:08 +0000
+++ openlp/core/lib/__init__.py 2009-09-18 17:37:11 +0000
@@ -111,6 +111,7 @@
from eventreceiver import Receiver
from settingsmanager import SettingsManager
from pluginconfig import PluginConfig
+from plugin import PluginStatus
from plugin import Plugin
from pluginmanager import PluginManager
from settingstab import SettingsTab
=== modified file 'openlp/core/lib/plugin.py'
--- openlp/core/lib/plugin.py 2009-09-17 18:24:13 +0000
+++ openlp/core/lib/plugin.py 2009-09-18 17:37:11 +0000
@@ -27,6 +27,13 @@
from openlp.core.lib import PluginConfig, Receiver
+class PluginStatus(object):
+ """
+ Defines the status of the plugin
+ """
+ Active = 1
+ Inactive = 2
+
class Plugin(object):
"""
Base class for openlp plugins to inherit from.
@@ -122,6 +129,7 @@
self.icon = None
self.config = PluginConfig(self.name)
self.weight = 0
+ self.status = PluginStatus.Inactive
# Set up logging
self.log = logging.getLogger(self.name)
self.preview_controller = plugin_helpers[u'preview']
=== modified file 'openlp/core/lib/pluginmanager.py'
--- openlp/core/lib/pluginmanager.py 2009-09-17 18:24:13 +0000
+++ openlp/core/lib/pluginmanager.py 2009-09-18 17:37:11 +0000
@@ -26,7 +26,7 @@
import sys
import logging
-from openlp.core.lib import Plugin
+from openlp.core.lib import Plugin, PluginStatus
class PluginManager(object):
"""
@@ -92,23 +92,20 @@
log.error(u'Failed to import module %s on path %s for reason %s', modulename, path, e.args[0])
plugin_classes = Plugin.__subclasses__()
self.plugins = []
- self.plugin_list=[]
plugin_objects = []
for p in plugin_classes:
try:
plugin = p(self.plugin_helpers)
log.debug(u'Loaded plugin %s with helpers', unicode(p))
-
plugin_objects.append(plugin)
except TypeError:
log.error(u'loaded plugin %s has no helpers', unicode(p))
plugins_list = sorted(plugin_objects, self.order_by_weight)
for plugin in plugins_list:
- pList = {u'plugin': plugin, u'status': u'Inactive'}
if plugin.check_pre_conditions():
log.debug(u'Plugin %s active', unicode(plugin.name))
- pList[u'status'] = u'Active'
- self.plugins.append(pList)
+ plugin.status = PluginStatus.Active
+ self.plugins.append(plugin)
def order_by_weight(self, x, y):
"""
@@ -131,11 +128,11 @@
The Media Manager itself.
"""
for plugin in self.plugins:
- if plugin[u'status'] == u'Active':
- media_manager_item = plugin[u'plugin'].get_media_manager_item()
+ if plugin.status == PluginStatus.Active:
+ media_manager_item = plugin.get_media_manager_item()
if media_manager_item is not None:
- log.debug(u'Inserting media manager item from %s' % plugin[u'plugin'].name)
- mediatoolbox.addItem(media_manager_item, plugin[u'plugin'].icon, media_manager_item.title)
+ log.debug(u'Inserting media manager item from %s' % plugin.name)
+ mediatoolbox.addItem(media_manager_item, plugin.icon, media_manager_item.title)
def hook_settings_tabs(self, settingsform=None):
"""
@@ -147,12 +144,12 @@
Defaults to *None*. The settings form to add tabs to.
"""
for plugin in self.plugins:
- settings_tab = plugin[u'plugin'].get_settings_tab()
+ settings_tab = plugin.get_settings_tab()
if settings_tab is not None:
- log.debug(u'Inserting settings tab item from %s' % plugin[u'plugin'].name)
+ log.debug(u'Inserting settings tab item from %s' % plugin.name)
settingsform.addTab(settings_tab)
else:
- log.debug(u'No settings in %s' % plugin[u'plugin'].name)
+ log.debug(u'No settings in %s' % plugin.name)
def hook_import_menu(self, import_menu):
"""
@@ -163,8 +160,8 @@
The Import menu.
"""
for plugin in self.plugins:
- if plugin[u'status'] == u'Active':
- plugin[u'plugin'].add_import_menu_item(import_menu)
+ if plugin.status == PluginStatus.Active:
+ plugin.add_import_menu_item(import_menu)
def hook_export_menu(self, export_menu):
"""
@@ -175,8 +172,8 @@
The Export menu.
"""
for plugin in self.plugins:
- if plugin[u'status'] == u'Active':
- plugin[u'plugin'].add_export_menu_item(export_menu)
+ if plugin.status == PluginStatus.Active:
+ plugin.add_export_menu_item(export_menu)
def hook_tools_menu(self, tools_menu):
"""
@@ -187,8 +184,8 @@
The Tools menu.
"""
for plugin in self.plugins:
- if plugin[u'status'] == u'Active':
- plugin[u'plugin'].add_tools_menu_item(tools_menu)
+ if plugin.status == PluginStatus.Active:
+ plugin.add_tools_menu_item(tools_menu)
def initialise_plugins(self):
"""
@@ -196,8 +193,8 @@
initialise themselves.
"""
for plugin in self.plugins:
- if plugin[u'status'] == u'Active':
- plugin[u'plugin'].initialise()
+ if plugin.status == PluginStatus.Active:
+ plugin.initialise()
def finalise_plugins(self):
"""
@@ -205,5 +202,5 @@
clean themselves up
"""
for plugin in self.plugins:
- if plugin[u'status'] == u'Active':
- plugin[u'plugin'].finalise()
+ if plugin.status == PluginStatus.Active:
+ plugin.finalise()
=== modified file 'openlp/core/ui/plugindialoglistform.py'
--- openlp/core/ui/plugindialoglistform.py 2009-08-15 19:10:59 +0000
+++ openlp/core/ui/plugindialoglistform.py 2009-09-18 17:37:11 +0000
@@ -9,7 +9,7 @@
import logging
from PyQt4 import QtCore, QtGui
-from openlp.core.lib import translate
+from openlp.core.lib import translate, PluginStatus
class PluginForm(QtGui.QDialog):
global log
@@ -63,11 +63,14 @@
for plugin in self.parent.plugin_manager.plugins:
row = self.PluginViewList.rowCount()
self.PluginViewList.setRowCount(row + 1)
- item1 = QtGui.QTableWidgetItem(plugin[u'plugin'].name)
+ item1 = QtGui.QTableWidgetItem(plugin.name)
item1.setTextAlignment(QtCore.Qt.AlignVCenter)
- item2 = QtGui.QTableWidgetItem(plugin[u'plugin'].version)
+ item2 = QtGui.QTableWidgetItem(plugin.version)
item2.setTextAlignment(QtCore.Qt.AlignVCenter)
- item3 = QtGui.QTableWidgetItem(translate(u'PluginForm', plugin[u'status']))
+ if plugin.status == PluginStatus.Active:
+ item3 = QtGui.QTableWidgetItem(translate(u'PluginForm', u'Active'))
+ else:
+ item3 = QtGui.QTableWidgetItem(translate(u'PluginForm', u'Inactive'))
item3.setTextAlignment(QtCore.Qt.AlignVCenter)
self.PluginViewList.setItem(row, 0, item1)
self.PluginViewList.setItem(row, 1, item2)
Follow ups