diff --git a/documentation/source/core/lib.rst b/documentation/source/core/lib.rst index 12c7b702c..43ca90b3b 100644 --- a/documentation/source/core/lib.rst +++ b/documentation/source/core/lib.rst @@ -60,18 +60,6 @@ .. autoclass:: openlp.core.lib.settingstab.SettingsTab :members: -:mod:`SongXMLBuilder` ---------------------- - -.. autoclass:: openlp.core.lib.songxmlhandler.SongXMLBuilder - :members: - -:mod:`SongXMLParser` --------------------- - -.. autoclass:: openlp.core.lib.songxmlhandler.SongXMLParser - :members: - :mod:`ThemeXML` --------------- @@ -83,10 +71,3 @@ .. autoclass:: openlp.core.lib.toolbar.OpenLPToolbar :members: - -:mod:`XmlRootClass` -------------------- - -.. autoclass:: openlp.core.lib.xmlrootclass.XmlRootClass - :members: - diff --git a/openlp/core/lib/__init__.py b/openlp/core/lib/__init__.py index d6f805c98..4718e289e 100644 --- a/openlp/core/lib/__init__.py +++ b/openlp/core/lib/__init__.py @@ -202,28 +202,17 @@ def check_item_selected(list_widget, message): return False return True - -class ThemeLevel(object): - """ - Provides an enumeration for the level a theme applies to - """ - Global = 1 - Service = 2 - Song = 3 - from eventreceiver import Receiver from settingsmanager import SettingsManager from plugin import PluginStatus, Plugin from pluginmanager import PluginManager from settingstab import SettingsTab -from xmlrootclass import XmlRootClass from serviceitem import ServiceItem from serviceitem import ServiceItemType from serviceitem import ItemCapabilities from toolbar import OpenLPToolbar from dockwidget import OpenLPDockWidget -from songxmlhandler import SongXMLBuilder, SongXMLParser -from themexmlhandler import ThemeXML +from theme import ThemeLevel, ThemeXML from renderer import Renderer from rendermanager import RenderManager from mediamanageritem import MediaManagerItem diff --git a/openlp/core/lib/db.py b/openlp/core/lib/db.py index f20f3ab38..8acc79541 100644 --- a/openlp/core/lib/db.py +++ b/openlp/core/lib/db.py @@ -189,7 +189,7 @@ class Manager(object): Any parameters to order the returned objects by. Defaults to None. """ query = self.session.query(object_class) - if order_by_ref: + if order_by_ref is not None: return query.order_by(order_by_ref).all() return query.all() @@ -208,7 +208,7 @@ class Manager(object): Any parameters to order the returned objects by. Defaults to None. """ query = self.session.query(object_class).filter(filter_clause) - if order_by_ref: + if order_by_ref is not None: return query.order_by(order_by_ref).all() return query.all() diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index c8397f39a..18d4bdc9e 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -67,23 +67,23 @@ class Plugin(QtCore.QObject): **Hook Functions** - ``check_pre_conditions()`` + ``checkPreConditions()`` Provides the Plugin with a handle to check if it can be loaded. - ``get_media_manager_item()`` + ``getMediaManagerItem()`` Returns an instance of MediaManagerItem to be used in the Media Manager. - ``add_import_menu_item(import_menu)`` + ``addImportMenuItem(import_menu)`` Add an item to the Import menu. - ``add_export_menu_item(export_menu)`` + ``addExportMenuItem(export_menu)`` Add an item to the Export menu. - ``get_settings_tab()`` + ``getSettingsTab()`` Returns an instance of SettingsTabItem to be used in the Settings dialog. - ``add_to_menu(menubar)`` + ``addToMenu(menubar)`` A method to add a menu item to anywhere in the menu, given the menu bar. ``handle_event(event)`` @@ -134,9 +134,9 @@ class Plugin(QtCore.QObject): self.pluginManager = plugin_helpers[u'pluginmanager'] QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'%s_add_service_item' % self.name), - self.process_add_service_event) + self.processAddServiceEvent) - def check_pre_conditions(self): + def checkPreConditions(self): """ Provides the Plugin with a handle to check if it can be loaded. Failing Preconditions does not stop a settings Tab being created @@ -145,7 +145,7 @@ class Plugin(QtCore.QObject): """ return True - def set_status(self): + def setStatus(self): """ Sets the status of the plugin """ @@ -153,7 +153,7 @@ class Plugin(QtCore.QObject): self.settingsSection + u'/status', QtCore.QVariant(PluginStatus.Inactive)).toInt()[0] - def toggle_status(self, new_status): + def toggleStatus(self, new_status): """ Changes the status of the plugin and remembers it """ @@ -161,7 +161,7 @@ class Plugin(QtCore.QObject): QtCore.QSettings().setValue( self.settingsSection + u'/status', QtCore.QVariant(self.status)) - def is_active(self): + def isActive(self): """ Indicates if the plugin is active @@ -169,14 +169,14 @@ class Plugin(QtCore.QObject): """ return self.status == PluginStatus.Active - def get_media_manager_item(self): + def getMediaManagerItem(self): """ Construct a MediaManagerItem object with all the buttons and things you need, and return it for integration into openlp.org. """ pass - def add_import_menu_item(self, importMenu): + def addImportMenuItem(self, importMenu): """ Create a menu item and add it to the "Import" menu. @@ -185,7 +185,7 @@ class Plugin(QtCore.QObject): """ pass - def add_export_menu_item(self, exportMenu): + def addExportMenuItem(self, exportMenu): """ Create a menu item and add it to the "Export" menu. @@ -194,7 +194,7 @@ class Plugin(QtCore.QObject): """ pass - def add_tools_menu_item(self, toolsMenu): + def addToolsMenuItem(self, toolsMenu): """ Create a menu item and add it to the "Tools" menu. @@ -203,13 +203,13 @@ class Plugin(QtCore.QObject): """ pass - def get_settings_tab(self): + def getSettingsTab(self): """ Create a tab for the settings window. """ pass - def add_to_menu(self, menubar): + def addToMenu(self, menubar): """ Add menu items to the menu, given the menubar. @@ -218,11 +218,11 @@ class Plugin(QtCore.QObject): """ pass - def process_add_service_event(self, replace=False): + def processAddServiceEvent(self, replace=False): """ Generic Drag and drop handler triggered from service_manager. """ - log.debug(u'process_add_service_event event called for plugin %s' % + log.debug(u'processAddServiceEvent event called for plugin %s' % self.name) if replace: self.mediaItem.onAddEditClick() @@ -243,15 +243,15 @@ class Plugin(QtCore.QObject): """ if self.mediaItem: self.mediaItem.initialise() - self.insert_toolbox_item() + self.insertToolboxItem() def finalise(self): """ Called by the plugin Manager to cleanup things. """ - self.remove_toolbox_item() + self.removeToolboxItem() - def remove_toolbox_item(self): + def removeToolboxItem(self): """ Called by the plugin to remove toolbar """ @@ -260,7 +260,7 @@ class Plugin(QtCore.QObject): if self.settings_tab: self.settingsForm.removeTab(self.name) - def insert_toolbox_item(self): + def insertToolboxItem(self): """ Called by plugin to replace toolbar """ @@ -269,8 +269,8 @@ class Plugin(QtCore.QObject): if self.settings_tab: self.settingsForm.insertTab(self.settings_tab, self.weight) - def can_delete_theme(self, theme): + def canDeleteTheme(self, theme): """ Called to ask the plugin if a theme can be deleted """ - return True + return True \ No newline at end of file diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index c9c578603..20c8bc97b 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -109,9 +109,9 @@ class PluginManager(object): log.exception(u'loaded plugin %s has no helpers', unicode(p)) plugins_list = sorted(plugin_objects, self.order_by_weight) for plugin in plugins_list: - if plugin.check_pre_conditions(): + if plugin.checkPreConditions(): log.debug(u'Plugin %s active', unicode(plugin.name)) - plugin.set_status() + plugin.setStatus() else: plugin.status = PluginStatus.Disabled self.plugins.append(plugin) @@ -138,7 +138,7 @@ class PluginManager(object): """ for plugin in self.plugins: if plugin.status is not PluginStatus.Disabled: - plugin.mediaItem = plugin.get_media_manager_item() + plugin.mediaItem = plugin.getMediaManagerItem() def hook_settings_tabs(self, settingsform=None): """ @@ -151,7 +151,7 @@ class PluginManager(object): """ for plugin in self.plugins: if plugin.status is not PluginStatus.Disabled: - plugin.settings_tab = plugin.get_settings_tab() + plugin.settings_tab = plugin.getSettingsTab() if plugin.settings_tab: log.debug(u'Inserting settings tab item from %s' % plugin.name) @@ -169,7 +169,7 @@ class PluginManager(object): """ for plugin in self.plugins: if plugin.status is not PluginStatus.Disabled: - plugin.add_import_menu_item(import_menu) + plugin.addImportMenuItem(import_menu) def hook_export_menu(self, export_menu): """ @@ -181,7 +181,7 @@ class PluginManager(object): """ for plugin in self.plugins: if plugin.status is not PluginStatus.Disabled: - plugin.add_export_menu_item(export_menu) + plugin.addExportMenuItem(export_menu) def hook_tools_menu(self, tools_menu): """ @@ -193,7 +193,7 @@ class PluginManager(object): """ for plugin in self.plugins: if plugin.status is not PluginStatus.Disabled: - plugin.add_tools_menu_item(tools_menu) + plugin.addToolsMenuItem(tools_menu) def initialise_plugins(self): """ @@ -202,12 +202,12 @@ class PluginManager(object): """ for plugin in self.plugins: log.info(u'initialising plugins %s in a %s state' - % (plugin.name, plugin.is_active())) - if plugin.is_active(): + % (plugin.name, plugin.isActive())) + if plugin.isActive(): plugin.initialise() log.info(u'Initialisation Complete for %s ' % plugin.name) - if not plugin.is_active(): - plugin.remove_toolbox_item() + if not plugin.isActive(): + plugin.removeToolboxItem() def finalise_plugins(self): """ @@ -216,7 +216,6 @@ class PluginManager(object): """ log.info(u'finalising plugins') for plugin in self.plugins: - if plugin.is_active(): + if plugin.isActive(): plugin.finalise() - log.info(u'Finalisation Complete for %s ' % plugin.name) - + log.info(u'Finalisation Complete for %s ' % plugin.name) \ No newline at end of file diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index c7f96528c..04c854afa 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -29,6 +29,7 @@ format it for the output display. import logging from PyQt4 import QtGui, QtCore + from openlp.core.lib import resize_image log = logging.getLogger(__name__) diff --git a/openlp/core/lib/rendermanager.py b/openlp/core/lib/rendermanager.py index 431f74564..b3c46a5eb 100644 --- a/openlp/core/lib/rendermanager.py +++ b/openlp/core/lib/rendermanager.py @@ -27,8 +27,7 @@ import logging from PyQt4 import QtCore -from renderer import Renderer -from openlp.core.lib import ThemeLevel +from openlp.core.lib import Renderer, ThemeLevel log = logging.getLogger(__name__) diff --git a/openlp/core/lib/themexmlhandler.py b/openlp/core/lib/theme.py similarity index 99% rename from openlp/core/lib/themexmlhandler.py rename to openlp/core/lib/theme.py index a5b4137ce..3f7b613d4 100644 --- a/openlp/core/lib/themexmlhandler.py +++ b/openlp/core/lib/theme.py @@ -79,6 +79,14 @@ BLANK_THEME_XML = \ ''' +class ThemeLevel(object): + """ + Provides an enumeration for the level a theme applies to + """ + Global = 1 + Service = 2 + Song = 3 + class ThemeXML(object): """ A class to encapsulate the Theme XML. @@ -313,7 +321,6 @@ class ThemeXML(object): element.appendChild(value) background.appendChild(element) - def child_element(self, element, tag, value): """ Generic child element creator. @@ -351,14 +358,8 @@ class ThemeXML(object): ``xml`` The XML string to parse. """ - self.base_parse_xml() - self.parse_xml(xml) - - def base_parse_xml(self): - """ - Pull in the blank theme XML as a starting point. - """ self.parse_xml(BLANK_THEME_XML) + self.parse_xml(xml) def parse_xml(self, xml): """ @@ -414,4 +415,3 @@ class ThemeXML(object): if key[0:1] != u'_': theme_strings.append(u'%30s: %s' % (key, getattr(self, key))) return u'\n'.join(theme_strings) - diff --git a/openlp/core/lib/xmlrootclass.py b/openlp/core/lib/xmlrootclass.py deleted file mode 100644 index 1ea1d41a2..000000000 --- a/openlp/core/lib/xmlrootclass.py +++ /dev/null @@ -1,104 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2010 Raoul Snyman # -# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # -# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin # -# Thompson, Jon Tibble, Carsten Tinggaard # -# --------------------------------------------------------------------------- # -# This program is free software; you can redistribute it and/or modify it # -# under the terms of the GNU General Public License as published by the Free # -# Software Foundation; version 2 of the License. # -# # -# This program is distributed in the hope that it will be useful, but WITHOUT # -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # -# more details. # -# # -# You should have received a copy of the GNU General Public License along # -# with this program; if not, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -############################################################################### - -import os -import sys - -from xml.etree.ElementTree import ElementTree, XML - -sys.path.append(os.path.abspath(os.path.join(u'.', u'..', u'..'))) - -class XmlRootClass(object): - """ - Root class for themes, songs etc - - This class provides interface for parsing xml files into object attributes. - - If you overload this class and provide a function called `post_tag_hook`, - it will be called thusly for each `tag, value` pair:: - - (element.tag, val) = self.post_tag_hook(element.tag, val) - """ - def _set_from_xml(self, xml, root_tag): - """ - Set song properties from given xml content. - - ``xml`` - Formatted xml tags and values. - ``root_tag`` - The root tag of the xml. - """ - root = ElementTree(element=XML(xml)) - xml_iter = root.getiterator() - for element in xml_iter: - if element.tag != root_tag: - text = element.text - if text is None: - val = text - elif isinstance(text, basestring): - # Strings need special handling to sort the colours out - if text[0] == u'$': - # This might be a hex number, let's try to convert it. - try: - val = int(text[1:], 16) - except ValueError: - pass - else: - # Let's just see if it's a integer. - try: - val = int(text) - except ValueError: - # Ok, it seems to be a string. - val = text - if hasattr(self, u'post_tag_hook'): - (element.tag, val) = \ - self.post_tag_hook(element.tag, val) - setattr(self, element.tag, val) - - def __str__(self): - """ - Return string with all public attributes - - The string is formatted with one attribute per line - If the string is split on newline then the length of the - list is equal to the number of attributes - """ - attributes = [] - for attrib in dir(self): - if not attrib.startswith(u'_'): - attributes.append( - u'%30s : %s' % (attrib, getattr(self, attrib))) - return u'\n'.join(attributes) - - def _get_as_string(self): - """ - Return one string with all public attributes - """ - result = u'' - for attrib in dir(self): - if not attrib.startswith(u'_'): - result += u'_%s_' % getattr(self, attrib) - return result - diff --git a/openlp/core/theme/theme.py b/openlp/core/theme/theme.py index 6cddbcb45..82e7ac2cc 100644 --- a/openlp/core/theme/theme.py +++ b/openlp/core/theme/theme.py @@ -222,4 +222,3 @@ class Theme(object): if key[0:1] != u'_': theme_strings.append(u'%30s : %s' % (key, getattr(self, key))) return u'\n'.join(theme_strings) - diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index aaef47612..b770a9e05 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -35,27 +35,27 @@ from openlp.core.ui import HideMode log = logging.getLogger(__name__) -HTMLIMAGE = """ - - - - """ - #http://www.steveheffernan.com/html5-video-player/demo-video-player.html HTMLVIDEO = u""" - - \" - - + + + +