Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp:~trb143/openlp/audit |
Merge into: | lp:openlp |
Diff against target: | None lines |
To merge this branch: | bzr merge lp:~trb143/openlp/audit |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Raoul Snyman | Approve | ||
Review via email: mp+12080@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Tim Bentley (trb143) wrote : | # |
Revision history for this message
Raoul Snyman (raoul-snyman) wrote : | # |
Looking good!
Just a thought:
from plugin import PluginStatus
from plugin import Plugin
You might as well have written:
from plugin import Plugin, PluginStatus
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'openlp/core/lib/__init__.py' | |||
2 | --- openlp/core/lib/__init__.py 2009-09-14 22:10:08 +0000 | |||
3 | +++ openlp/core/lib/__init__.py 2009-09-18 17:37:11 +0000 | |||
4 | @@ -111,6 +111,7 @@ | |||
5 | 111 | from eventreceiver import Receiver | 111 | from eventreceiver import Receiver |
6 | 112 | from settingsmanager import SettingsManager | 112 | from settingsmanager import SettingsManager |
7 | 113 | from pluginconfig import PluginConfig | 113 | from pluginconfig import PluginConfig |
8 | 114 | from plugin import PluginStatus | ||
9 | 114 | from plugin import Plugin | 115 | from plugin import Plugin |
10 | 115 | from pluginmanager import PluginManager | 116 | from pluginmanager import PluginManager |
11 | 116 | from settingstab import SettingsTab | 117 | from settingstab import SettingsTab |
12 | 117 | 118 | ||
13 | === modified file 'openlp/core/lib/plugin.py' | |||
14 | --- openlp/core/lib/plugin.py 2009-09-17 18:24:13 +0000 | |||
15 | +++ openlp/core/lib/plugin.py 2009-09-18 17:37:11 +0000 | |||
16 | @@ -27,6 +27,13 @@ | |||
17 | 27 | 27 | ||
18 | 28 | from openlp.core.lib import PluginConfig, Receiver | 28 | from openlp.core.lib import PluginConfig, Receiver |
19 | 29 | 29 | ||
20 | 30 | class PluginStatus(object): | ||
21 | 31 | """ | ||
22 | 32 | Defines the status of the plugin | ||
23 | 33 | """ | ||
24 | 34 | Active = 1 | ||
25 | 35 | Inactive = 2 | ||
26 | 36 | |||
27 | 30 | class Plugin(object): | 37 | class Plugin(object): |
28 | 31 | """ | 38 | """ |
29 | 32 | Base class for openlp plugins to inherit from. | 39 | Base class for openlp plugins to inherit from. |
30 | @@ -122,6 +129,7 @@ | |||
31 | 122 | self.icon = None | 129 | self.icon = None |
32 | 123 | self.config = PluginConfig(self.name) | 130 | self.config = PluginConfig(self.name) |
33 | 124 | self.weight = 0 | 131 | self.weight = 0 |
34 | 132 | self.status = PluginStatus.Inactive | ||
35 | 125 | # Set up logging | 133 | # Set up logging |
36 | 126 | self.log = logging.getLogger(self.name) | 134 | self.log = logging.getLogger(self.name) |
37 | 127 | self.preview_controller = plugin_helpers[u'preview'] | 135 | self.preview_controller = plugin_helpers[u'preview'] |
38 | 128 | 136 | ||
39 | === modified file 'openlp/core/lib/pluginmanager.py' | |||
40 | --- openlp/core/lib/pluginmanager.py 2009-09-17 18:24:13 +0000 | |||
41 | +++ openlp/core/lib/pluginmanager.py 2009-09-18 17:37:11 +0000 | |||
42 | @@ -26,7 +26,7 @@ | |||
43 | 26 | import sys | 26 | import sys |
44 | 27 | import logging | 27 | import logging |
45 | 28 | 28 | ||
47 | 29 | from openlp.core.lib import Plugin | 29 | from openlp.core.lib import Plugin, PluginStatus |
48 | 30 | 30 | ||
49 | 31 | class PluginManager(object): | 31 | class PluginManager(object): |
50 | 32 | """ | 32 | """ |
51 | @@ -92,23 +92,20 @@ | |||
52 | 92 | log.error(u'Failed to import module %s on path %s for reason %s', modulename, path, e.args[0]) | 92 | log.error(u'Failed to import module %s on path %s for reason %s', modulename, path, e.args[0]) |
53 | 93 | plugin_classes = Plugin.__subclasses__() | 93 | plugin_classes = Plugin.__subclasses__() |
54 | 94 | self.plugins = [] | 94 | self.plugins = [] |
55 | 95 | self.plugin_list=[] | ||
56 | 96 | plugin_objects = [] | 95 | plugin_objects = [] |
57 | 97 | for p in plugin_classes: | 96 | for p in plugin_classes: |
58 | 98 | try: | 97 | try: |
59 | 99 | plugin = p(self.plugin_helpers) | 98 | plugin = p(self.plugin_helpers) |
60 | 100 | log.debug(u'Loaded plugin %s with helpers', unicode(p)) | 99 | log.debug(u'Loaded plugin %s with helpers', unicode(p)) |
61 | 101 | |||
62 | 102 | plugin_objects.append(plugin) | 100 | plugin_objects.append(plugin) |
63 | 103 | except TypeError: | 101 | except TypeError: |
64 | 104 | log.error(u'loaded plugin %s has no helpers', unicode(p)) | 102 | log.error(u'loaded plugin %s has no helpers', unicode(p)) |
65 | 105 | plugins_list = sorted(plugin_objects, self.order_by_weight) | 103 | plugins_list = sorted(plugin_objects, self.order_by_weight) |
66 | 106 | for plugin in plugins_list: | 104 | for plugin in plugins_list: |
67 | 107 | pList = {u'plugin': plugin, u'status': u'Inactive'} | ||
68 | 108 | if plugin.check_pre_conditions(): | 105 | if plugin.check_pre_conditions(): |
69 | 109 | log.debug(u'Plugin %s active', unicode(plugin.name)) | 106 | log.debug(u'Plugin %s active', unicode(plugin.name)) |
72 | 110 | pList[u'status'] = u'Active' | 107 | plugin.status = PluginStatus.Active |
73 | 111 | self.plugins.append(pList) | 108 | self.plugins.append(plugin) |
74 | 112 | 109 | ||
75 | 113 | def order_by_weight(self, x, y): | 110 | def order_by_weight(self, x, y): |
76 | 114 | """ | 111 | """ |
77 | @@ -131,11 +128,11 @@ | |||
78 | 131 | The Media Manager itself. | 128 | The Media Manager itself. |
79 | 132 | """ | 129 | """ |
80 | 133 | for plugin in self.plugins: | 130 | for plugin in self.plugins: |
83 | 134 | if plugin[u'status'] == u'Active': | 131 | if plugin.status == PluginStatus.Active: |
84 | 135 | media_manager_item = plugin[u'plugin'].get_media_manager_item() | 132 | media_manager_item = plugin.get_media_manager_item() |
85 | 136 | if media_manager_item is not None: | 133 | if media_manager_item is not None: |
88 | 137 | log.debug(u'Inserting media manager item from %s' % plugin[u'plugin'].name) | 134 | log.debug(u'Inserting media manager item from %s' % plugin.name) |
89 | 138 | mediatoolbox.addItem(media_manager_item, plugin[u'plugin'].icon, media_manager_item.title) | 135 | mediatoolbox.addItem(media_manager_item, plugin.icon, media_manager_item.title) |
90 | 139 | 136 | ||
91 | 140 | def hook_settings_tabs(self, settingsform=None): | 137 | def hook_settings_tabs(self, settingsform=None): |
92 | 141 | """ | 138 | """ |
93 | @@ -147,12 +144,12 @@ | |||
94 | 147 | Defaults to *None*. The settings form to add tabs to. | 144 | Defaults to *None*. The settings form to add tabs to. |
95 | 148 | """ | 145 | """ |
96 | 149 | for plugin in self.plugins: | 146 | for plugin in self.plugins: |
98 | 150 | settings_tab = plugin[u'plugin'].get_settings_tab() | 147 | settings_tab = plugin.get_settings_tab() |
99 | 151 | if settings_tab is not None: | 148 | if settings_tab is not None: |
101 | 152 | log.debug(u'Inserting settings tab item from %s' % plugin[u'plugin'].name) | 149 | log.debug(u'Inserting settings tab item from %s' % plugin.name) |
102 | 153 | settingsform.addTab(settings_tab) | 150 | settingsform.addTab(settings_tab) |
103 | 154 | else: | 151 | else: |
105 | 155 | log.debug(u'No settings in %s' % plugin[u'plugin'].name) | 152 | log.debug(u'No settings in %s' % plugin.name) |
106 | 156 | 153 | ||
107 | 157 | def hook_import_menu(self, import_menu): | 154 | def hook_import_menu(self, import_menu): |
108 | 158 | """ | 155 | """ |
109 | @@ -163,8 +160,8 @@ | |||
110 | 163 | The Import menu. | 160 | The Import menu. |
111 | 164 | """ | 161 | """ |
112 | 165 | for plugin in self.plugins: | 162 | for plugin in self.plugins: |
115 | 166 | if plugin[u'status'] == u'Active': | 163 | if plugin.status == PluginStatus.Active: |
116 | 167 | plugin[u'plugin'].add_import_menu_item(import_menu) | 164 | plugin.add_import_menu_item(import_menu) |
117 | 168 | 165 | ||
118 | 169 | def hook_export_menu(self, export_menu): | 166 | def hook_export_menu(self, export_menu): |
119 | 170 | """ | 167 | """ |
120 | @@ -175,8 +172,8 @@ | |||
121 | 175 | The Export menu. | 172 | The Export menu. |
122 | 176 | """ | 173 | """ |
123 | 177 | for plugin in self.plugins: | 174 | for plugin in self.plugins: |
126 | 178 | if plugin[u'status'] == u'Active': | 175 | if plugin.status == PluginStatus.Active: |
127 | 179 | plugin[u'plugin'].add_export_menu_item(export_menu) | 176 | plugin.add_export_menu_item(export_menu) |
128 | 180 | 177 | ||
129 | 181 | def hook_tools_menu(self, tools_menu): | 178 | def hook_tools_menu(self, tools_menu): |
130 | 182 | """ | 179 | """ |
131 | @@ -187,8 +184,8 @@ | |||
132 | 187 | The Tools menu. | 184 | The Tools menu. |
133 | 188 | """ | 185 | """ |
134 | 189 | for plugin in self.plugins: | 186 | for plugin in self.plugins: |
137 | 190 | if plugin[u'status'] == u'Active': | 187 | if plugin.status == PluginStatus.Active: |
138 | 191 | plugin[u'plugin'].add_tools_menu_item(tools_menu) | 188 | plugin.add_tools_menu_item(tools_menu) |
139 | 192 | 189 | ||
140 | 193 | def initialise_plugins(self): | 190 | def initialise_plugins(self): |
141 | 194 | """ | 191 | """ |
142 | @@ -196,8 +193,8 @@ | |||
143 | 196 | initialise themselves. | 193 | initialise themselves. |
144 | 197 | """ | 194 | """ |
145 | 198 | for plugin in self.plugins: | 195 | for plugin in self.plugins: |
148 | 199 | if plugin[u'status'] == u'Active': | 196 | if plugin.status == PluginStatus.Active: |
149 | 200 | plugin[u'plugin'].initialise() | 197 | plugin.initialise() |
150 | 201 | 198 | ||
151 | 202 | def finalise_plugins(self): | 199 | def finalise_plugins(self): |
152 | 203 | """ | 200 | """ |
153 | @@ -205,5 +202,5 @@ | |||
154 | 205 | clean themselves up | 202 | clean themselves up |
155 | 206 | """ | 203 | """ |
156 | 207 | for plugin in self.plugins: | 204 | for plugin in self.plugins: |
159 | 208 | if plugin[u'status'] == u'Active': | 205 | if plugin.status == PluginStatus.Active: |
160 | 209 | plugin[u'plugin'].finalise() | 206 | plugin.finalise() |
161 | 210 | 207 | ||
162 | === modified file 'openlp/core/ui/plugindialoglistform.py' | |||
163 | --- openlp/core/ui/plugindialoglistform.py 2009-08-15 19:10:59 +0000 | |||
164 | +++ openlp/core/ui/plugindialoglistform.py 2009-09-18 17:37:11 +0000 | |||
165 | @@ -9,7 +9,7 @@ | |||
166 | 9 | 9 | ||
167 | 10 | import logging | 10 | import logging |
168 | 11 | from PyQt4 import QtCore, QtGui | 11 | from PyQt4 import QtCore, QtGui |
170 | 12 | from openlp.core.lib import translate | 12 | from openlp.core.lib import translate, PluginStatus |
171 | 13 | 13 | ||
172 | 14 | class PluginForm(QtGui.QDialog): | 14 | class PluginForm(QtGui.QDialog): |
173 | 15 | global log | 15 | global log |
174 | @@ -63,11 +63,14 @@ | |||
175 | 63 | for plugin in self.parent.plugin_manager.plugins: | 63 | for plugin in self.parent.plugin_manager.plugins: |
176 | 64 | row = self.PluginViewList.rowCount() | 64 | row = self.PluginViewList.rowCount() |
177 | 65 | self.PluginViewList.setRowCount(row + 1) | 65 | self.PluginViewList.setRowCount(row + 1) |
179 | 66 | item1 = QtGui.QTableWidgetItem(plugin[u'plugin'].name) | 66 | item1 = QtGui.QTableWidgetItem(plugin.name) |
180 | 67 | item1.setTextAlignment(QtCore.Qt.AlignVCenter) | 67 | item1.setTextAlignment(QtCore.Qt.AlignVCenter) |
182 | 68 | item2 = QtGui.QTableWidgetItem(plugin[u'plugin'].version) | 68 | item2 = QtGui.QTableWidgetItem(plugin.version) |
183 | 69 | item2.setTextAlignment(QtCore.Qt.AlignVCenter) | 69 | item2.setTextAlignment(QtCore.Qt.AlignVCenter) |
185 | 70 | item3 = QtGui.QTableWidgetItem(translate(u'PluginForm', plugin[u'status'])) | 70 | if plugin.status == PluginStatus.Active: |
186 | 71 | item3 = QtGui.QTableWidgetItem(translate(u'PluginForm', u'Active')) | ||
187 | 72 | else: | ||
188 | 73 | item3 = QtGui.QTableWidgetItem(translate(u'PluginForm', u'Inactive')) | ||
189 | 71 | item3.setTextAlignment(QtCore.Qt.AlignVCenter) | 74 | item3.setTextAlignment(QtCore.Qt.AlignVCenter) |
190 | 72 | self.PluginViewList.setItem(row, 0, item1) | 75 | self.PluginViewList.setItem(row, 0, item1) |
191 | 73 | self.PluginViewList.setItem(row, 1, item2) | 76 | self.PluginViewList.setItem(row, 1, item2) |
Clean up Plugin status code following last review