diff --git a/openlp/core/common/__init__.py b/openlp/core/common/__init__.py index 1f252e50d..03bf964bc 100644 --- a/openlp/core/common/__init__.py +++ b/openlp/core/common/__init__.py @@ -49,8 +49,7 @@ def trace_error_handler(logger): """ Log the calling path of an exception - ``logger`` - logger to use so traceback is logged to correct class + :param logger: logger to use so traceback is logged to correct class """ for tb in traceback.extract_stack(): logger.error('Called by ' + tb[3] + ' at line ' + str(tb[1]) + ' in ' + tb[0]) @@ -60,11 +59,8 @@ def check_directory_exists(directory, do_not_log=False): """ Check a theme directory exists and if not create it - ``directory`` - The directory to make sure exists - - ``do_not_log`` - To not log anything. This is need for the start up, when the log isn't ready. + :param directory: The directory to make sure exists + :param do_not_log: To not log anything. This is need for the start up, when the log isn't ready. """ if not do_not_log: log.debug('check_directory_exists %s' % directory) @@ -99,14 +95,12 @@ def translate(context, text, comment=None, encoding=QtCore.QCoreApplication.Code A special shortcut method to wrap around the Qt4 translation functions. This abstracts the translation procedure so that we can change it if at a later date if necessary, without having to redo the whole of OpenLP. - ``context`` - The translation context, used to give each string a context or a namespace. - - ``text`` - The text to put into the translation tables for translation. - - ``comment`` - An identifying string for when the same text is used in different roles within the same context. + :param context: The translation context, used to give each string a context or a namespace. + :param text: The text to put into the translation tables for translation. + :param comment: An identifying string for when the same text is used in different roles within the same context. + :param encoding: + :param n: + :param qt_translate: """ return qt_translate(context, text, comment, encoding, n) diff --git a/openlp/core/common/applocation.py b/openlp/core/common/applocation.py index 4ff975520..fdc787f6a 100644 --- a/openlp/core/common/applocation.py +++ b/openlp/core/common/applocation.py @@ -69,8 +69,7 @@ class AppLocation(object): """ Return the appropriate directory according to the directory type. - ``dir_type`` - The directory type you want, for instance the data directory. Default *AppLocation.AppDir* + :param dir_type: The directory type you want, for instance the data directory. Default *AppLocation.AppDir* """ if dir_type == AppLocation.AppDir: return get_frozen_path(os.path.abspath(os.path.split(sys.argv[0])[0]), os.path.split(openlp.__file__)[0]) @@ -106,10 +105,9 @@ class AppLocation(object): """ Get a list of files from the data files path. - ``section`` - Defaults to *None*. The section of code getting the files - used to load from a section's data subdirectory. - - ``extension`` + :param section: Defaults to *None*. The section of code getting the files - used to load from a section's + data subdirectory. + :param extension: Defaults to *None*. The extension to search for. For example:: u'.png' diff --git a/openlp/core/common/registry.py b/openlp/core/common/registry.py index 4d43a738e..014a534f7 100644 --- a/openlp/core/common/registry.py +++ b/openlp/core/common/registry.py @@ -73,8 +73,7 @@ class Registry(object): """ Extracts the registry value from the list based on the key passed in - ``key`` - The service to be retrieved. + :param key: The service to be retrieved. """ if key in self.service_list: return self.service_list[key] @@ -88,11 +87,8 @@ class Registry(object): """ Registers a component against a key. - ``key`` - The service to be created this is usually a major class like "renderer" or "main_window" . - - ``reference`` - The service address to be saved. + :param key: The service to be created this is usually a major class like "renderer" or "main_window" . + :param reference: The service address to be saved. """ if key in self.service_list: trace_error_handler(log) @@ -106,8 +102,7 @@ class Registry(object): Removes the registry value from the list based on the key passed in (Only valid and active for testing framework). - ``key`` - The service to be deleted. + :param key: The service to be deleted. """ if key in self.service_list: del self.service_list[key] @@ -116,13 +111,10 @@ class Registry(object): """ Register an event and associated function to be called - ``event`` - The function description like "live_display_hide" where a number of places in the code + :param event: The function description like "live_display_hide" where a number of places in the code will/may need to respond to a single action and the caller does not need to understand or know about the recipients. - - ``function`` - The function to be called when the event happens. + :param function: The function to be called when the event happens. """ if event in self.functions_list: self.functions_list[event].append(function) @@ -133,11 +125,8 @@ class Registry(object): """ Remove an event and associated handler - ``event`` - The function description.. - - ``function`` - The function to be called when the event happens. + :param event: The function description.. + :param function: The function to be called when the event happens. """ if self.running_under_test is False: trace_error_handler(log) @@ -150,14 +139,9 @@ class Registry(object): """ Execute all the handlers associated with the event and return an array of results. - ``event`` - The function to be processed - - ``*args`` - Parameters to be passed to the function. - - ``*kwargs`` - Parameters to be passed to the function. + :param event: The function to be processed + :param args: Parameters to be passed to the function. + :param kwargs: Parameters to be passed to the function. """ results = [] if event in self.functions_list: diff --git a/openlp/core/common/registryproperties.py b/openlp/core/common/registryproperties.py index 2564947a8..663513c29 100644 --- a/openlp/core/common/registryproperties.py +++ b/openlp/core/common/registryproperties.py @@ -115,3 +115,38 @@ class RegistryProperties(object): self._main_window = Registry().get('main_window') return self._main_window + @property + def renderer(self): + """ + Adds the Renderer to the class dynamically + """ + if not hasattr(self, '_renderer') or not self._renderer: + self._renderer = Registry().get('renderer') + return self._renderer + + @property + def theme_manager(self): + """ + Adds the theme manager to the class dynamically + """ + if not hasattr(self, '_theme_manager') or not self._theme_manager: + self._theme_manager = Registry().get('theme_manager') + return self._theme_manager + + @property + def settings_form(self): + """ + Adds the settings form to the class dynamically + """ + if not hasattr(self, '_settings_form') or not self._settings_form: + self._settings_form = Registry().get('settings_form') + return self._settings_form + + @property + def alerts_manager(self): + """ + Adds the alerts manager to the class dynamically + """ + if not hasattr(self, '_alerts_manager') or not self._alerts_manager: + self._alerts_manager = Registry().get('alerts_manager') + return self._alerts_manager \ No newline at end of file diff --git a/openlp/core/common/settings.py b/openlp/core/common/settings.py index 22cf3a2b5..216b31d08 100644 --- a/openlp/core/common/settings.py +++ b/openlp/core/common/settings.py @@ -348,8 +348,7 @@ class Settings(QtCore.QSettings): """ Static method to merge the given ``default_values`` with the ``Settings.__default_settings__``. - ``default_values`` - A dict with setting keys and their default values. + :param default_values: A dict with setting keys and their default values. """ Settings.__default_settings__ = dict(list(default_values.items()) + list(Settings.__default_settings__.items())) @@ -419,8 +418,7 @@ class Settings(QtCore.QSettings): Returns the value for the given ``key``. The returned ``value`` is of the same type as the default value in the *Settings.__default_settings__* dict. - ``key`` - The key to return the value from. + :param key: The key to return the value from. """ # if group() is not empty the group has not been specified together with the key. if self.group(): @@ -434,12 +432,9 @@ class Settings(QtCore.QSettings): """ This converts the given ``setting`` to the type of the given ``default_value``. - ``setting`` - The setting to convert. This could be ``true`` for example.Settings() - - ``default_value`` - Indication the type the setting should be converted to. For example ``True`` (type is boolean), meaning that - we convert the string ``true`` to a python boolean. + :param setting: The setting to convert. This could be ``true`` for example.Settings() + :param default_value: Indication the type the setting should be converted to. For example ``True`` + (type is boolean), meaning that we convert the string ``true`` to a python boolean. **Note**, this method only converts a few types and might need to be extended if a certain type is missing! """ @@ -471,10 +466,9 @@ class Settings(QtCore.QSettings): This removes the settings needed for old way we saved files (e. g. the image paths for the image plugin). A list of file paths are returned. - **Note**: Only a list of paths is returned; this does not convert anything! + **Note**: Only a list of paths is returned; this does not convert anything! - ``plugin`` - The Plugin object.The caller has to convert/save the list himself; o + :param plugin: The Plugin object.The caller has to convert/save the list himself; o """ files_list = [] # We need QSettings instead of Settings here to bypass our central settings dict. diff --git a/openlp/core/lib/db.py b/openlp/core/lib/db.py index 36bfa24ef..c81cb5a3a 100644 --- a/openlp/core/lib/db.py +++ b/openlp/core/lib/db.py @@ -52,14 +52,9 @@ def init_db(url, auto_flush=True, auto_commit=False): """ Initialise and return the session and metadata for a database - ``url`` - The database to initialise connection with - - ``auto_flush`` - Sets the flushing behaviour of the session - - ``auto_commit`` - Sets the commit behaviour of the session + :param url: The database to initialise connection with + :param auto_flush: Sets the flushing behaviour of the session + :param auto_commit: Sets the commit behaviour of the session """ engine = create_engine(url, poolclass=NullPool) metadata = MetaData(bind=engine) @@ -71,8 +66,7 @@ def get_upgrade_op(session): """ Create a migration context and an operations object for performing upgrades. - ``session`` - The SQLAlchemy session object. + :param session: The SQLAlchemy session object. """ context = MigrationContext.configure(session.bind.connect()) return Operations(context) diff --git a/openlp/core/lib/formattingtags.py b/openlp/core/lib/formattingtags.py index db6213462..0028129b5 100644 --- a/openlp/core/lib/formattingtags.py +++ b/openlp/core/lib/formattingtags.py @@ -170,9 +170,7 @@ class FormattingTags(object): """ Add a list of tags to the list. - ``tags`` - The list with tags to add. - + :param tags: The list with tags to add. Each **tag** has to be a ``dict`` and should have the following keys: * desc diff --git a/openlp/core/lib/htmlbuilder.py b/openlp/core/lib/htmlbuilder.py index b85c76955..7f6ab67b7 100644 --- a/openlp/core/lib/htmlbuilder.py +++ b/openlp/core/lib/htmlbuilder.py @@ -556,23 +556,12 @@ def build_html(item, screen, is_live, background, image=None, plugins=None): """ Build the full web paged structure for display - ``item`` - Service Item to be displayed - - ``screen`` - Current display information - - ``is_live`` - Item is going live, rather than preview/theme building - - ``background`` - Theme background image - bytes - - ``image`` - Image media item - bytes - - ``plugins`` - The List of available plugins + :param item: Service Item to be displayed + :param screen: Current display information + :param is_live: Item is going live, rather than preview/theme building + :param background: Theme background image - bytes + :param image: Image media item - bytes + :param plugins: The List of available plugins """ width = screen['size'].width() height = screen['size'].height() @@ -626,8 +615,8 @@ def build_background_css(item, width): """ Build the background css - ``item`` - Service Item containing theme and location information + :param item: Service Item containing theme and location information + :param width: """ width = int(width) // 2 theme = item.theme_data @@ -660,9 +649,7 @@ def build_lyrics_css(item): """ Build the lyrics display css - ``item`` - Service Item containing theme and location information - + :param item: Service Item containing theme and location information """ style = """ .lyricstable { @@ -700,8 +687,7 @@ def build_lyrics_outline_css(theme_data): """ Build the css which controls the theme outline. Also used by renderer for splitting verses - ``theme_data`` - Object containing theme information + :param theme_data: Object containing theme information """ if theme_data.font_main_outline: size = float(theme_data.font_main_outline_size) / 16 @@ -715,14 +701,9 @@ def build_lyrics_format_css(theme_data, width, height): """ Build the css which controls the theme format. Also used by renderer for splitting verses - ``theme_data`` - Object containing theme information - - ``width`` - Width of the lyrics block - - ``height`` - Height of the lyrics block + :param theme_data: Object containing theme information + :param width: Width of the lyrics block + :param height: Height of the lyrics block """ align = HorizontalType.Names[theme_data.display_horizontal_align] valign = VerticalType.Names[theme_data.display_vertical_align] @@ -756,8 +737,8 @@ def build_footer_css(item, height): """ Build the display of the item footer - ``item`` - Service Item to be processed. + :param item: Service Item to be processed. + :param height: """ style = """ left: %spx; diff --git a/openlp/core/lib/imagemanager.py b/openlp/core/lib/imagemanager.py index 2a803dd6a..47938d8b0 100644 --- a/openlp/core/lib/imagemanager.py +++ b/openlp/core/lib/imagemanager.py @@ -111,16 +111,12 @@ class Image(object): """ Create an image for the :class:`ImageManager`'s cache. - ``path`` - The image's file path. This should be an existing file path. - - ``source`` - The source describes the image's origin. Possible values are described in the + :param path: The image's file path. This should be an existing file path. + :param source: The source describes the image's origin. Possible values are described in the :class:`~openlp.core.lib.ImageSource` class. - - ``background`` - A ``QtGui.QColor`` object specifying the colour to be used to fill the gabs if the image's ratio does not + :param background: A ``QtGui.QColor`` object specifying the colour to be used to fill the gabs if the image's ratio does not match with the display ratio. + """ self.path = path self.image = None @@ -163,11 +159,8 @@ class PriorityQueue(queue.PriorityQueue): """ Modifies the priority of the given ``image``. - ``image`` - The image to remove. This should be an :class:`Image` instance. - - ``new_priority`` - The image's new priority. See the :class:`Priority` class for priorities. + :param image: The image to remove. This should be an :class:`Image` instance. + :param new_priority: The image's new priority. See the :class:`Priority` class for priorities. """ self.remove(image) image.priority = new_priority @@ -177,8 +170,7 @@ class PriorityQueue(queue.PriorityQueue): """ Removes the given ``image`` from the queue. - ``image`` - The image to remove. This should be an ``Image`` instance. + :param image: The image to remove. This should be an ``Image`` instance. """ if (image.priority, image.secondary_priority, image) in self.queue: self.queue.remove((image.priority, image.secondary_priority, image)) diff --git a/openlp/core/lib/listwidgetwithdnd.py b/openlp/core/lib/listwidgetwithdnd.py index 3c49763ae..2618d13c3 100644 --- a/openlp/core/lib/listwidgetwithdnd.py +++ b/openlp/core/lib/listwidgetwithdnd.py @@ -95,8 +95,7 @@ class ListWidgetWithDnD(QtGui.QListWidget): """ Receive drop event check if it is a file and process it if it is. - ``event`` - Handle of the event pint passed + :param event: Handle of the event pint passed """ if event.mimeData().hasUrls(): event.setDropAction(QtCore.Qt.CopyAction) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index a92306ce9..13d4b0bbb 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -35,7 +35,7 @@ import re from PyQt4 import QtCore, QtGui -from openlp.core.common import Registry, Settings, UiStrings, translate +from openlp.core.common import Registry, RegistryProperties, Settings, UiStrings, translate from openlp.core.lib import FileDialog, OpenLPToolbar, ServiceItem, StringContent, ListWidgetWithDnD, \ ServiceItemContext from openlp.core.lib.searchedit import SearchEdit @@ -44,7 +44,7 @@ from openlp.core.lib.ui import create_widget_action, critical_error_message_box log = logging.getLogger(__name__) -class MediaManagerItem(QtGui.QWidget): +class MediaManagerItem(QtGui.QWidget, RegistryProperties): """ MediaManagerItem is a helper widget for plugins. @@ -684,97 +684,3 @@ s :param show_error: Should the error be shown (True) """ raise NotImplementedError('Plugin.search needs to be defined by the plugin') - - def _get_main_window(self): - """ - Adds the main window to the class dynamically - """ - if not hasattr(self, '_main_window'): - self._main_window = Registry().get('main_window') - return self._main_window - - main_window = property(_get_main_window) - - def _get_renderer(self): - """ - Adds the Renderer to the class dynamically - """ - if not hasattr(self, '_renderer'): - self._renderer = Registry().get('renderer') - return self._renderer - - renderer = property(_get_renderer) - - def _get_live_controller(self): - """ - Adds the live controller to the class dynamically - """ - if not hasattr(self, '_live_controller'): - self._live_controller = Registry().get('live_controller') - return self._live_controller - - live_controller = property(_get_live_controller) - - def _get_preview_controller(self): - """ - Adds the preview controller to the class dynamically - """ - if not hasattr(self, '_preview_controller'): - self._preview_controller = Registry().get('preview_controller') - return self._preview_controller - - preview_controller = property(_get_preview_controller) - - def _get_plugin_manager(self): - """ - Adds the plugin manager to the class dynamically - """ - if not hasattr(self, '_plugin_manager'): - self._plugin_manager = Registry().get('plugin_manager') - return self._plugin_manager - - plugin_manager = property(_get_plugin_manager) - - def _get_media_controller(self): - """ - Adds the media controller to the class dynamically - """ - if not hasattr(self, '_media_controller'): - self._media_controller = Registry().get('media_controller') - return self._media_controller - - media_controller = property(_get_media_controller) - - def _get_service_manager(self): - """ - Adds the service manager to the class dynamically - """ - if not hasattr(self, '_service_manager'): - self._service_manager = Registry().get('service_manager') - return self._service_manager - - service_manager = property(_get_service_manager) - - def _get_theme_manager(self): - """ - Adds the theme manager to the class dynamically - """ - if not hasattr(self, '_theme_manager'): - self._theme_manager = Registry().get('theme_manager') - return self._theme_manager - - theme_manager = property(_get_theme_manager) - - def _get_application(self): - """ - Adds the openlp to the class dynamically. - Windows needs to access the application in a dynamic manner. - """ - if os.name == 'nt': - return Registry().get('application') - else: - if not hasattr(self, '_application'): - self._application = Registry().get('application') - return self._application - - application = property(_get_application) diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 38fe05435..cafc24d9b 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -30,11 +30,11 @@ Provide the generic plugin functionality for OpenLP plugins. """ import logging -import os + from PyQt4 import QtCore -from openlp.core.common import Registry, Settings, UiStrings +from openlp.core.common import Registry, RegistryProperties, Settings, UiStrings from openlp.core.utils import get_application_version log = logging.getLogger(__name__) @@ -65,7 +65,7 @@ class StringContent(object): VisibleName = 'visible_name' -class Plugin(QtCore.QObject): +class Plugin(QtCore.QObject, RegistryProperties): """ Base class for openlp plugins to inherit from. @@ -122,28 +122,21 @@ class Plugin(QtCore.QObject): def __init__(self, name, default_settings, media_item_class=None, settings_tab_class=None, version=None): """ - This is the constructor for the plugin object. This provides an easy - way for descendent plugins to populate common data. This method *must* + This is the constructor for the plugin object. This provides an easy way for descendant plugins to populate + common data. This method *must* + be overridden, like so:: class MyPlugin(Plugin): def __init__(self): super(MyPlugin, self).__init__('MyPlugin', version=u'0.1') - ``name`` - Defaults to *None*. The name of the plugin. - - ``default_settings`` - A dict containing the plugin's settings. The value to each key is the default value to be used. - - ``media_item_class`` - The class name of the plugin's media item. - - ``settings_tab_class`` - The class name of the plugin's settings tab. - - ``version`` - Defaults to *None*, which means that the same version number is used as OpenLP's version number. + :param name: Defaults to *None*. The name of the plugin. + :param default_settings: A dict containing the plugin's settings. The value to each key is the default value + to be used. + :param media_item_class: The class name of the plugin's media item. + :param settings_tab_class: The class name of the plugin's settings tab. + :param version: Defaults to *None*, which means that the same version number is used as OpenLP's version number. """ log.debug('Plugin %s initialised' % name) super(Plugin, self).__init__() @@ -221,8 +214,7 @@ class Plugin(QtCore.QObject): """ Upgrade the settings of this plugin. - ``settings`` - The Settings object containing the old settings. + :param settings: The Settings object containing the old settings. """ pass @@ -230,8 +222,7 @@ class Plugin(QtCore.QObject): """ Create a menu item and add it to the "Import" menu. - ``import_menu`` - The Import menu. + :param import_menu: The Import menu. """ pass @@ -239,8 +230,7 @@ class Plugin(QtCore.QObject): """ Create a menu item and add it to the "Export" menu. - ``export_menu`` - The Export menu + :param export_menu: The Export menu """ pass @@ -248,8 +238,7 @@ class Plugin(QtCore.QObject): """ Create a menu item and add it to the "Tools" menu. - ``tools_menu`` - The Tools menu + :param tools_menu: The Tools menu """ pass @@ -267,8 +256,7 @@ class Plugin(QtCore.QObject): """ Add menu items to the menu, given the menubar. - ``menubar`` - The application's menu bar. + :param menubar: The application's menu bar. """ pass @@ -284,8 +272,7 @@ class Plugin(QtCore.QObject): def about(self): """ - Show a dialog when the user clicks on the 'About' button in the plugin - manager. + Show a dialog when the user clicks on the 'About' button in the plugin manager. """ raise NotImplementedError('Plugin.about needs to be defined by the plugin') @@ -328,11 +315,8 @@ class Plugin(QtCore.QObject): """ Renames a theme a plugin is using making the plugin use the new name. - ``old_theme`` - The name of the theme the plugin should stop using. - - ``new_theme`` - The new name the plugin should now use. + :param old_theme: The name of the theme the plugin should stop using. + :param new_theme: The new name the plugin should now use """ pass @@ -409,27 +393,4 @@ class Plugin(QtCore.QObject): """ The plugin's needs to handle a new song creation """ - pass - - def _get_main_window(self): - """ - Adds the main window to the class dynamically - """ - if not hasattr(self, '_main_window'): - self._main_window = Registry().get('main_window') - return self._main_window - - main_window = property(_get_main_window) - - def _get_application(self): - """ - Adds the openlp to the class dynamically - """ - if os.name == 'nt': - return Registry().get('application') - else: - if not hasattr(self, '_application'): - self._application = Registry().get('application') - return self._application - - application = property(_get_application) + pass \ No newline at end of file diff --git a/openlp/core/lib/pluginmanager.py b/openlp/core/lib/pluginmanager.py index aaae5375d..d24f07eac 100644 --- a/openlp/core/lib/pluginmanager.py +++ b/openlp/core/lib/pluginmanager.py @@ -34,10 +34,10 @@ import sys import imp from openlp.core.lib import Plugin, PluginStatus -from openlp.core.common import AppLocation, Registry, OpenLPMixin, RegistryMixin +from openlp.core.common import AppLocation, RegistryProperties, OpenLPMixin, RegistryMixin -class PluginManager(RegistryMixin, OpenLPMixin): +class PluginManager(RegistryMixin, OpenLPMixin, RegistryProperties): """ This is the Plugin manager, which loads all the plugins, and executes all the hooks, as and when necessary. @@ -176,8 +176,7 @@ class PluginManager(RegistryMixin, OpenLPMixin): """ Loop through all the plugins and give them an opportunity to upgrade their settings. - ``settings`` - The Settings object containing the old settings. + :param settings: The Settings object containing the old settings. """ for plugin in self.plugins: if plugin.status is not PluginStatus.Disabled: @@ -185,8 +184,7 @@ class PluginManager(RegistryMixin, OpenLPMixin): def initialise_plugins(self): """ - Loop through all the plugins and give them an opportunity to - initialise themselves. + Loop through all the plugins and give them an opportunity to initialise themselves. """ for plugin in self.plugins: self.log_info('initialising plugins %s in a %s state' % (plugin.name, plugin.is_active())) @@ -196,8 +194,7 @@ class PluginManager(RegistryMixin, OpenLPMixin): def finalise_plugins(self): """ - Loop through all the plugins and give them an opportunity to - clean themselves up + Loop through all the plugins and give them an opportunity to clean themselves up """ for plugin in self.plugins: if plugin.is_active(): @@ -220,23 +217,3 @@ class PluginManager(RegistryMixin, OpenLPMixin): for plugin in self.plugins: if plugin.is_active(): plugin.new_service_created() - - def _get_settings_form(self): - """ - Adds the plugin manager to the class dynamically - """ - if not hasattr(self, '_settings_form'): - self._settings_form = Registry().get('settings_form') - return self._settings_form - - settings_form = property(_get_settings_form) - - def _get_main_window(self): - """ - Adds the main window to the class dynamically - """ - if not hasattr(self, '_main_window'): - self._main_window = Registry().get('main_window') - return self._main_window - - main_window = property(_get_main_window) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 49407a78d..233af3784 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -30,7 +30,7 @@ from PyQt4 import QtGui, QtCore, QtWebKit -from openlp.core.common import Registry, OpenLPMixin, RegistryMixin, Settings +from openlp.core.common import Registry, RegistryProperties, OpenLPMixin, RegistryMixin, Settings from openlp.core.lib import FormattingTags, ImageSource, ItemCapabilities, ScreenList, ServiceItem, expand_tags, \ build_lyrics_format_css, build_lyrics_outline_css from openlp.core.common import ThemeLevel @@ -47,7 +47,7 @@ VERSE_FOR_LINE_COUNT = '\n'.join(map(str, range(100))) FOOTER = ['Arky Arky (Unknown)', 'Public Domain', 'CCLI 123456'] -class Renderer(OpenLPMixin, RegistryMixin): +class Renderer(OpenLPMixin, RegistryMixin, RegistryProperties): """ Class to pull all Renderer interactions into one place. The plugins will call helper methods to do the rendering but this class will provide display defense code. @@ -563,23 +563,3 @@ class Renderer(OpenLPMixin, RegistryMixin): # this parse we are to be wordy line = line.replace('\n', ' ') return line.split(' ') - - def _get_image_manager(self): - """ - Adds the image manager to the class dynamically - """ - if not hasattr(self, '_image_manager'): - self._image_manager = Registry().get('image_manager') - return self._image_manager - - image_manager = property(_get_image_manager) - - def _get_theme_manager(self): - """ - Adds the theme manager to the class dynamically - """ - if not hasattr(self, '_theme_manager') or not self._theme_manager : - self._theme_manager = Registry().get('theme_manager') - return self._theme_manager - - theme_manager = property(_get_theme_manager) diff --git a/openlp/core/lib/screen.py b/openlp/core/lib/screen.py index e9994d593..17ead5346 100644 --- a/openlp/core/lib/screen.py +++ b/openlp/core/lib/screen.py @@ -150,8 +150,7 @@ class ScreenList(object): """ Add a screen to the list of known screens. - ``screen`` - A dict with the screen properties:: + :param screen: A dict with the screen properties:: { u'primary': True, @@ -170,8 +169,7 @@ class ScreenList(object): """ Remove a screen from the list of known screens. - ``number`` - The screen number (int). + :param number: The screen number (int). """ log.info('remove_screen %d' % number) for screen in self.screen_list: @@ -184,8 +182,7 @@ class ScreenList(object): """ Confirms a screen is known. - ``number`` - The screen number (int). + :param number: The screen number (int). """ for screen in self.screen_list: if screen['number'] == number: @@ -196,8 +193,7 @@ class ScreenList(object): """ Set up the current screen dimensions. - ``number`` - The screen number (int). + :param number: The screen number (int). """ log.debug('set_current_display %s' % number) if number + 1 > self.display_count: @@ -211,8 +207,7 @@ class ScreenList(object): def set_override_display(self): """ - Replace the current size with the override values, as the user wants to - have their own screen attributes. + Replace the current size with the override values, as the user wants to have their own screen attributes. """ log.debug('set_override_display') self.current = copy.deepcopy(self.override) @@ -220,8 +215,7 @@ class ScreenList(object): def reset_current_display(self): """ - Replace the current values with the correct values, as the user wants to - use the correct screen attributes. + Replace the current values with the correct values, as the user wants to use the correct screen attributes. """ log.debug('reset_current_display') self.set_current_display(self.current['number']) @@ -230,8 +224,7 @@ class ScreenList(object): """ Return the screen number that the centre of the passed window is in. - ``window`` - A QWidget we are finding the location of. + :param window: A QWidget we are finding the location of. """ x = window.x() + (window.width() // 2) y = window.y() + (window.height() // 2) diff --git a/openlp/core/lib/searchedit.py b/openlp/core/lib/searchedit.py index 3f795f5a2..d6eaafa7d 100644 --- a/openlp/core/lib/searchedit.py +++ b/openlp/core/lib/searchedit.py @@ -79,8 +79,7 @@ class SearchEdit(QtGui.QLineEdit): """ Reimplemented method to react to resizing of the widget. - ``event`` - The event that happened. + :param event: The event that happened. """ size = self.clear_button.size() frame_width = self.style().pixelMetric(QtGui.QStyle.PM_DefaultFrameWidth) @@ -100,8 +99,7 @@ class SearchEdit(QtGui.QLineEdit): """ Set a new current search type. - ``identifier`` - The search type identifier (int). + :param identifier: The search type identifier (int). """ menu = self.menu_button.menu() for action in menu.actions(): @@ -122,8 +120,8 @@ class SearchEdit(QtGui.QLineEdit): A list of tuples to be used in the search type menu. The first item in the list will be preselected as the default. - ``items`` - The list of tuples to use. The tuples should contain an integer identifier, an icon (QIcon instance or + :param items: The list of tuples to use. The tuples should contain an integer identifier, an icon (QIcon instance or + string) and a title for the item in the menu. In short, they should look like this:: (, , , <place holder text>) @@ -162,8 +160,7 @@ class SearchEdit(QtGui.QLineEdit): Internally implemented slot to react to when the text in the line edit has changed so that we can show or hide the clear button. - ``text`` - A :class:`~PyQt4.QtCore.QString` instance which represents the text in the line edit. + :param text: A :class:`~PyQt4.QtCore.QString` instance which represents the text in the line edit. """ self.clear_button.setVisible(bool(text)) diff --git a/openlp/core/lib/serviceitem.py b/openlp/core/lib/serviceitem.py index 17679141d..be3822eaa 100644 --- a/openlp/core/lib/serviceitem.py +++ b/openlp/core/lib/serviceitem.py @@ -39,7 +39,7 @@ import uuid from PyQt4 import QtGui -from openlp.core.common import Registry, Settings, translate +from openlp.core.common import RegistryProperties, Settings, translate from openlp.core.lib import ImageSource, build_icon, clean_tags, expand_tags log = logging.getLogger(__name__) @@ -140,7 +140,7 @@ class ItemCapabilities(object): HasThumbnails = 19 -class ServiceItem(object): +class ServiceItem(RegistryProperties): """ The service item is a base class for the plugins to use to interact with the service manager, the slide controller, and the projection screen @@ -152,8 +152,7 @@ class ServiceItem(object): """ Set up the service item. - ``plugin`` - The plugin that this service item belongs to. + :param plugin: The plugin that this service item belongs to. """ if plugin: self.name = plugin.name @@ -199,8 +198,7 @@ class ServiceItem(object): def _new_item(self): """ - Method to set the internal id of the item. This is used to compare - service items to see if they are the same. + Method to set the internal id of the item. This is used to compare service items to see if they are the same. """ self.unique_identifier = str(uuid.uuid1()) self.validate_item() @@ -209,8 +207,7 @@ class ServiceItem(object): """ Add an ItemCapability to a ServiceItem - ``capability`` - The capability to add + :param capability: The capability to add """ self.capabilities.append(capability) @@ -218,30 +215,25 @@ class ServiceItem(object): """ Tell the caller if a ServiceItem has a capability - ``capability`` - The capability to test for + :param capability: The capability to test for """ return capability in self.capabilities def add_icon(self, icon): """ - Add an icon to the service item. This is used when displaying the - service item in the service manager. + Add an icon to the service item. This is used when displaying the service item in the service manager. - ``icon`` - A string to an icon in the resources or on disk. + :param icon: A string to an icon in the resources or on disk. """ self.icon = icon self.iconic_representation = build_icon(icon) def render(self, provides_own_theme_data=False): """ - The render method is what generates the frames for the screen and - obtains the display information from the renderer. At this point all - slides are built for the given display size. + The render method is what generates the frames for the screen and obtains the display information from the + renderer. At this point all slides are built for the given display size. - ``provides_own_theme_data`` - This switch disables the usage of the item's theme. However, this is + :param provides_own_theme_data: This switch disables the usage of the item's theme. However, this is disabled by default. If this is used, it has to be taken care, that the renderer knows the correct theme data. However, this is needed for the theme manager. @@ -289,11 +281,9 @@ class ServiceItem(object): """ Add an image slide to the service item. - ``path`` - The directory in which the image file is located. - - ``title`` - A title for the slide in the service item. + :param path: The directory in which the image file is located. + :param title: A title for the slide in the service item. + :param background: """ if background: self.image_border = background @@ -306,8 +296,8 @@ class ServiceItem(object): """ Add a text slide to the service item. - ``raw_slide`` - The raw text of the slide. + :param raw_slide: The raw text of the slide. + :param verse_tag: """ if verse_tag: verse_tag = verse_tag.upper() @@ -320,14 +310,9 @@ class ServiceItem(object): """ Add a slide from a command. - ``path`` - The title of the slide in the service item. - - ``file_name`` - The title of the slide in the service item. - - ``image`` - The command of/for the slide. + :param path: The title of the slide in the service item. + :param file_name: The title of the slide in the service item. + :param image: The command of/for the slide. """ self.service_item_type = ServiceItemType.Command self._raw_frames.append({'title': file_name, 'image': image, 'path': path, @@ -336,8 +321,7 @@ class ServiceItem(object): def get_service_repr(self, lite_save): """ - This method returns some text which can be saved into the service - file to represent this item. + This method returns some text which can be saved into the service file to represent this item. """ service_header = { 'name': self.name, @@ -380,21 +364,17 @@ class ServiceItem(object): 'display_title': slide['display_title'], 'notes': slide['notes']}) return {'header': service_header, 'data': service_data} - def set_from_service(self, serviceitem, path=None): + def set_from_service(self, service_item, path=None): """ - This method takes a service item from a saved service file (passed - from the ServiceManager) and extracts the data actually required. + This method takes a service item from a saved service file (passed from the ServiceManager) and extracts the + data actually required. - ``serviceitem`` - The item to extract data from. - - ``path`` - Defaults to *None*. This is the service manager path for things - which have their files saved with them or None when the saved - service is lite and the original file paths need to be preserved.. + :param service_item: The item to extract data from. + :param path: Defaults to *None*. This is the service manager path for things which have their files saved + with them or None when the saved service is lite and the original file paths need to be preserved. """ log.debug('set_from_service called with path %s' % path) - header = serviceitem['serviceitem']['header'] + header = service_item['serviceitem']['header'] self.title = header['title'] self.name = header['name'] self.service_item_type = header['type'] @@ -430,21 +410,21 @@ class ServiceItem(object): self.background_audio.append(os.path.join(path, filename)) self.theme_overwritten = header.get('theme_overwritten', False) if self.service_item_type == ServiceItemType.Text: - for slide in serviceitem['serviceitem']['data']: + for slide in service_item['serviceitem']['data']: self._raw_frames.append(slide) elif self.service_item_type == ServiceItemType.Image: - settings_section = serviceitem['serviceitem']['header']['name'] + settings_section = service_item['serviceitem']['header']['name'] background = QtGui.QColor(Settings().value(settings_section + '/background color')) if path: self.has_original_files = False - for text_image in serviceitem['serviceitem']['data']: + for text_image in service_item['serviceitem']['data']: filename = os.path.join(path, text_image) self.add_from_image(filename, text_image, background) else: - for text_image in serviceitem['serviceitem']['data']: + for text_image in service_item['serviceitem']['data']: self.add_from_image(text_image['path'], text_image['title'], background) elif self.service_item_type == ServiceItemType.Command: - for text_image in serviceitem['serviceitem']['data']: + for text_image in service_item['serviceitem']['data']: if not self.title: self.title = text_image['title'] if path: @@ -470,11 +450,9 @@ class ServiceItem(object): def merge(self, other): """ Updates the unique_identifier with the value from the original one - The unique_identifier is unique for a given service item but this allows one to - replace an original version. + The unique_identifier is unique for a given service item but this allows one to replace an original version. - ``other`` - The service item to be merged with + :param other: The service item to be merged with """ self.unique_identifier = other.unique_identifier self.notes = other.notes @@ -541,8 +519,7 @@ class ServiceItem(object): """ Stores the media length of the item - ``length`` - The length of the media item + :param length: The length of the media item """ self.media_length = length if length > 0: @@ -560,8 +537,8 @@ class ServiceItem(object): def get_rendered_frame(self, row): """ Returns the correct frame for a given list and renders it if required. - ``row`` - The service item slide to be returned + + :param row: The service item slide to be returned """ if self.service_item_type == ServiceItemType.Text: return self._display_frames[row]['html'].split('\n')[0] @@ -626,8 +603,7 @@ class ServiceItem(object): """ updates the theme in the service item - ``theme`` - The new theme to be replaced in the service item + :param theme: The new theme to be replaced in the service item """ self.theme_overwritten = (theme is None) self.theme = theme @@ -668,23 +644,3 @@ class ServiceItem(object): if file_suffix.lower() not in suffix_list: self.is_valid = False break - - def _get_renderer(self): - """ - Adds the Renderer to the class dynamically - """ - if not hasattr(self, '_renderer'): - self._renderer = Registry().get('renderer') - return self._renderer - - renderer = property(_get_renderer) - - def _get_image_manager(self): - """ - Adds the image manager to the class dynamically - """ - if not hasattr(self, '_image_manager'): - self._image_manager = Registry().get('image_manager') - return self._image_manager - - image_manager = property(_get_image_manager) diff --git a/openlp/core/lib/settingstab.py b/openlp/core/lib/settingstab.py index d7e80dc0e..2275e47a0 100644 --- a/openlp/core/lib/settingstab.py +++ b/openlp/core/lib/settingstab.py @@ -35,10 +35,10 @@ own tab to the settings dialog. from PyQt4 import QtGui -from openlp.core.common import Registry +from openlp.core.common import RegistryProperties -class SettingsTab(QtGui.QWidget): +class SettingsTab(QtGui.QWidget, RegistryProperties): """ SettingsTab is a helper widget for plugins to define Tabs for the settings dialog. """ @@ -46,11 +46,10 @@ class SettingsTab(QtGui.QWidget): """ Constructor to create the Settings tab item. - ``title`` - The title of the tab, which is used internally for the tab handling. - - ``visible_title`` - The title of the tab, which is usually displayed on the tab. + :param parent: + :param title: The title of the tab, which is used internally for the tab handling. + :param visible_title: The title of the tab, which is usually displayed on the tab. + :param icon_path: """ super(SettingsTab, self).__init__(parent) self.tab_title = title @@ -129,9 +128,7 @@ class SettingsTab(QtGui.QWidget): """ Changes which need to be made after setup of application - ``postUpdate`` - Indicates if called before or after updates. - + :param post_update: Indicates if called before or after updates. """ pass @@ -140,63 +137,3 @@ class SettingsTab(QtGui.QWidget): Tab has just been made visible to the user """ self.tab_visited = True - - def _get_service_manager(self): - """ - Adds the service manager to the class dynamically - """ - if not hasattr(self, '_service_manager'): - self._service_manager = Registry().get('service_manager') - return self._service_manager - - service_manager = property(_get_service_manager) - - def _get_main_window(self): - """ - Adds the main window to the class dynamically - """ - if not hasattr(self, '_main_window'): - self._main_window = Registry().get('main_window') - return self._main_window - - main_window = property(_get_main_window) - - def _get_renderer(self): - """ - Adds the Renderer to the class dynamically - """ - if not hasattr(self, '_renderer'): - self._renderer = Registry().get('renderer') - return self._renderer - - renderer = property(_get_renderer) - - def _get_theme_manager(self): - """ - Adds the theme manager to the class dynamically - """ - if not hasattr(self, '_theme_manager'): - self._theme_manager = Registry().get('theme_manager') - return self._theme_manager - - theme_manager = property(_get_theme_manager) - - def _get_media_controller(self): - """ - Adds the media controller to the class dynamically - """ - if not hasattr(self, '_media_controller'): - self._media_controller = Registry().get('media_controller') - return self._media_controller - - media_controller = property(_get_media_controller) - - def _get_settings_form(self): - """ - Adds the plugin manager to the class dynamically - """ - if not hasattr(self, '_settings_form'): - self._settings_form = Registry().get('settings_form') - return self._settings_form - - settings_form = property(_get_settings_form) diff --git a/openlp/core/lib/spelltextedit.py b/openlp/core/lib/spelltextedit.py index 08652c685..facf596ab 100644 --- a/openlp/core/lib/spelltextedit.py +++ b/openlp/core/lib/spelltextedit.py @@ -128,8 +128,7 @@ class SpellTextEdit(QtGui.QPlainTextEdit): """ Changes the language for this spelltextedit. - ``action`` - The action. + :param action: The action. """ self.dictionary = enchant.Dict(action.text()) self.highlighter.spelling_dictionary = self.dictionary @@ -182,7 +181,7 @@ class Highlighter(QtGui.QSyntaxHighlighter): def highlightBlock(self, text): """ - Highlight misspelt words in a block of text. + Highlight mis spelt words in a block of text. Note, this is a Qt hook. """ diff --git a/openlp/core/lib/theme.py b/openlp/core/lib/theme.py index 813c621f8..7b1045aff 100644 --- a/openlp/core/lib/theme.py +++ b/openlp/core/lib/theme.py @@ -172,11 +172,8 @@ class ThemeXML(object): """ Expand the json objects and make into variables. - ``var`` - The array list to be processed. - - ``prev`` - The preceding string to add to the key to make the variable. + :param var: The array list to be processed. + :param prev: The preceding string to add to the key to make the variable. """ for key, value in var.items(): if prev: @@ -192,8 +189,7 @@ class ThemeXML(object): """ Add the path name to the image name so the background can be rendered. - ``path`` - The path name to be added. + :param path: The path name to be added. """ if self.background_type == 'image': if self.background_filename and path: @@ -226,8 +222,7 @@ class ThemeXML(object): """ Add a Solid background. - ``bkcolor`` - The color of the background. + :param bkcolor: The color of the background. """ background = self.theme_xml.createElement('background') background.setAttribute('type', 'solid') @@ -238,14 +233,9 @@ class ThemeXML(object): """ Add a gradient background. - ``startcolor`` - The gradient's starting colour. - - ``endcolor`` - The gradient's ending colour. - - ``direction`` - The direction of the gradient. + :param startcolor: The gradient's starting colour. + :param endcolor: The gradient's ending colour. + :param direction: The direction of the gradient. """ background = self.theme_xml.createElement('background') background.setAttribute('type', 'gradient') @@ -261,8 +251,8 @@ class ThemeXML(object): """ Add a image background. - ``filename`` - The file name of the image. + :param filename: The file name of the image. + :param border_color: """ background = self.theme_xml.createElement('background') background.setAttribute('type', 'image') @@ -278,57 +268,24 @@ class ThemeXML(object): """ Add a Font. - ``name`` - The name of the font. - - ``color`` - The colour of the font. - - ``size`` - The size of the font. - - ``override`` - Whether or not to override the default positioning of the theme. - - ``fonttype`` - The type of font, ``main`` or ``footer``. Defaults to ``main``. - - ``weight`` - The weight of then font Defaults to 50 Normal - - ``italics`` - Does the font render to italics Defaults to 0 Normal - - ``xpos`` - The X position of the text block. - - ``ypos`` - The Y position of the text block. - - ``width`` - The width of the text block. - - ``height`` - The height of the text block. - - ``outline`` - Whether or not to show an outline. - - ``outline_color`` - The colour of the outline. - - ``outline_size`` - How big the Shadow is - - ``shadow`` - Whether or not to show a shadow. - - ``shadow_color`` - The colour of the shadow. - - ``shadow_size`` - How big the Shadow is - + :param name: The name of the font. + :param color: The colour of the font. + :param size: The size of the font. + :param override: Whether or not to override the default positioning of the theme. + :param fonttype: The type of font, ``main`` or ``footer``. Defaults to ``main``. + :param bold: + :param italics: The weight of then font Defaults to 50 Normal + :param line_adjustment: Does the font render to italics Defaults to 0 Normal + :param xpos: The X position of the text block. + :param ypos: The Y position of the text block. + :param width: The width of the text block. + :param height: The height of the text block. + :param outline: Whether or not to show an outline. + :param outline_color: The colour of the outline. + :param outline_pixel: How big the Shadow is + :param shadow: Whether or not to show a shadow. + :param shadow_color: The colour of the shadow. + :param shadow_pixel: How big the Shadow is """ background = self.theme_xml.createElement('font') background.setAttribute('type', fonttype) @@ -372,15 +329,9 @@ class ThemeXML(object): """ Add a Display options. - ``horizontal`` - The horizontal alignment of the text. - - ``vertical`` - The vertical alignment of the text. - - ``transition`` - Whether the slide transition is active. - + :param horizontal: The horizontal alignment of the text. + :param vertical: The vertical alignment of the text. + :param transition: Whether the slide transition is active. """ background = self.theme_xml.createElement('display') self.theme.appendChild(background) @@ -446,8 +397,7 @@ class ThemeXML(object): """ Read in an XML string and parse it. - ``xml`` - The XML string to parse. + :param xml: The XML string to parse. """ self.parse_xml(str(xml)) @@ -455,8 +405,7 @@ class ThemeXML(object): """ Parse an XML string. - ``xml`` - The XML string to parse. + :param xml: The XML string to parse. """ # remove encoding string line = xml.find('?>') diff --git a/openlp/core/lib/toolbar.py b/openlp/core/lib/toolbar.py index d7e74937e..b1cc7b249 100644 --- a/openlp/core/lib/toolbar.py +++ b/openlp/core/lib/toolbar.py @@ -74,11 +74,8 @@ class OpenLPToolbar(QtGui.QToolBar): """ Set the visibility for a widget or a list of widgets. - ``widget`` - A list of string with widget object names. - - ``visible`` - The new state as bool. + :param widgets: A list of string with widget object names. + :param visible: The new state as bool. """ for handle in widgets: if handle in self.actions: diff --git a/openlp/core/lib/treewidgetwithdnd.py b/openlp/core/lib/treewidgetwithdnd.py index bbeae807a..cdb6cbbdb 100644 --- a/openlp/core/lib/treewidgetwithdnd.py +++ b/openlp/core/lib/treewidgetwithdnd.py @@ -66,8 +66,7 @@ class TreeWidgetWithDnD(QtGui.QTreeWidget): Drag and drop event does not care what data is selected as the recipient will use events to request the data move just tell it what plugin to call - ``event`` - The event that occurred + :param event: The event that occurred """ if event.buttons() != QtCore.Qt.LeftButton: event.ignore() @@ -85,8 +84,7 @@ class TreeWidgetWithDnD(QtGui.QTreeWidget): """ Receive drag enter event, check if it is a file or internal object and allow it if it is. - ``event`` - The event that occurred + :param event: The event that occurred """ if event.mimeData().hasUrls(): event.accept() @@ -99,8 +97,7 @@ class TreeWidgetWithDnD(QtGui.QTreeWidget): """ Receive drag move event, check if it is a file or internal object and allow it if it is. - ``event`` - The event that occurred + :param event: The event that occurred """ QtGui.QTreeWidget.dragMoveEvent(self, event) if event.mimeData().hasUrls(): @@ -116,8 +113,7 @@ class TreeWidgetWithDnD(QtGui.QTreeWidget): """ Receive drop event, check if it is a file or internal object and process it if it is. - ``event`` - Handle of the event pint passed + :param event: Handle of the event pint passed """ if event.mimeData().hasUrls(): event.setDropAction(QtCore.Qt.CopyAction) diff --git a/openlp/core/lib/ui.py b/openlp/core/lib/ui.py index 68fe2f7f9..6d9e9e8f8 100644 --- a/openlp/core/lib/ui.py +++ b/openlp/core/lib/ui.py @@ -45,11 +45,8 @@ def add_welcome_page(parent, image): """ Generate an opening welcome page for a wizard using a provided image. - ``parent`` - A ``QWizard`` object to add the welcome page to. - - ``image`` - A splash image for the wizard. + :param parent: A ``QWizard`` object to add the welcome page to. + :param image: A splash image for the wizard. """ parent.welcome_page = QtGui.QWizardPage() parent.welcome_page.setPixmap(QtGui.QWizard.WatermarkPixmap, QtGui.QPixmap(image)) @@ -73,19 +70,12 @@ def create_button_box(dialog, name, standard_buttons, custom_buttons=None): Creates a QDialogButtonBox with the given buttons. The ``accepted()`` and ``rejected()`` signals of the button box are connected with the dialogs ``accept()`` and ``reject()`` slots. - ``dialog`` - The parent object. This has to be a ``QDialog`` descendant. - - ``name`` - A string which is set as object name. - - ``standard_buttons`` - A list of strings for the used buttons. It might contain: ``ok``, ``save``, ``cancel``, ``close``, and - ``defaults``. - - ``custom_buttons`` - A list of additional buttons. If a item is a instance of QtGui.QAbstractButton it is added with - QDialogButtonBox.ActionRole. Otherwhise the item has to be a tuple of a button and a ButtonRole. + :param dialog: The parent object. This has to be a ``QDialog`` descendant. + :param name: A string which is set as object name. + :param standard_buttons: A list of strings for the used buttons. It might contain: ``ok``, ``save``, ``cancel``, + ``close``, and ``defaults``. + :param custom_buttons: A list of additional buttons. If a item is a instance of QtGui.QAbstractButton it is added + with QDialogButtonBox.ActionRole. Other wise the item has to be a tuple of a button and a ButtonRole. """ if custom_buttons is None: custom_buttons = [] @@ -117,17 +107,10 @@ def critical_error_message_box(title=None, message=None, parent=None, question=F """ Provides a standard critical message box for errors that OpenLP displays to users. - ``title`` - The title for the message box. - - ``message`` - The message to display to the user. - - ``parent`` - The parent UI element to attach the dialog to. - - ``question`` - Should this message box question the user. + :param title: The title for the message box. + :param message: The message to display to the user. + :param parent: The parent UI element to attach the dialog to. + :param question: Should this message box question the user. """ if question: return QtGui.QMessageBox.critical(parent, UiStrings().Error, message, @@ -140,11 +123,8 @@ def create_horizontal_adjusting_combo_box(parent, name): """ Creates a QComboBox with adapting width for media items. - ``parent`` - The parent widget. - - ``name`` - A string set as object name for the combo box. + :param parent: The parent widget. + :param name: A string set as object name for the combo box. """ combo = QtGui.QComboBox(parent) combo.setObjectName(name) @@ -157,11 +137,9 @@ def create_button(parent, name, **kwargs): """ Return an button with the object name set and the given parameters. - ``parent`` - A QtCore.QWidget for the buttons parent (required). - - ``name`` - A string which is set as object name (required). + :param parent: A QtCore.QWidget for the buttons parent (required). + :param name: A string which is set as object name (required). + :param kwargs: ``role`` A string which can have one value out of ``delete``, ``up``, and ``down``. This decides about default values @@ -178,6 +156,7 @@ def create_button(parent, name, **kwargs): ``enabled`` False in case the button should be disabled. + """ if 'role' in kwargs: role = kwargs.pop('role') @@ -217,11 +196,9 @@ def create_action(parent, name, **kwargs): """ Return an action with the object name set and the given parameters. - ``parent`` - A QtCore.QObject for the actions parent (required). - - ``name`` - A string which is set as object name (required). + :param parent: A QtCore.QObject for the actions parent (required). + :param name: A string which is set as object name (required). + :param kwargs: ``text`` A string for the action text. @@ -253,6 +230,7 @@ def create_action(parent, name, **kwargs): ``can_shortcuts`` Capability stating if this action can have shortcuts. If ``True`` the action is added to shortcut dialog + otherwise it it not. Define your shortcut in the :class:`~openlp.core.lib.Settings` class. *Note*: When *not* ``True`` you *must not* set a shortcuts at all. @@ -314,11 +292,8 @@ def set_case_insensitive_completer(cache, widget): """ Sets a case insensitive text completer for a widget. - ``cache`` - The list of items to use as suggestions. - - ``widget`` - A widget to set the completer (QComboBox or QTextEdit instance) + :param cache: The list of items to use as suggestions. + :param widget: A widget to set the completer (QComboBox or QTextEdit instance) """ completer = QtGui.QCompleter(cache) completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive) @@ -329,10 +304,7 @@ def create_valign_selection_widgets(parent): """ Creates a standard label and combo box for asking users to select a vertical alignment. - ``parent`` - The parent object. This should be a ``QWidget`` descendant. - - Returns a tuple of QLabel and QComboBox. + :param parent: The parent object. This should be a ``QWidget`` descendant. """ label = QtGui.QLabel(parent) label.setText(translate('OpenLP.Ui', '&Vertical Align:')) diff --git a/openlp/core/ui/advancedtab.py b/openlp/core/ui/advancedtab.py index 2806e36cd..cb0de776f 100644 --- a/openlp/core/ui/advancedtab.py +++ b/openlp/core/ui/advancedtab.py @@ -641,8 +641,7 @@ class AdvancedTab(SettingsTab): """ Notify user about required restart. - ``checked`` - The state of the check box (boolean). + :param checked: The state of the check box (boolean). """ QtGui.QMessageBox.information(self, translate('OpenLP.AdvancedTab', 'Restart Required'), translate('OpenLP.AdvancedTab', 'This change will only take effect once OpenLP ' diff --git a/openlp/core/ui/exceptionform.py b/openlp/core/ui/exceptionform.py index 462a15d42..72e78ad28 100644 --- a/openlp/core/ui/exceptionform.py +++ b/openlp/core/ui/exceptionform.py @@ -38,7 +38,7 @@ import bs4 import sqlalchemy from lxml import etree -from openlp.core.common import Registry +from openlp.core.common import RegistryProperties from PyQt4 import Qt, QtCore, QtGui, QtWebKit @@ -93,7 +93,7 @@ from .exceptiondialog import Ui_ExceptionDialog log = logging.getLogger(__name__) -class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): +class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog, RegistryProperties): """ The exception dialog """ @@ -260,13 +260,3 @@ class ExceptionForm(QtGui.QDialog, Ui_ExceptionDialog): return '-' except: return '- (Possible non-standard UNO installation)' - - def _get_main_window(self): - """ - Adds the main window to the class dynamically - """ - if not hasattr(self, '_main_window'): - self._main_window = Registry().get('main_window') - return self._main_window - - main_window = property(_get_main_window) diff --git a/openlp/core/ui/filerenameform.py b/openlp/core/ui/filerenameform.py index 717c52ea4..8e80fd102 100644 --- a/openlp/core/ui/filerenameform.py +++ b/openlp/core/ui/filerenameform.py @@ -34,10 +34,10 @@ from PyQt4 import QtGui from .filerenamedialog import Ui_FileRenameDialog -from openlp.core.common import Registry, translate +from openlp.core.common import Registry, RegistryProperties, translate -class FileRenameForm(QtGui.QDialog, Ui_FileRenameDialog): +class FileRenameForm(QtGui.QDialog, Ui_FileRenameDialog, RegistryProperties): """ The file rename dialog """ @@ -57,14 +57,4 @@ class FileRenameForm(QtGui.QDialog, Ui_FileRenameDialog): else: self.setWindowTitle(translate('OpenLP.FileRenameForm', 'File Rename')) self.file_name_edit.setFocus() - return QtGui.QDialog.exec_(self) - - def _get_main_window(self): - """ - Adds the main window to the class dynamically - """ - if not hasattr(self, '_main_window'): - self._main_window = Registry().get('main_window') - return self._main_window - - main_window = property(_get_main_window) + return QtGui.QDialog.exec_(self) \ No newline at end of file diff --git a/openlp/core/ui/firsttimeform.py b/openlp/core/ui/firsttimeform.py index 4cadaf892..56e43df77 100644 --- a/openlp/core/ui/firsttimeform.py +++ b/openlp/core/ui/firsttimeform.py @@ -41,7 +41,7 @@ from configparser import ConfigParser from PyQt4 import QtCore, QtGui -from openlp.core.common import Registry, AppLocation, Settings, check_directory_exists, translate +from openlp.core.common import Registry, RegistryProperties, AppLocation, Settings, check_directory_exists, translate from openlp.core.lib import PluginStatus, build_icon from openlp.core.utils import get_web_page from .firsttimewizard import Ui_FirstTimeWizard, FirstTimePage @@ -75,7 +75,7 @@ class ThemeScreenshotThread(QtCore.QThread): item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable) -class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): +class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard, RegistryProperties): """ This is the Theme Import Wizard, which allows easy creation and editing of OpenLP themes. """ @@ -284,8 +284,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): def _build_theme_screenshots(self): """ - This method builds the theme screenshots' icons for all items in the - ``self.themes_list_widget``. + This method builds the theme screenshots' icons for all items in the ``self.themes_list_widget``. """ themes = self.config.get('themes', 'files') themes = themes.split(',') @@ -298,12 +297,11 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): break item.setIcon(build_icon(os.path.join(gettempdir(), 'openlp', screenshot))) - def _getFileSize(self, url): + def _get_file_size(self, url): """ Get the size of a file. - ``url`` - The URL of the file we want to download. + :param url: The URL of the file we want to download. """ site = urllib.request.urlopen(url) meta = site.info() @@ -321,11 +319,8 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): """ Update the wizard progress page. - ``status_text`` - Current status information to display. - - ``increment`` - The value to increment the progress bar by. + :param status_text: Current status information to display. + :param increment: The value to increment the progress bar by. """ if status_text: self.progress_label.setText(status_text) @@ -346,7 +341,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): item = self.songs_list_widget.item(i) if item.checkState() == QtCore.Qt.Checked: filename = item.data(QtCore.Qt.UserRole) - size = self._getFileSize('%s%s' % (self.web, filename)) + size = self._get_file_size('%s%s' % (self.web, filename)) self.max_progress += size # Loop through the Bibles list and increase for each selected item iterator = QtGui.QTreeWidgetItemIterator(self.bibles_tree_widget) @@ -355,7 +350,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): item = iterator.value() if item.parent() and item.checkState(0) == QtCore.Qt.Checked: filename = item.data(0, QtCore.Qt.UserRole) - size = self._getFileSize('%s%s' % (self.web, filename)) + size = self._get_file_size('%s%s' % (self.web, filename)) self.max_progress += size iterator += 1 # Loop through the themes list and increase for each selected item @@ -364,7 +359,7 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): item = self.themes_list_widget.item(i) if item.checkState() == QtCore.Qt.Checked: filename = item.data(QtCore.Qt.UserRole) - size = self._getFileSize('%s%s' % (self.web, filename)) + size = self._get_file_size('%s%s' % (self.web, filename)) self.max_progress += size if self.max_progress: # Add on 2 for plugins status setting plus a "finished" point. @@ -473,28 +468,4 @@ class FirstTimeForm(QtGui.QWizard, Ui_FirstTimeWizard): Set the status of a plugin. """ status = PluginStatus.Active if field.checkState() == QtCore.Qt.Checked else PluginStatus.Inactive - Settings().setValue(tag, status) - - def _get_theme_manager(self): - """ - Adds the theme manager to the class dynamically - """ - if not hasattr(self, '_theme_manager'): - self._theme_manager = Registry().get('theme_manager') - return self._theme_manager - - theme_manager = property(_get_theme_manager) - - def _get_application(self): - """ - Adds the openlp to the class dynamically. - Windows needs to access the application in a dynamic manner. - """ - if os.name == 'nt': - return Registry().get('application') - else: - if not hasattr(self, '_application'): - self._application = Registry().get('application') - return self._application - - application = property(_get_application) + Settings().setValue(tag, status) \ No newline at end of file diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index 8fb488c86..642dfc538 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -335,8 +335,7 @@ class GeneralTab(SettingsTab): """ Toggle screen state depending on check box state. - ``checked`` - The state of the check box (boolean). + :param checked: The state of the check box (boolean). """ self.monitor_combo_box.setDisabled(checked) self.custom_X_value_edit.setEnabled(checked) diff --git a/openlp/core/ui/listpreviewwidget.py b/openlp/core/ui/listpreviewwidget.py index 9ee10efbd..1e05a5d07 100644 --- a/openlp/core/ui/listpreviewwidget.py +++ b/openlp/core/ui/listpreviewwidget.py @@ -33,11 +33,11 @@ It is based on a QTableWidget but represents its contents in list form. from PyQt4 import QtCore, QtGui -from openlp.core.common import Registry +from openlp.core.common import RegistryProperties from openlp.core.lib import ImageSource, ServiceItem -class ListPreviewWidget(QtGui.QTableWidget): +class ListPreviewWidget(QtGui.QTableWidget, RegistryProperties): def __init__(self, parent, screen_ratio): """ Initializes the widget to default state. @@ -160,15 +160,4 @@ class ListPreviewWidget(QtGui.QTableWidget): """ Returns the number of slides this widget holds. """ - return super(ListPreviewWidget, self).rowCount() - - def _get_image_manager(self): - """ - Adds the image manager to the class dynamically. - """ - if not hasattr(self, '_image_manager'): - self._image_manager = Registry().get('image_manager') - return self._image_manager - - image_manager = property(_get_image_manager) - + return super(ListPreviewWidget, self).rowCount() \ No newline at end of file diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 13277f6e7..eced865ad 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -38,13 +38,12 @@ Some of the code for this form is based on the examples at: import cgi import logging -import os import sys from PyQt4 import QtCore, QtGui, QtWebKit, QtOpenGL from PyQt4.phonon import Phonon -from openlp.core.common import Registry, OpenLPMixin, Settings, translate +from openlp.core.common import Registry, RegistryProperties, OpenLPMixin, Settings, translate from openlp.core.lib import ServiceItem, ImageSource, build_html, expand_tags, image_to_byte from openlp.core.lib.theme import BackgroundType @@ -118,7 +117,7 @@ class Display(QtGui.QGraphicsView): self.web_loaded = True -class MainDisplay(OpenLPMixin, Display): +class MainDisplay(OpenLPMixin, Display, RegistryProperties): """ This is the display screen as a specialized class from the Display class """ @@ -468,50 +467,6 @@ class MainDisplay(OpenLPMixin, Display): self.setCursor(QtCore.Qt.ArrowCursor) self.frame.evaluateJavaScript('document.body.style.cursor = "auto"') - def _get_plugin_manager(self): - """ - Adds the Renderer to the class dynamically - """ - if not hasattr(self, '_plugin_manager'): - self._plugin_manager = Registry().get('plugin_manager') - return self._plugin_manager - - plugin_manager = property(_get_plugin_manager) - - def _get_image_manager(self): - """ - Adds the image manager to the class dynamically - """ - if not hasattr(self, '_image_manager'): - self._image_manager = Registry().get('image_manager') - return self._image_manager - - image_manager = property(_get_image_manager) - - def _get_application(self): - """ - Adds the openlp to the class dynamically. - Windows needs to access the application in a dynamic manner. - """ - if os.name == 'nt': - return Registry().get('application') - else: - if not hasattr(self, '_application'): - self._application = Registry().get('application') - return self._application - - application = property(_get_application) - - def _get_live_controller(self): - """ - Adds the live controller to the class dynamically - """ - if not hasattr(self, '_live_controller'): - self._live_controller = Registry().get('live_controller') - return self._live_controller - - live_controller = property(_get_live_controller) - class AudioPlayer(OpenLPMixin, QtCore.QObject): """ @@ -522,8 +477,7 @@ class AudioPlayer(OpenLPMixin, QtCore.QObject): """ The constructor for the display form. - ``parent`` - The parent widget. + :param parent: The parent widget. """ super(AudioPlayer, self).__init__(parent) self.current_index = -1 diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 29213c2af..3526e551f 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -493,13 +493,13 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): Settings().set_up_default_values() self.about_form = AboutForm(self) MediaController() - self.settings_form = SettingsForm(self) + SettingsForm(self) self.formatting_tag_form = FormattingTagForm(self) self.shortcut_form = ShortcutListForm(self) # Set up the path with plugins PluginManager(self) ImageManager() - self.renderer = Renderer() + Renderer() # Set up the interface self.setupUi(self) # Define the media Dock Manager @@ -697,11 +697,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): """ Display an error message - ``title`` - The title of the warning box. - - ``message`` - The message to be displayed. + :param title: The title of the warning box. + :param message: The message to be displayed. """ if hasattr(self.application, 'splash'): self.application.splash.close() @@ -711,11 +708,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): """ Display a warning message - ``title`` - The title of the warning box. - - ``message`` - The message to be displayed. + :param title: The title of the warning box. + :param message: The message to be displayed. """ if hasattr(self.application, 'splash'): self.application.splash.close() @@ -725,11 +719,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): """ Display an informational message - ``title`` - The title of the warning box. - - ``message`` - The message to be displayed. + :param title: The title of the warning box. + :param message: The message to be displayed. """ if hasattr(self.application, 'splash'): self.application.splash.close() @@ -1067,8 +1058,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): """ Runs all the cleanup code before OpenLP shuts down. - ``save_settings`` - Switch to prevent saving settings. Defaults to **True**. + :param save_settings: Switch to prevent saving settings. Defaults to **True**. """ self.image_manager.stop_manager = True while self.image_manager.image_thread.isRunning(): @@ -1099,11 +1089,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): """ This method is called from the ServiceManager to set the title of the main window. - ``modified`` - Whether or not this service has been modified. - - ``file_name`` - The file name of the service file. + :param modified: Whether or not this service has been modified. + :param file_name: The file name of the service file. """ if modified: title = '%s - %s*' % (UiStrings().OLPV2x, file_name) @@ -1146,10 +1133,10 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): """ Sets the visibility of the preview panel including saving the setting and updating the menu. - ``visible`` - A bool giving the state to set the panel to + :param visible: A bool giving the state to set the panel to True - Visible False - Hidden + """ self.preview_controller.panel.setVisible(visible) Settings().setValue('user interface/preview panel', visible) @@ -1183,8 +1170,8 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): """ Sets the visibility of the live panel including saving the setting and updating the menu. - ``visible`` - A bool giving the state to set the panel to + + :param visible: A bool giving the state to set the panel to True - Visible False - Hidden """ @@ -1266,8 +1253,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow, RegistryProperties): """ Adds a service to the list of recently used files. - ``filename`` - The service filename to add + :param filename: The service filename to add """ # The max_recent_files value does not have an interface and so never gets # actually stored in the settings therefore the default value of 20 will diff --git a/openlp/core/ui/media/__init__.py b/openlp/core/ui/media/__init__.py index b915e8beb..1276c8662 100644 --- a/openlp/core/ui/media/__init__.py +++ b/openlp/core/ui/media/__init__.py @@ -96,14 +96,10 @@ def get_media_players(): def set_media_players(players_list, overridden_player='auto'): """ - This method saves the configured media players and overridden player to the - settings + This method saves the configured media players and overridden player to the settings - ``players_list`` - A list with all active media players. - - ``overridden_player`` - Here an special media player is chosen for all media actions. + :param players_list: A list with all active media players. + :param overridden_player: Here an special media player is chosen for all media actions. """ log.debug('set_media_players') players = ','.join(players_list) diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index ac52700a1..54cc6cdf8 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -35,7 +35,7 @@ import os import datetime from PyQt4 import QtCore, QtGui -from openlp.core.common import Registry, RegistryMixin, Settings, UiStrings, translate +from openlp.core.common import OpenLPMixin, Registry, RegistryMixin, RegistryProperties, Settings, UiStrings, translate from openlp.core.lib import OpenLPToolbar from openlp.core.lib.ui import critical_error_message_box from openlp.core.ui.media import MediaState, MediaInfo, MediaType, get_media_players, set_media_players @@ -80,26 +80,24 @@ class MediaSlider(QtGui.QSlider): QtGui.QSlider.mouseReleaseEvent(self, event) -class MediaController(object): +class MediaController(RegistryMixin, OpenLPMixin, RegistryProperties): """ - The implementation of the Media Controller. The Media Controller adds an own - class for every Player. Currently these are QtWebkit, Phonon and Vlc. + The implementation of the Media Controller. The Media Controller adds an own class for every Player. + Currently these are QtWebkit, Phonon and Vlc. display_controllers are an array of controllers keyed on the + slidecontroller or plugin which built them. - display_controllers are an array of controllers keyed on the - slidecontroller or plugin which built them. ControllerType is the class - containing the key values. + ControllerType is the class containing the key values. media_players are an array of media players keyed on player name. current_media_players is an array of player instances keyed on ControllerType. """ - def __init__(self): + def __init__(self, parent=None): """ Constructor """ - Registry().register('media_controller', self) - Registry().register_function('bootstrap_initialise', self.bootstrap_initialise) + super(MediaController, self).__init__(parent) self.media_players = {} self.display_controllers = {} self.current_media_players = {} @@ -156,8 +154,7 @@ class MediaController(object): Register each media Player (Webkit, Phonon, etc) and store for later use - ``player`` - Individual player class which has been enabled + :param player: Individual player class which has been enabled """ self.media_players[player.name] = player @@ -199,8 +196,7 @@ class MediaController(object): def media_state(self): """ - Check if there is a running media Player and do updating stuff (e.g. - update the UI) + Check if there is a running media Player and do updating stuff (e.g. update the UI) """ if not list(self.current_media_players.keys()): self.timer.stop() @@ -256,8 +252,7 @@ class MediaController(object): """ Registers media controls where the players will be placed to run. - ``controller`` - The controller where a player will be placed + :param controller: The controller where a player will be placed """ self.display_controllers[controller.controller_type] = controller self.setup_generic_controls(controller) @@ -266,8 +261,7 @@ class MediaController(object): """ Set up controls on the control_panel for a given controller - ``controller`` - First element is the controller which should be used + :param controller: First element is the controller which should be used """ controller.media_info = MediaInfo() # Build a Media ToolBar @@ -313,14 +307,10 @@ class MediaController(object): def setup_display(self, display, preview): """ - After a new display is configured, all media related widgets will be - created too + After a new display is configured, all media related widgets will be created too - ``display`` - Display on which the output is to be played - - ``preview`` - Whether the display is a main or preview display + :param display: Display on which the output is to be played + :param preview: Whether the display is a main or preview display """ # clean up possible running old media files self.finalise() @@ -337,14 +327,10 @@ class MediaController(object): def set_controls_visible(self, controller, value): """ - After a new display is configured, all media related widget will be - created too + After a new display is configured, all media related widget will be created too - ``controller`` - The controller on which controls act. - - ``value`` - control name to be changed. + :param controller: The controller on which controls act. + :param value: control name to be changed. """ # Generic controls controller.mediabar.setVisible(value) @@ -355,14 +341,10 @@ class MediaController(object): def resize(self, display, player): """ - After Mainwindow changes or Splitter moved all related media widgets - have to be resized + After Mainwindow changes or Splitter moved all related media widgets have to be resized - ``display`` - The display on which output is playing. - - ``player`` - The player which is doing the playing. + :param display: The display on which output is playing. + :param player: The player which is doing the playing. """ player.resize(display) @@ -370,17 +352,10 @@ class MediaController(object): """ Loads and starts a video to run with the option of sound - ``source`` - Where the call originated form - - ``service_item`` - The player which is doing the playing - - ``hidden`` - The player which is doing the playing - - ``video_behind_text`` - Is the video to be played behind text. + :param source: Where the call originated form + :param service_item: The player which is doing the playing + :param hidden: The player which is doing the playing + :param video_behind_text: Is the video to be played behind text. """ log.debug('video') is_valid = False @@ -437,8 +412,7 @@ class MediaController(object): """ Loads and starts a media item to obtain the media length - ``service_item`` - The ServiceItem containing the details to be played. + :param service_item: The ServiceItem containing the details to be played. """ controller = self.display_controllers[DisplayControllerType.Plugin] log.debug('media_length') @@ -466,11 +440,9 @@ class MediaController(object): """ Select the correct media Player type from the prioritized Player list - ``controller`` - First element is the controller which should be used - - ``service_item`` - The ServiceItem containing the details to be played. + :param controller: First element is the controller which should be used + :param display: Which display to use + :param service_item: The ServiceItem containing the details to be played. """ used_players = get_media_players()[0] if service_item.processor != UiStrings().Automatic: @@ -508,8 +480,8 @@ class MediaController(object): """ Responds to the request to play a loaded video - ``msg`` - First element is the controller which should be used + :param msg: First element is the controller which should be used + :param status: """ log.debug('media_play_msg') self.media_play(msg[0], status) @@ -518,8 +490,8 @@ class MediaController(object): """ Responds to the request to play a loaded video - ``controller`` - The controller to be played + :param controller: The controller to be played + :param status: """ log.debug('media_play') controller.seek_slider.blockSignals(True) @@ -558,8 +530,7 @@ class MediaController(object): """ Responds to the request to pause a loaded video - ``msg`` - First element is the controller which should be used + :param msg: First element is the controller which should be used """ log.debug('media_pause_msg') self.media_pause(msg[0]) @@ -568,8 +539,7 @@ class MediaController(object): """ Responds to the request to pause a loaded video - ``controller`` - The Controller to be paused + :param controller: The Controller to be paused """ log.debug('media_pause') display = self._define_display(controller) @@ -582,8 +552,7 @@ class MediaController(object): """ Responds to the request to stop a loaded video - ``msg`` - First element is the controller which should be used + :param msg: First element is the controller which should be used """ log.debug('media_stop_msg') self.media_stop(msg[0]) @@ -592,8 +561,7 @@ class MediaController(object): """ Responds to the request to stop a loaded video - ``controller`` - The controller that needs to be stopped + :param controller: The controller that needs to be stopped """ log.debug('media_stop') display = self._define_display(controller) @@ -610,8 +578,7 @@ class MediaController(object): """ Changes the volume of a running video - ``msg`` - First element is the controller which should be used + :param msg: First element is the controller which should be used """ controller = msg[0] vol = msg[1][0] @@ -621,8 +588,8 @@ class MediaController(object): """ Changes the volume of a running video - ``msg`` - First element is the controller which should be used + :param controller: The Controller to use + :param volume: The volume to be set """ log.debug('media_volume %d' % volume) display = self._define_display(controller) @@ -633,8 +600,7 @@ class MediaController(object): """ Responds to the request to change the seek Slider of a loaded video via a message - ``msg`` - First element is the controller which should be used + :param msg: First element is the controller which should be used Second element is a list with the seek value as first element """ log.debug('media_seek') @@ -646,12 +612,8 @@ class MediaController(object): """ Responds to the request to change the seek Slider of a loaded video - ``controller`` - The controller to use. - - ``seek_value`` - The value to set. - + :param controller: The controller to use. + :param seek_value: The value to set. """ log.debug('media_seek') display = self._define_display(controller) @@ -675,8 +637,7 @@ class MediaController(object): """ Hide the related video Widget - ``msg`` - First element is the boolean for Live indication + :param msg: First element is the boolean for Live indication """ is_live = msg[1] if not is_live: @@ -691,8 +652,7 @@ class MediaController(object): """ Blank the related video Widget - ``msg`` - First element is the boolean for Live indication + :param msg: First element is the boolean for Live indication Second element is the hide mode """ is_live = msg[1] @@ -709,8 +669,7 @@ class MediaController(object): """ Unblank the related video Widget - ``msg`` - First element is not relevant in this context + :param msg: First element is not relevant in this context Second element is the boolean for Live indication """ Registry().execute('live_display_show') @@ -738,29 +697,8 @@ class MediaController(object): """ Extract the correct display for a given controller - ``controller`` - Controller to be used + :param controller: Controller to be used """ if controller.is_live: return controller.display - return controller.preview_display - - def _get_service_manager(self): - """ - Adds the plugin manager to the class dynamically - """ - if not hasattr(self, '_service_manager'): - self._service_manager = Registry().get('service_manager') - return self._service_manager - - service_manager = property(_get_service_manager) - - def _get_live_controller(self): - """ - Adds the live controller to the class dynamically - """ - if not hasattr(self, '_live_controller'): - self._live_controller = Registry().get('live_controller') - return self._live_controller - - live_controller = property(_get_live_controller) + return controller.preview_display \ No newline at end of file diff --git a/openlp/core/ui/media/mediaplayer.py b/openlp/core/ui/media/mediaplayer.py index 3aa0c1fbf..49b699034 100644 --- a/openlp/core/ui/media/mediaplayer.py +++ b/openlp/core/ui/media/mediaplayer.py @@ -31,11 +31,11 @@ The :mod:`~openlp.core.ui.media.mediaplayer` module contains the MediaPlayer cla """ import os -from openlp.core.common import Registry +from openlp.core.common import RegistryProperties from openlp.core.ui.media import MediaState -class MediaPlayer(object): +class MediaPlayer(RegistryProperties): """ This is the base class media Player class to provide OpenLP with a pluggable media display framework. """ @@ -150,18 +150,4 @@ class MediaPlayer(object): """ Returns Information about the player """ - return '' - - def _get_application(self): - """ - Adds the openlp to the class dynamically. - Windows needs to access the application in a dynamic manner. - """ - if os.name == 'nt': - return Registry().get('application') - else: - if not hasattr(self, '_application'): - self._application = Registry().get('application') - return self._application - - application = property(_get_application) \ No newline at end of file + return '' \ No newline at end of file diff --git a/openlp/core/ui/media/phononplayer.py b/openlp/core/ui/media/phononplayer.py index 5a2d29223..d08628004 100644 --- a/openlp/core/ui/media/phononplayer.py +++ b/openlp/core/ui/media/phononplayer.py @@ -66,10 +66,8 @@ ADDITIONAL_EXT = { class PhononPlayer(MediaPlayer): """ - A specialised version of the MediaPlayer class, which provides a Phonon - display. + A specialised version of the MediaPlayer class, which provides a Phonon display. """ - def __init__(self, parent): """ Constructor @@ -83,11 +81,11 @@ class PhononPlayer(MediaPlayer): for mime_type in Phonon.BackendCapabilities.availableMimeTypes(): mime_type = str(mime_type) if mime_type.startswith('audio/'): - self._addToList(self.audio_extensions_list, mime_type) + self._add_to_list(self.audio_extensions_list, mime_type) elif mime_type.startswith('video/'): - self._addToList(self.video_extensions_list, mime_type) + self._add_to_list(self.video_extensions_list, mime_type) - def _addToList(self, mimetype_list, mimetype): + def _add_to_list(self, mime_type_list, mimetype): """ Add mimetypes to the provided list """ @@ -95,8 +93,8 @@ class PhononPlayer(MediaPlayer): extensions = mimetypes.guess_all_extensions(str(mimetype)) for extension in extensions: ext = '*%s' % extension - if ext not in mimetype_list: - mimetype_list.append(ext) + if ext not in mime_type_list: + mime_type_list.append(ext) log.info('MediaPlugin: %s extensions: %s' % (mimetype, ' '.join(extensions))) # Add extensions for this mimetype from self.additional_extensions. # This hack clears mimetypes' and operating system's shortcomings @@ -104,8 +102,8 @@ class PhononPlayer(MediaPlayer): if mimetype in list(self.additional_extensions.keys()): for extension in self.additional_extensions[mimetype]: ext = '*%s' % extension - if ext not in mimetype_list: - mimetype_list.append(ext) + if ext not in mime_type_list: + mime_type_list.append(ext) log.info('MediaPlugin: %s additional extensions: %s' % (mimetype, ' '.join(self.additional_extensions[mimetype]))) diff --git a/openlp/core/ui/media/playertab.py b/openlp/core/ui/media/playertab.py index 566071f30..09bac5125 100644 --- a/openlp/core/ui/media/playertab.py +++ b/openlp/core/ui/media/playertab.py @@ -99,11 +99,11 @@ class PlayerTab(SettingsTab): self.player_order_layout = QtGui.QHBoxLayout(self.player_order_group_box) self.player_order_layout.setObjectName('player_order_layout') self.player_order_list_widget = QtGui.QListWidget(self.player_order_group_box) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.player_order_list_widget.sizePolicy().hasHeightForWidth()) - self.player_order_list_widget.setSizePolicy(sizePolicy) + size_policy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + size_policy.setHorizontalStretch(0) + size_policy.setVerticalStretch(0) + size_policy.setHeightForWidth(self.player_order_list_widget.sizePolicy().hasHeightForWidth()) + self.player_order_list_widget.setSizePolicy(size_policy) self.player_order_list_widget.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) self.player_order_list_widget.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.player_order_list_widget.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers) diff --git a/openlp/core/ui/mediadockmanager.py b/openlp/core/ui/mediadockmanager.py index efdf710f0..34c605ab0 100644 --- a/openlp/core/ui/mediadockmanager.py +++ b/openlp/core/ui/mediadockmanager.py @@ -50,11 +50,9 @@ class MediaDockManager(object): """ Add a MediaManagerItem to the dock - ``media_item`` - The item to add to the dock - - ``icon`` - An icon for this dock item + :param media_item: The item to add to the dock + :param icon: An icon for this dock item + :param weight: """ visible_title = media_item.plugin.get_string(StringContent.VisibleName) log.info('Adding %s dock' % visible_title) @@ -80,8 +78,7 @@ class MediaDockManager(object): """ Removes a MediaManagerItem from the dock - ``media_item`` - The item to add to the dock + :param media_item: The item to add to the dock """ visible_title = media_item.plugin.get_string(StringContent.VisibleName) log.debug('remove %s dock' % visible_title['title']) diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index 8196f0242..9e6ac9663 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -34,14 +34,14 @@ import os from PyQt4 import QtGui -from openlp.core.common import Registry, translate +from openlp.core.common import RegistryProperties, translate from openlp.core.lib import PluginStatus from .plugindialog import Ui_PluginViewDialog log = logging.getLogger(__name__) -class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): +class PluginForm(QtGui.QDialog, Ui_PluginViewDialog, RegistryProperties): """ The plugin form provides user control over the plugins OpenLP uses. """ @@ -154,28 +154,4 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): elif self.active_plugin.status == PluginStatus.Disabled: status_text = translate('OpenLP.PluginForm', '%s (Disabled)') self.plugin_list_widget.currentItem().setText( - status_text % self.active_plugin.name_strings['singular']) - - def _get_plugin_manager(self): - """ - Adds the plugin manager to the class dynamically - """ - if not hasattr(self, '_plugin_manager'): - self._plugin_manager = Registry().get('plugin_manager') - return self._plugin_manager - - plugin_manager = property(_get_plugin_manager) - - def _get_application(self): - """ - Adds the openlp to the class dynamically. - Windows needs to access the application in a dynamic manner. - """ - if os.name == 'nt': - return Registry().get('application') - else: - if not hasattr(self, '_application'): - self._application = Registry().get('application') - return self._application - - application = property(_get_application) + status_text % self.active_plugin.name_strings['singular']) \ No newline at end of file diff --git a/openlp/core/ui/printserviceform.py b/openlp/core/ui/printserviceform.py index 3a6fbe8c1..753bb2a04 100644 --- a/openlp/core/ui/printserviceform.py +++ b/openlp/core/ui/printserviceform.py @@ -36,7 +36,7 @@ import lxml.html from PyQt4 import QtCore, QtGui -from openlp.core.common import Registry, Settings, UiStrings, translate +from openlp.core.common import Registry, RegistryProperties, Settings, UiStrings, translate from openlp.core.lib import get_text_file_string from openlp.core.ui.printservicedialog import Ui_PrintServiceDialog, ZoomSize from openlp.core.common import AppLocation @@ -111,7 +111,7 @@ http://doc.trolltech.com/4.7/richtext-html-subset.html#css-properties """ -class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): +class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog, RegistryProperties): """ The :class:`~openlp.core.ui.printserviceform.PrintServiceForm` class displays a dialog for printing the service. """ @@ -239,23 +239,14 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): def _add_element(self, tag, text=None, parent=None, classId=None, attribute=None): """ - Creates a html element. If ``text`` is given, the element's text will - set and if a ``parent`` is given, the element is appended. + Creates a html element. If ``text`` is given, the element's text will set and if a ``parent`` is given, + the element is appended. - ``tag`` - The html tag, e. g. ``u'span'``. Defaults to ``None``. - - ``text`` - The text for the tag. Defaults to ``None``. - - ``parent`` - The parent element. Defaults to ``None``. - - ``classId`` - Value for the class attribute - - ``attribute`` - Tuple name/value pair to add as an optional attribute + :param tag: The html tag, e. g. ``u'span'``. Defaults to ``None``. + :param text: The text for the tag. Defaults to ``None``. + :param parent: The parent element. Defaults to ``None``. + :param classId: Value for the class attribute + :param attribute: Tuple name/value pair to add as an optional attribute """ if text is not None: element = lxml.html.fragment_fromstring(str(text), create_parent=tag) @@ -403,24 +394,4 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): return for item in self.service_manager.service_items: # Trigger Audit requests - Registry().register_function('print_service_started', [item['service_item']]) - - def _get_service_manager(self): - """ - Adds the service manager to the class dynamically - """ - if not hasattr(self, '_service_manager'): - self._service_manager = Registry().get('service_manager') - return self._service_manager - - service_manager = property(_get_service_manager) - - def _get_main_window(self): - """ - Adds the main window to the class dynamically - """ - if not hasattr(self, '_main_window'): - self._main_window = Registry().get('main_window') - return self._main_window - - main_window = property(_get_main_window) + Registry().register_function('print_service_started', [item['service_item']]) \ No newline at end of file diff --git a/openlp/core/ui/serviceitemeditform.py b/openlp/core/ui/serviceitemeditform.py index cf1753fa7..1259516e9 100644 --- a/openlp/core/ui/serviceitemeditform.py +++ b/openlp/core/ui/serviceitemeditform.py @@ -30,12 +30,12 @@ The service item edit dialog """ from PyQt4 import QtGui -from openlp.core.common import Registry +from openlp.core.common import Registry, RegistryProperties from .serviceitemeditdialog import Ui_ServiceItemEditDialog -class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog): +class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog, RegistryProperties): """ This is the form that is used to edit the verses of the song. """ @@ -131,8 +131,7 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog): """ Called when the currentRow has changed. - ``row`` - The row number (int). + :param row: The row number (int). """ # Disable all buttons, as no row is selected or only one image is left. if row == -1 or self.list_widget.count() == 1: @@ -151,14 +150,3 @@ class ServiceItemEditForm(QtGui.QDialog, Ui_ServiceItemEditDialog): else: self.up_button.setEnabled(True) self.delete_button.setEnabled(True) - - def _get_main_window(self): - """ - Adds the main window to the class dynamically - """ - if not hasattr(self, '_main_window'): - self._main_window = Registry().get('main_window') - return self._main_window - - main_window = property(_get_main_window) - diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index c5c9c7002..6375e4803 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -39,8 +39,8 @@ from datetime import datetime, timedelta from PyQt4 import QtCore, QtGui -from openlp.core.common import Registry, AppLocation, Settings, ThemeLevel, OpenLPMixin, RegistryMixin, \ - check_directory_exists, UiStrings, translate +from openlp.core.common import Registry, RegistryProperties, AppLocation, Settings, ThemeLevel, OpenLPMixin, \ + RegistryMixin, check_directory_exists, UiStrings, translate from openlp.core.lib import OpenLPToolbar, ServiceItem, ItemCapabilities, PluginStatus, build_icon from openlp.core.lib.ui import critical_error_message_box, create_widget_action, find_and_set_in_combo_box from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm, StartTimeForm @@ -306,7 +306,7 @@ class Ui_ServiceManager(object): event.accept() -class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManager): +class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManager, RegistryProperties): """ Manages the services. This involves taking text strings from plugins and adding them to the service. This service can then be zipped up with all the resources used into one OSZ or oszl file for use on any OpenLP v2 installation. @@ -1639,68 +1639,4 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage Print a Service Order Sheet. """ setting_dialog = PrintServiceForm() - setting_dialog.exec_() - - def _get_renderer(self): - """ - Adds the Renderer to the class dynamically - """ - if not hasattr(self, '_renderer'): - self._renderer = Registry().get('renderer') - return self._renderer - - renderer = property(_get_renderer) - - def _get_live_controller(self): - """ - Adds the live controller to the class dynamically - """ - if not hasattr(self, '_live_controller'): - self._live_controller = Registry().get('live_controller') - return self._live_controller - - live_controller = property(_get_live_controller) - - def _get_preview_controller(self): - """ - Adds the preview controller to the class dynamically - """ - if not hasattr(self, '_preview_controller'): - self._preview_controller = Registry().get('preview_controller') - return self._preview_controller - - preview_controller = property(_get_preview_controller) - - def _get_plugin_manager(self): - """ - Adds the plugin manager to the class dynamically - """ - if not hasattr(self, '_plugin_manager'): - self._plugin_manager = Registry().get('plugin_manager') - return self._plugin_manager - - plugin_manager = property(_get_plugin_manager) - - def _get_main_window(self): - """ - Adds the main window to the class dynamically - """ - if not hasattr(self, '_main_window'): - self._main_window = Registry().get('main_window') - return self._main_window - - main_window = property(_get_main_window) - - def _get_application(self): - """ - Adds the openlp to the class dynamically. - Windows needs to access the application in a dynamic manner. - """ - if os.name == 'nt': - return Registry().get('application') - else: - if not hasattr(self, '_application'): - self._application = Registry().get('application') - return self._application - - application = property(_get_application) + setting_dialog.exec_() \ No newline at end of file diff --git a/openlp/core/ui/servicenoteform.py b/openlp/core/ui/servicenoteform.py index 0e5867772..ee24cf7cf 100644 --- a/openlp/core/ui/servicenoteform.py +++ b/openlp/core/ui/servicenoteform.py @@ -31,12 +31,12 @@ The :mod:`~openlp.core.ui.servicenoteform` module contains the `ServiceNoteForm` """ from PyQt4 import QtGui -from openlp.core.common import Registry, translate +from openlp.core.common import Registry, RegistryProperties, translate from openlp.core.lib import SpellTextEdit from openlp.core.lib.ui import create_button_box -class ServiceNoteForm(QtGui.QDialog): +class ServiceNoteForm(QtGui.QDialog, RegistryProperties): """ This is the form that is used to edit the verses of the song. """ @@ -74,14 +74,4 @@ class ServiceNoteForm(QtGui.QDialog): """ Translate the UI on the fly """ - self.setWindowTitle(translate('OpenLP.ServiceNoteForm', 'Service Item Notes')) - - def _get_main_window(self): - """ - Adds the main window to the class dynamically - """ - if not hasattr(self, '_main_window'): - self._main_window = Registry().get('main_window') - return self._main_window - - main_window = property(_get_main_window) + self.setWindowTitle(translate('OpenLP.ServiceNoteForm', 'Service Item Notes')) \ No newline at end of file diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index d220fb70d..68b0b3b41 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -33,7 +33,7 @@ import logging from PyQt4 import QtGui -from openlp.core.common import Registry +from openlp.core.common import Registry, RegistryProperties from openlp.core.lib import PluginStatus, build_icon from openlp.core.ui import AdvancedTab, GeneralTab, ThemesTab from openlp.core.ui.media import PlayerTab @@ -42,7 +42,7 @@ from .settingsdialog import Ui_SettingsDialog log = logging.getLogger(__name__) -class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): +class SettingsForm(QtGui.QDialog, Ui_SettingsDialog, RegistryProperties): """ Provide the form to manipulate the settings for OpenLP """ @@ -148,38 +148,7 @@ class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): """ Register for updates to be done on save removing duplicate functions - ``function`` - The function to be called + :param function: The function to be called """ if not function in self.processes: - self.processes.append(function) - - def _get_main_window(self): - """ - Adds the main window to the class dynamically - """ - if not hasattr(self, '_main_window'): - self._main_window = Registry().get('main_window') - return self._main_window - - main_window = property(_get_main_window) - - def _get_service_manager(self): - """ - Adds the plugin manager to the class dynamically - """ - if not hasattr(self, '_service_manager'): - self._service_manager = Registry().get('service_manager') - return self._service_manager - - service_manager = property(_get_service_manager) - - def _get_plugin_manager(self): - """ - Adds the plugin manager to the class dynamically - """ - if not hasattr(self, '_plugin_manager'): - self._plugin_manager = Registry().get('plugin_manager') - return self._plugin_manager - - plugin_manager = property(_get_plugin_manager) + self.processes.append(function) \ No newline at end of file diff --git a/openlp/core/ui/shortcutlistform.py b/openlp/core/ui/shortcutlistform.py index f2c67882f..a8e4c6ba1 100644 --- a/openlp/core/ui/shortcutlistform.py +++ b/openlp/core/ui/shortcutlistform.py @@ -33,7 +33,7 @@ import re from PyQt4 import QtCore, QtGui -from openlp.core.common import Registry, Settings, translate +from openlp.core.common import RegistryProperties, Settings, translate from openlp.core.utils.actions import ActionList from .shortcutlistdialog import Ui_ShortcutListDialog @@ -42,7 +42,7 @@ REMOVE_AMPERSAND = re.compile(r'&{1}') log = logging.getLogger(__name__) -class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): +class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog, RegistryProperties): """ The shortcut list dialog """ @@ -397,11 +397,8 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): Checks if the given ``changing_action `` can use the given ``key_sequence``. Returns ``True`` if the ``key_sequence`` can be used by the action, otherwise displays a dialog and returns ``False``. - ``changing_action`` - The action which wants to use the ``key_sequence``. - - ``key_sequence`` - The key sequence which the action want so use. + :param changing_action: The action which wants to use the ``key_sequence``. + :param key_sequence: The key sequence which the action want so use. """ is_valid = True for category in self.action_list.categories: @@ -462,14 +459,3 @@ class ShortcutListForm(QtGui.QDialog, Ui_ShortcutListDialog): button.setChecked(checked) if enabled is not None: button.setEnabled(enabled) - - def _get_main_window(self): - """ - Adds the main window to the class dynamically - """ - if not hasattr(self, '_main_window'): - self._main_window = Registry().get('main_window') - return self._main_window - - main_window = property(_get_main_window) - diff --git a/openlp/core/ui/starttimeform.py b/openlp/core/ui/starttimeform.py index d1be55d7a..4ee9e565c 100644 --- a/openlp/core/ui/starttimeform.py +++ b/openlp/core/ui/starttimeform.py @@ -33,11 +33,11 @@ from PyQt4 import QtGui from .starttimedialog import Ui_StartTimeDialog -from openlp.core.common import Registry, UiStrings, translate +from openlp.core.common import Registry, RegistryProperties, UiStrings, translate from openlp.core.lib.ui import critical_error_message_box -class StartTimeForm(QtGui.QDialog, Ui_StartTimeDialog): +class StartTimeForm(QtGui.QDialog, Ui_StartTimeDialog, RegistryProperties): """ The start time dialog """ @@ -88,20 +88,10 @@ class StartTimeForm(QtGui.QDialog, Ui_StartTimeDialog): def _time_split(self, seconds): """ - Split time up into hours minutes and seconds from secongs + Split time up into hours minutes and seconds from seconds """ hours = seconds // 3600 seconds -= 3600 * hours minutes = seconds // 60 seconds -= 60 * minutes - return hours, minutes, seconds - - def _get_main_window(self): - """ - Adds the main window to the class dynamically - """ - if not hasattr(self, '_main_window'): - self._main_window = Registry().get('main_window') - return self._main_window - - main_window = property(_get_main_window) + return hours, minutes, seconds \ No newline at end of file diff --git a/openlp/core/ui/themeform.py b/openlp/core/ui/themeform.py index a8b6aabd2..7cb53e47b 100644 --- a/openlp/core/ui/themeform.py +++ b/openlp/core/ui/themeform.py @@ -34,7 +34,7 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.common import Registry, UiStrings, translate +from openlp.core.common import Registry, RegistryProperties, UiStrings, translate from openlp.core.lib.theme import BackgroundType, BackgroundGradientType from openlp.core.lib.ui import critical_error_message_box from openlp.core.ui import ThemeLayoutForm @@ -44,7 +44,7 @@ from .themewizard import Ui_ThemeWizard log = logging.getLogger(__name__) -class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): +class ThemeForm(QtGui.QWizard, Ui_ThemeWizard, RegistryProperties): """ This is the Theme Import Wizard, which allows easy creation and editing of OpenLP themes. @@ -55,8 +55,7 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): """ Instantiate the wizard, and run any extra setup we need to. - ``parent`` - The QWidget-derived parent of the wizard. + :param parent: The QWidget-derived parent of the wizard. """ super(ThemeForm, self).__init__(parent) self.setupUi(self) @@ -541,24 +540,4 @@ class ThemeForm(QtGui.QWizard, Ui_ThemeWizard): new_color = QtGui.QColorDialog.getColor(QtGui.QColor(field), self) if new_color.isValid(): field = new_color.name() - return field - - def _get_renderer(self): - """ - Adds the Renderer to the class dynamically - """ - if not hasattr(self, '_renderer'): - self._renderer = Registry().get('renderer') - return self._renderer - - renderer = property(_get_renderer) - - def _get_theme_manager(self): - """ - Adds the theme manager to the class dynamically - """ - if not hasattr(self, '_theme_manager'): - self._theme_manager = Registry().get('theme_manager') - return self._theme_manager - - theme_manager = property(_get_theme_manager) + return field \ No newline at end of file diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 777a3e014..98c2198c7 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -36,8 +36,8 @@ import shutil from xml.etree.ElementTree import ElementTree, XML from PyQt4 import QtCore, QtGui -from openlp.core.common import Registry, AppLocation, Settings, OpenLPMixin, RegistryMixin, check_directory_exists, \ - UiStrings, translate +from openlp.core.common import Registry, RegistryProperties, AppLocation, Settings, OpenLPMixin, RegistryMixin, \ + check_directory_exists, UiStrings, translate from openlp.core.lib import FileDialog, ImageSource, OpenLPToolbar, get_text_file_string, build_icon, \ check_item_selected, create_thumb, validate_thumb from openlp.core.lib.theme import ThemeXML, BackgroundType @@ -127,7 +127,7 @@ class Ui_ThemeManager(object): self.theme_list_widget.currentItemChanged.connect(self.check_list_state) -class ThemeManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ThemeManager): +class ThemeManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ThemeManager, RegistryProperties): """ Manages the orders of Theme. """ @@ -753,58 +753,4 @@ class ThemeManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ThemeManager): % (theme, plugin.name)) return False return True - return False - - def _get_renderer(self): - """ - Adds the Renderer to the class dynamically - """ - if not hasattr(self, '_renderer'): - self._renderer = Registry().get('renderer') - return self._renderer - - renderer = property(_get_renderer) - - def _get_image_manager(self): - """ - Adds the image manager to the class dynamically - """ - if not hasattr(self, '_image_manager'): - self._image_manager = Registry().get('image_manager') - return self._image_manager - - image_manager = property(_get_image_manager) - - def _get_plugin_manager(self): - """ - Adds the Renderer to the class dynamically - """ - if not hasattr(self, '_plugin_manager'): - self._plugin_manager = Registry().get('plugin_manager') - return self._plugin_manager - - plugin_manager = property(_get_plugin_manager) - - def _get_main_window(self): - """ - Adds the main window to the class dynamically - """ - if not hasattr(self, '_main_window'): - self._main_window = Registry().get('main_window') - return self._main_window - - main_window = property(_get_main_window) - - def _get_application(self): - """ - Adds the openlp to the class dynamically. - Windows needs to access the application in a dynamic manner. - """ - if os.name == 'nt': - return Registry().get('application') - else: - if not hasattr(self, '_application'): - self._application = Registry().get('application') - return self._application - - application = property(_get_application) + return False \ No newline at end of file diff --git a/openlp/core/ui/themestab.py b/openlp/core/ui/themestab.py index f754d626c..32ed30303 100644 --- a/openlp/core/ui/themestab.py +++ b/openlp/core/ui/themestab.py @@ -186,8 +186,7 @@ class ThemesTab(SettingsTab): """ Called from ThemeManager when the Themes have changed. - ``theme_list`` - The list of available themes:: + :param theme_list: The list of available themes:: [u'Bible Theme', u'Song Theme'] """ diff --git a/openlp/core/ui/wizard.py b/openlp/core/ui/wizard.py index 87fed2a54..4d9b4ebdf 100644 --- a/openlp/core/ui/wizard.py +++ b/openlp/core/ui/wizard.py @@ -34,7 +34,7 @@ import os from PyQt4 import QtGui -from openlp.core.common import Registry, Settings, UiStrings, translate +from openlp.core.common import Registry, RegistryProperties, Settings, UiStrings, translate from openlp.core.lib import build_icon from openlp.core.lib.ui import add_welcome_page @@ -64,15 +64,15 @@ class WizardStrings(object): PercentSymbolFormat = translate('OpenLP.Ui', '%p%') Ready = translate('OpenLP.Ui', 'Ready.') StartingImport = translate('OpenLP.Ui', 'Starting import...') - YouSpecifyFile = translate('OpenLP.Ui', 'You need to specify one ' - '%s file to import from.', 'A file type e.g. OpenSong') - YouSpecifyFiles = translate('OpenLP.Ui', 'You need to specify at ' - 'least one %s file to import from.', 'A file type e.g. OpenSong') - YouSpecifyFolder = translate('OpenLP.Ui', 'You need to specify one ' - '%s folder to import from.', 'A song format e.g. PowerSong') + YouSpecifyFile = translate('OpenLP.Ui', 'You need to specify one %s file to import from.', + 'A file type e.g. OpenSong') + YouSpecifyFiles = translate('OpenLP.Ui', 'You need to specify at least one %s file to import from.', + 'A file type e.g. OpenSong') + YouSpecifyFolder = translate('OpenLP.Ui', 'You need to specify one %s folder to import from.', + 'A song format e.g. PowerSong') -class OpenLPWizard(QtGui.QWizard): +class OpenLPWizard(QtGui.QWizard, RegistryProperties): """ Generic OpenLP wizard to provide generic functionality and a unified look and feel. @@ -121,7 +121,7 @@ class OpenLPWizard(QtGui.QWizard): self.setModal(True) self.setWizardStyle(QtGui.QWizard.ModernStyle) self.setOptions(QtGui.QWizard.IndependentPages | - QtGui.QWizard.NoBackButtonOnStartPage | QtGui.QWizard.NoBackButtonOnLastPage) + QtGui.QWizard.NoBackButtonOnStartPage | QtGui.QWizard.NoBackButtonOnLastPage) add_welcome_page(self, image) self.add_custom_pages() if self.with_progress_page: @@ -209,18 +209,18 @@ class OpenLPWizard(QtGui.QWizard): Registry().execute('openlp_stop_wizard') self.done(QtGui.QDialog.Rejected) - def on_current_id_changed(self, pageId): + def on_current_id_changed(self, page_id): """ Perform necessary functions depending on which wizard page is active. """ - if self.with_progress_page and self.page(pageId) == self.progress_page: + if self.with_progress_page and self.page(page_id) == self.progress_page: self.pre_wizard() self.perform_wizard() self.post_wizard() else: - self.custom_page_changed(pageId) + self.custom_page_changed(page_id) - def custom_page_changed(self, pageId): + def custom_page_changed(self, page_id): """ Called when changing to a page other than the progress page """ @@ -242,11 +242,8 @@ class OpenLPWizard(QtGui.QWizard): """ Update the wizard progress page. - ``status_text`` - Current status information to display. - - ``increment`` - The value to increment the progress bar by. + :param status_text: Current status information to display. + :param increment: The value to increment the progress bar by. """ log.debug('IncrementBar %s', status_text) self.progress_label.setText(status_text) @@ -276,17 +273,10 @@ class OpenLPWizard(QtGui.QWizard): """ Opens a QFileDialog and saves the filename to the given editbox. - ``title`` - The title of the dialog (unicode). - - ``editbox`` - An editbox (QLineEdit). - - ``setting_name`` - The place where to save the last opened directory. - - ``filters`` - The file extension filters. It should contain the file description + :param title: The title of the dialog (unicode). + :param editbox: An editbox (QLineEdit). + :param setting_name: The place where to save the last opened directory. + :param filters: The file extension filters. It should contain the file description as well as the file extension. For example:: u'OpenLP 2.0 Databases (*.sqlite)' @@ -304,32 +294,13 @@ class OpenLPWizard(QtGui.QWizard): """ Opens a QFileDialog and saves the selected folder to the given editbox. - ``title`` - The title of the dialog (unicode). - - ``editbox`` - An editbox (QLineEdit). - - ``setting_name`` - The place where to save the last opened directory. + :param title: The title of the dialog (unicode). + :param editbox: An editbox (QLineEdit). + :param setting_name: The place where to save the last opened directory. """ folder = QtGui.QFileDialog.getExistingDirectory( self, title, Settings().value(self.plugin.settings_section + '/' + setting_name), QtGui.QFileDialog.ShowDirsOnly) if folder: editbox.setText(folder) - Settings().setValue(self.plugin.settings_section + '/' + setting_name, folder) - - def _get_application(self): - """ - Adds the openlp to the class dynamically. - Windows needs to access the application in a dynamic manner. - """ - if os.name == 'nt': - return Registry().get('application') - else: - if not hasattr(self, '_application'): - self._application = Registry().get('application') - return self._application - - application = property(_get_application) + Settings().setValue(self.plugin.settings_section + '/' + setting_name, folder) \ No newline at end of file diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index 510528bcb..d9e060aed 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -179,8 +179,7 @@ def check_latest_version(current_version): Check the latest version of OpenLP against the version file on the OpenLP site. - ``current_version`` - The current version of OpenLP. + :param current_version: The current version of OpenLP. **Rules around versions and version files:** @@ -222,11 +221,8 @@ def add_actions(target, actions): """ Adds multiple actions to a menu or toolbar in one command. - ``target`` - The menu or toolbar to add actions to. - - ``actions`` - The actions to be added. An action consisting of the keyword ``None`` + :param target: The menu or toolbar to add actions to + :param actions: The actions to be added. An action consisting of the keyword ``None`` will result in a separator being inserted into the target. """ for action in actions: @@ -264,8 +260,7 @@ def is_not_image_file(file_name): """ Validate that the file is not an image file. - ``file_name`` - File name to be checked. + :param file_name: File name to be checked. """ if not file_name: return True @@ -292,8 +287,7 @@ def clean_filename(filename): """ Removes invalid characters from the given ``filename``. - ``filename`` - The "dirty" file name to clean. + :param filename: The "dirty" file name to clean. """ if not isinstance(filename, str): filename = str(filename, 'utf-8') @@ -304,8 +298,7 @@ def delete_file(file_path_name): """ Deletes a file from the system. - ``file_path_name`` - The file, including path, to delete. + :param file_path_name: The file, including path, to delete. """ if not file_path_name: return False @@ -333,14 +326,9 @@ def get_web_page(url, header=None, update_openlp=False): """ Attempts to download the webpage at url and returns that page or None. - ``url`` - The URL to be downloaded. - - ``header`` - An optional HTTP header to pass in the request to the web server. - - ``update_openlp`` - Tells OpenLP to update itself if the page is successfully downloaded. + :param url: The URL to be downloaded. + :param header: An optional HTTP header to pass in the request to the web server. + :param update_openlp: Tells OpenLP to update itself if the page is successfully downloaded. Defaults to False. """ # TODO: Add proxy usage. Get proxy info from OpenLP settings, add to a @@ -386,8 +374,7 @@ def get_uno_instance(resolver): """ Returns a running openoffice.org instance. - ``resolver`` - The UNO resolver to use to find a running instance. + :param resolver: The UNO resolver to use to find a running instance. """ log.debug('get UNO Desktop Openoffice - resolve') if UNO_CONNECTION_TYPE == 'pipe': @@ -404,11 +391,8 @@ def format_time(text, local_time): unicode string and passes individual % placeholders to time.strftime(). This ensures only ascii characters are passed to time.strftime(). - ``text`` - The text to be processed. - - ``local_time`` - The time to be used to add to the string. This is a time object + :param text: The text to be processed. + :param local_time: The time to be used to add to the string. This is a time object """ def match_formatting(match): """ @@ -422,8 +406,7 @@ def get_locale_key(string): """ Creates a key for case insensitive, locale aware string sorting. - ``string`` - The corresponding string. + :param string: The corresponding string. """ string = string.lower() # ICU is the prefered way to handle locale sort key, we fallback to locale.strxfrm which will work in most cases. @@ -439,6 +422,7 @@ def get_locale_key(string): except: return locale.strxfrm(string).encode() + def get_natural_key(string): """ Generate a key for locale aware natural string sorting. @@ -458,5 +442,5 @@ from .actions import ActionList __all__ = ['ActionList', 'LanguageManager', 'get_application_version', 'check_latest_version', - 'add_actions', 'get_filesystem_encoding', 'get_web_page', 'get_uno_command', 'get_uno_instance', - 'delete_file', 'clean_filename', 'format_time', 'get_locale_key', 'get_natural_key'] + 'add_actions', 'get_filesystem_encoding', 'get_web_page', 'get_uno_command', 'get_uno_instance', + 'delete_file', 'clean_filename', 'format_time', 'get_locale_key', 'get_natural_key'] diff --git a/openlp/core/utils/actions.py b/openlp/core/utils/actions.py index 86ba3a04e..6201dff52 100644 --- a/openlp/core/utils/actions.py +++ b/openlp/core/utils/actions.py @@ -258,17 +258,12 @@ class ActionList(object): **Note**: The action's objectName must be set when you want to add it! - ``action`` - The action to add (QAction). **Note**, the action must not have an empty ``objectName``. - - ``category`` - The category this action belongs to. The category has to be a python string. . **Note**, if the category - is ``None``, the category and its actions are being hidden in the shortcut dialog. However, if they are - added, it is possible to avoid assigning shortcuts twice, which is important. - - ``weight`` - The weight specifies how important a category is. However, this only has an impact on the order the - categories are displayed. + :param action: The action to add (QAction). **Note**, the action must not have an empty ``objectName``. + :param category: The category this action belongs to. The category has to be a python string. . **Note**, + if the category is ``None``, the category and its actions are being hidden in the shortcut dialog. However, + if they are added, it is possible to avoid assigning shortcuts twice, which is important. + :param weight: The weight specifies how important a category is. However, this only has an impact on the order + the categories are displayed. """ if category not in self.categories: self.categories.append(category) @@ -319,11 +314,8 @@ class ActionList(object): """ This removes an action from its category. Empty categories are automatically removed. - ``action`` - The ``QAction`` object to be removed. - - ``category`` - The name (unicode string) of the category, which contains the action. Defaults to None. + :param action: The ``QAction`` object to be removed. + :param category: The name (unicode string) of the category, which contains the action. Defaults to None. """ if category not in self.categories: return @@ -343,11 +335,8 @@ class ActionList(object): """ Add an empty category to the list of categories. This is only convenient for categories with a given weight. - ``name`` - The category's name. - - ``weight`` - The category's weight (int). + :param name: The category's name. + :param weight: The category's weight (int). """ if name in self.categories: # Only change the weight and resort the categories again. @@ -361,15 +350,11 @@ class ActionList(object): def update_shortcut_map(self, action, old_shortcuts): """ Remove the action for the given ``old_shortcuts`` from the ``shortcut_map`` to ensure its up-to-dateness. - **Note**: The new action's shortcuts **must** be assigned to the given ``action`` **before** calling this method. - ``action`` - The action whose shortcuts are supposed to be updated in the ``shortcut_map``. - - ``old_shortcuts`` - A list of unicode keysequences. + :param action: The action whose shortcuts are supposed to be updated in the ``shortcut_map``. + :param old_shortcuts: A list of unicode key sequences. """ for old_shortcut in old_shortcuts: # Remove action from the list of actions which are using this shortcut. @@ -388,11 +373,8 @@ class ActionList(object): """ Checks if the given ``action`` may use its assigned shortcut(s) or not. Returns ``True`` or ``False. - ``existing_actions`` - A list of actions which already use a particular shortcut. - - ``action`` - The action which wants to use a particular shortcut. + :param existing_actions: A list of actions which already use a particular shortcut. + :param action: The action which wants to use a particular shortcut. """ global_context = action.shortcutContext() in [QtCore.Qt.WindowShortcut, QtCore.Qt.ApplicationShortcut] affected_actions = [] diff --git a/openlp/core/utils/languagemanager.py b/openlp/core/utils/languagemanager.py index 1e195ce77..3e240778b 100644 --- a/openlp/core/utils/languagemanager.py +++ b/openlp/core/utils/languagemanager.py @@ -52,8 +52,7 @@ class LanguageManager(object): """ Set up a translator to use in this instance of OpenLP - ``language`` - The language to load into the translator + :param language: The language to load into the translator """ if LanguageManager.auto_language: language = QtCore.QLocale.system().name() @@ -85,8 +84,7 @@ class LanguageManager(object): """ Load the language name from a language file - ``qm_file`` - The file to obtain the name from + :param qm_file: The file to obtain the name from """ translator = QtCore.QTranslator() translator.load(qm_file) @@ -110,11 +108,8 @@ class LanguageManager(object): """ Set the language to translate OpenLP into - ``action`` - The language menu option - - ``message`` - Display the message option + :param action: The language menu option + :param message: Display the message option """ language = 'en' if action: diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py index e41c413bc..e9a24980e 100644 --- a/openlp/plugins/alerts/alertsplugin.py +++ b/openlp/plugins/alerts/alertsplugin.py @@ -140,7 +140,7 @@ class AlertsPlugin(Plugin): self.weight = -3 self.icon_path = ':/plugins/plugin_alerts.png' self.icon = build_icon(self.icon_path) - self.alerts_manager = AlertsManager(self) + AlertsManager(self) self.manager = Manager('alerts', init_schema) self.alert_form = AlertForm(self) diff --git a/openlp/plugins/alerts/lib/alertsmanager.py b/openlp/plugins/alerts/lib/alertsmanager.py index 4b0832537..675b5874e 100644 --- a/openlp/plugins/alerts/lib/alertsmanager.py +++ b/openlp/plugins/alerts/lib/alertsmanager.py @@ -33,10 +33,10 @@ displaying of alerts. from PyQt4 import QtCore -from openlp.core.common import OpenLPMixin, RegistryMixin, Registry, translate +from openlp.core.common import OpenLPMixin, RegistryMixin, Registry, RegistryProperties, translate -class AlertsManager(OpenLPMixin, RegistryMixin, QtCore.QObject): +class AlertsManager(OpenLPMixin, RegistryMixin, QtCore.QObject, RegistryProperties): """ AlertsManager manages the settings of Alerts. """ @@ -97,24 +97,4 @@ class AlertsManager(OpenLPMixin, RegistryMixin, QtCore.QObject): self.live_controller.display.alert('', alert_tab.location) self.killTimer(self.timer_id) self.timer_id = 0 - self.generate_alert() - - def _get_live_controller(self): - """ - Adds the live controller to the class dynamically - """ - if not hasattr(self, '_live_controller'): - self._live_controller = Registry().get('live_controller') - return self._live_controller - - live_controller = property(_get_live_controller) - - def _get_main_window(self): - """ - Adds the main window to the class dynamically - """ - if not hasattr(self, '_main_window'): - self._main_window = Registry().get('main_window') - return self._main_window - - main_window = property(_get_main_window) + self.generate_alert() \ No newline at end of file diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 92a91aad4..fc7d76130 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -136,8 +136,7 @@ class BiblePlugin(Plugin): """ Give the bible plugin the opportunity to add items to the **Tools** menu. - ``tools_menu`` - The actual **Tools** menu item, so that your actions can use it as their parent. + :param tools_menu: The actual **Tools** menu item, so that your actions can use it as their parent. """ log.debug('add tools menu') self.tools_upgrade_item = create_action( diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 5cde95fef..8c7b62d10 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -67,14 +67,9 @@ class BibleImportForm(OpenLPWizard): """ Instantiate the wizard, and run any extra setup we need to. - ``parent`` - The QWidget-derived parent of the wizard. - - ``manager`` - The Bible manager. - - ``bible_plugin`` - The Bible plugin. + :param parent: The QWidget-derived parent of the wizard. + :param manager: The Bible manager. + :param bible_plugin: The Bible plugin. """ self.manager = manager self.web_bible_list = {} diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 3bda5edfc..2b574f778 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -57,14 +57,9 @@ class BibleUpgradeForm(OpenLPWizard): """ Instantiate the wizard, and run any extra setup we need to. - ``parent`` - The QWidget-derived parent of the wizard. - - ``manager`` - The Bible manager. - - ``bible_plugin`` - The Bible plugin. + :param parent: The QWidget-derived parent of the wizard. + :param manager: The Bible manager. + :param bible_plugin: The Bible plugin. """ self.manager = manager self.media_item = bible_plugin.media_item diff --git a/openlp/plugins/bibles/forms/editbibleform.py b/openlp/plugins/bibles/forms/editbibleform.py index 8e59d02f7..f2d97cc08 100644 --- a/openlp/plugins/bibles/forms/editbibleform.py +++ b/openlp/plugins/bibles/forms/editbibleform.py @@ -33,7 +33,7 @@ import re from PyQt4 import QtGui -from openlp.core.common import Registry, UiStrings, translate +from openlp.core.common import RegistryProperties, UiStrings, translate from openlp.core.lib.ui import critical_error_message_box from .editbibledialog import Ui_EditBibleDialog from openlp.plugins.bibles.lib import BibleStrings @@ -41,7 +41,8 @@ from openlp.plugins.bibles.lib.db import BiblesResourcesDB log = logging.getLogger(__name__) -class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog): + +class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog, RegistryProperties): """ Class to manage the editing of a bible """ @@ -57,12 +58,13 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog): self.setupUi(self) self.manager = manager - def loadBible(self, bible): + def load_bible(self, bible): """ Loads a bible. ``bible`` - The name of the bible. + + :param bible: The name of the bible. """ log.debug('Load Bible') self.bible = bible @@ -73,18 +75,20 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog): if book_name_language and book_name_language.value != 'None': self.language_selection_combo_box.setCurrentIndex(int(book_name_language.value) + 1) self.books = {} - self.webbible = self.manager.get_meta_data(self.bible, 'download_source') - if self.webbible: - self.book_name_notice.setText(translate('BiblesPlugin.EditBibleForm', - 'This is a Web Download Bible.\nIt is not possible to customize the Book Names.')) + self.web_bible = self.manager.get_meta_data(self.bible, 'download_source') + if self.web_bible: + self.book_name_notice.setText( + translate('BiblesPlugin.EditBibleForm', + 'This is a Web Download Bible.\nIt is not possible to customize the Book Names.')) self.scroll_area.hide() else: - self.book_name_notice.setText(translate('BiblesPlugin.EditBibleForm', - 'To use the customized book names, "Bible language" must be selected on the Meta Data tab or, ' - 'if "Global settings" is selected, on the Bible page in Configure OpenLP.')) + self.book_name_notice.setText( + translate('BiblesPlugin.EditBibleForm', + 'To use the customized book names, "Bible language" must be selected on the Meta Data tab ' + 'or, if "Global settings" is selected, on the Bible page in Configure OpenLP.')) for book in BiblesResourcesDB.get_books(): self.books[book['abbreviation']] = self.manager.get_book_by_id(self.bible, book['id']) - if self.books[book['abbreviation']] and not self.webbible: + if self.books[book['abbreviation']] and not self.web_bible: self.book_name_edit[book['abbreviation']].setText(self.books[book['abbreviation']].name) else: # It is necessary to remove the Widget otherwise there still @@ -113,19 +117,19 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog): book_name_language = self.language_selection_combo_box.currentIndex() - 1 if book_name_language == -1: book_name_language = None - if not self.validateMeta(version, copyright): + if not self.validate_meta(version, copyright): return - if not self.webbible: + if not self.web_bible: custom_names = {} for abbr, book in self.books.items(): if book: custom_names[abbr] = self.book_name_edit[abbr].text() if book.name != custom_names[abbr]: - if not self.validateBook(custom_names[abbr], abbr): + if not self.validate_book(custom_names[abbr], abbr): return self.application.set_busy_cursor() self.manager.save_meta_data(self.bible, version, copyright, permissions, book_name_language) - if not self.webbible: + if not self.web_bible: for abbr, book in self.books.items(): if book: if book.name != custom_names[abbr]: @@ -135,47 +139,52 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog): self.application.set_normal_cursor() QtGui.QDialog.accept(self) - def validateMeta(self, name, copyright): + def validate_meta(self, name, copyright): """ Validate the Meta before saving. """ if not name: self.version_name_edit.setFocus() - critical_error_message_box(UiStrings().EmptyField, + critical_error_message_box( + UiStrings().EmptyField, translate('BiblesPlugin.BibleEditForm', 'You need to specify a version name for your Bible.')) return False elif not copyright: self.copyright_edit.setFocus() - critical_error_message_box(UiStrings().EmptyField, + critical_error_message_box( + UiStrings().EmptyField, translate('BiblesPlugin.BibleEditForm', - 'You need to set a copyright for your Bible. Bibles in the Public Domain need to be marked as such.')) + 'You need to set a copyright for your Bible. Bibles in the Public Domain need to be marked ' + 'as such.')) return False - elif self.manager.exists(name) and self.manager.get_meta_data(self.bible, 'name').value != \ - name: + elif self.manager.exists(name) and self.manager.get_meta_data(self.bible, 'name').value != name: self.version_name_edit.setFocus() - critical_error_message_box(translate('BiblesPlugin.BibleEditForm', 'Bible Exists'), + critical_error_message_box( + translate('BiblesPlugin.BibleEditForm', 'Bible Exists'), translate('BiblesPlugin.BibleEditForm', 'This Bible already exists. Please import ' - 'a different Bible or first delete the existing one.')) + 'a different Bible or first delete the existing one.')) return False return True - def validateBook(self, new_book_name, abbreviation): + def validate_book(self, new_book_name, abbreviation): """ Validate a book. """ book_regex = re.compile('[\d]*[^\d]+$') if not new_book_name: self.book_name_edit[abbreviation].setFocus() - critical_error_message_box(UiStrings().EmptyField, + critical_error_message_box( + UiStrings().EmptyField, translate('BiblesPlugin.BibleEditForm', 'You need to specify a book name for "%s".') % - self.book_names[abbreviation]) + self.book_names[abbreviation]) return False elif not book_regex.match(new_book_name): self.book_name_edit[abbreviation].setFocus() - critical_error_message_box(UiStrings().EmptyField, + critical_error_message_box( + UiStrings().EmptyField, translate('BiblesPlugin.BibleEditForm', - 'The book name "%s" is not correct.\nNumbers can only be used at the beginning and must\nbe ' - 'followed by one or more non-numeric characters.') % new_book_name) + 'The book name "%s" is not correct.\nNumbers can only be used at the beginning and must\nbe ' + 'followed by one or more non-numeric characters.') % new_book_name) return False for abbr, book in self.books.items(): if book: @@ -186,20 +195,6 @@ class EditBibleForm(QtGui.QDialog, Ui_EditBibleDialog): critical_error_message_box( translate('BiblesPlugin.BibleEditForm', 'Duplicate Book Name'), translate('BiblesPlugin.BibleEditForm', 'The Book Name "%s" has been entered more than once.') - % new_book_name) + % new_book_name) return False return True - - def _get_application(self): - """ - Adds the openlp to the class dynamically. - Windows needs to access the application in a dynamic manner. - """ - if os.name == 'nt': - return Registry().get('application') - else: - if not hasattr(self, '_application'): - self._application = Registry().get('application') - return self._application - - application = property(_get_application) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 36b8a0bf2..a41545377 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -38,7 +38,7 @@ from sqlalchemy import Column, ForeignKey, Table, or_, types, func from sqlalchemy.orm import class_mapper, mapper, relation from sqlalchemy.orm.exc import UnmappedClassError -from openlp.core.common import Registry, AppLocation, translate +from openlp.core.common import Registry, RegistryProperties, AppLocation, translate from openlp.core.lib.db import BaseModel, init_db, Manager from openlp.core.lib.ui import critical_error_message_box from openlp.core.utils import clean_filename @@ -74,8 +74,7 @@ def init_schema(url): """ Setup a bible database connection and initialise the database schema. - ``url`` - The database to setup. + :param url: The database to setup. """ session, metadata = init_db(url) @@ -116,7 +115,7 @@ def init_schema(url): return session -class BibleDB(QtCore.QObject, Manager): +class BibleDB(QtCore.QObject, Manager, RegistryProperties): """ This class represents a database-bound Bible. It is used as a base class for all the custom importers, so that the can implement their own import methods, but benefit from the database methods in here via inheritance, @@ -501,20 +500,6 @@ class BibleDB(QtCore.QObject, Manager): verses = self.session.query(Verse).all() log.debug(verses) - def _get_application(self): - """ - Adds the openlp to the class dynamically. - Windows needs to access the application in a dynamic manner. - """ - if os.name == 'nt': - return Registry().get('application') - else: - if not hasattr(self, '_application'): - self._application = Registry().get('application') - return self._application - - application = property(_get_application) - class BiblesResourcesDB(QtCore.QObject, Manager): """ @@ -725,9 +710,9 @@ class BiblesResourcesDB(QtCore.QObject, Manager): @staticmethod def get_webbibles(source): """ - Return the bibles a webbible provide for download. + Return the bibles a web_bible provide for download. - :param source: The source of the webbible. + :param source: The source of the web_bible. """ log.debug('BiblesResourcesDB.get_webbibles("%s")', source) if not isinstance(source, str): @@ -749,10 +734,10 @@ class BiblesResourcesDB(QtCore.QObject, Manager): @staticmethod def get_webbible(abbreviation, source): """ - Return the bibles a webbible provide for download. + Return the bibles a web_bible provide for download. - :param abbreviation: The abbreviation of the webbible. - :param source: The source of the webbible. + :param abbreviation: The abbreviation of the web_bible. + :param source: The source of the web_bible. """ log.debug('BiblesResourcesDB.get_webbibles("%s", "%s")', abbreviation, source) if not isinstance(abbreviation, str): diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 5f3692527..3400c9a56 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -29,7 +29,6 @@ """ The :mod:`http` module enables OpenLP to retrieve scripture from bible websites. """ -import os import logging import re import socket @@ -38,7 +37,7 @@ from html.parser import HTMLParseError from bs4 import BeautifulSoup, NavigableString, Tag -from openlp.core.common import Registry, translate +from openlp.core.common import Registry, RegistryProperties, translate from openlp.core.lib.ui import critical_error_message_box from openlp.core.utils import get_web_page from openlp.plugins.bibles.lib import SearchResults @@ -61,7 +60,7 @@ VERSE_NUMBER_REGEX = re.compile(r'v(\d{1,2})(\d{3})(\d{3}) verse.*') log = logging.getLogger(__name__) -class BGExtract(object): +class BGExtract(RegistryProperties): """ Extract verses from BibleGateway """ @@ -285,22 +284,8 @@ class BGExtract(object): books.append(book.contents[0]) return books - def _get_application(self): - """ - Adds the openlp to the class dynamically. - Windows needs to access the application in a dynamic manner. - """ - if os.name == 'nt': - return Registry().get('application') - else: - if not hasattr(self, '_application'): - self._application = Registry().get('application') - return self._application - application = property(_get_application) - - -class BSExtract(object): +class BSExtract(RegistryProperties): """ Extract verses from Bibleserver.com """ @@ -359,22 +344,8 @@ class BSExtract(object): content = content.find_all('li') return [book.contents[0].contents[0] for book in content if len(book.contents[0].contents)] - def _get_application(self): - """ - Adds the openlp to the class dynamically. - Windows needs to access the application in a dynamic manner. - """ - if os.name == 'nt': - return Registry().get('application') - else: - if not hasattr(self, '_application'): - self._application = Registry().get('application') - return self._application - application = property(_get_application) - - -class CWExtract(object): +class CWExtract(RegistryProperties): """ Extract verses from CrossWalk/BibleStudyTools """ @@ -457,22 +428,8 @@ class CWExtract(object): books.append(book.contents[0]) return books - def _get_application(self): - """ - Adds the openlp to the class dynamically. - Windows needs to access the application in a dynamic manner. - """ - if os.name == 'nt': - return Registry().get('application') - else: - if not hasattr(self, '_application'): - self._application = Registry().get('application') - return self._application - application = property(_get_application) - - -class HTTPBible(BibleDB): +class HTTPBible(BibleDB, RegistryProperties): log.info('%s HTTPBible loaded', __name__) def __init__(self, parent, **kwargs): @@ -647,20 +604,6 @@ class HTTPBible(BibleDB): log.debug('HTTPBible.get_verse_count("%s", %s)', book_id, chapter) return BiblesResourcesDB.get_verse_count(book_id, chapter) - def _get_application(self): - """ - Adds the openlp to the class dynamically. - Windows needs to access the application in a dynamic manner. - """ - if os.name == 'nt': - return Registry().get('application') - else: - if not hasattr(self, '_application'): - self._application = Registry().get('application') - return self._application - - application = property(_get_application) - def get_soup_for_bible_ref(reference_url, header=None, pre_parse_regex=None, pre_parse_substitute=None): """ @@ -698,8 +641,7 @@ def send_error_message(error_type): """ Send a standard error message informing the user of an issue. - ``error_type`` - The type of error that occured for the issue. + :param error_type: The type of error that occurred for the issue. """ if error_type == 'download': critical_error_message_box( diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 53bab5f6b..8ad446ab4 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -30,7 +30,7 @@ import logging import os -from openlp.core.common import Registry, AppLocation, Settings, translate +from openlp.core.common import RegistryProperties, AppLocation, Settings, translate from openlp.core.utils import delete_file from openlp.plugins.bibles.lib import parse_reference, get_reference_separator, LanguageSelection from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta @@ -84,7 +84,7 @@ class BibleFormat(object): ] -class BibleManager(object): +class BibleManager(RegistryProperties): """ The Bible manager which holds and manages all the Bibles. """ @@ -405,15 +405,4 @@ class BibleManager(object): for bible in self.db_cache: self.db_cache[bible].finalise() - def _get_main_window(self): - """ - Adds the main window to the class dynamically - """ - if not hasattr(self, '_main_window'): - self._main_window = Registry().get('main_window') - return self._main_window - - main_window = property(_get_main_window) - - __all__ = ['BibleFormat'] diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 0bdd8aae6..4b8b8bc83 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -475,7 +475,7 @@ class BibleMediaItem(MediaManagerItem): bible = self.advancedVersionComboBox.currentText() if bible: self.edit_bible_form = EditBibleForm(self, self.main_window, self.plugin.manager) - self.edit_bible_form.loadBible(bible) + self.edit_bible_form.load_bible(bible) if self.edit_bible_form.exec_(): self.reload_bibles() diff --git a/openlp/plugins/custom/customplugin.py b/openlp/plugins/custom/customplugin.py index 751c5939c..eb7de530a 100644 --- a/openlp/plugins/custom/customplugin.py +++ b/openlp/plugins/custom/customplugin.py @@ -83,14 +83,10 @@ class CustomPlugin(Plugin): def rename_theme(self, old_theme, new_theme): """ - Renames a theme the custom plugin is using making the plugin use the - new name. + Renames a theme the custom plugin is using making the plugin use the new name. - ``oldTheme`` - The name of the theme the plugin should stop using. - - ``newTheme`` - The new name the plugin should now use. + :param old_theme: The name of the theme the plugin should stop using. + :param new_theme: The new name the plugin should now use. """ customs_using_theme = self.db_manager.get_all_objects(CustomSlide, CustomSlide.theme_name == old_theme) for custom in customs_using_theme: diff --git a/openlp/plugins/custom/lib/customxmlhandler.py b/openlp/plugins/custom/lib/customxmlhandler.py index c0f02942f..ca42a705b 100644 --- a/openlp/plugins/custom/lib/customxmlhandler.py +++ b/openlp/plugins/custom/lib/customxmlhandler.py @@ -127,8 +127,7 @@ class CustomXMLParser(object): """ Set up our custom XML parser. - ``xml`` - The XML of the custom to be parsed. + :param xml: The XML of the custom to be parsed. """ self.custom_xml = None if xml[:5] == '<?xml': @@ -140,8 +139,7 @@ class CustomXMLParser(object): def get_verses(self): """ - Iterates through the verses in the XML and returns a list of verses - and their attributes. + Iterates through the verses in the XML and returns a list of verses and their attributes. """ xml_iter = self.custom_xml.getiterator() verse_list = [] diff --git a/openlp/plugins/custom/lib/db.py b/openlp/plugins/custom/lib/db.py index 44287b543..ad20b5842 100644 --- a/openlp/plugins/custom/lib/db.py +++ b/openlp/plugins/custom/lib/db.py @@ -60,8 +60,7 @@ def init_schema(url): """ Setup the custom database connection and initialise the database schema - ``url`` - The database to setup + :param url: The database to setup """ session, metadata = init_db(url) diff --git a/openlp/plugins/images/forms/choosegroupdialog.py b/openlp/plugins/images/forms/choosegroupdialog.py index 7f05202e6..75f8cacee 100644 --- a/openlp/plugins/images/forms/choosegroupdialog.py +++ b/openlp/plugins/images/forms/choosegroupdialog.py @@ -41,8 +41,7 @@ class Ui_ChooseGroupDialog(object): """ Set up the UI. - ``choose_group_dialog`` - The form object (not the class). + :param choose_group_dialog: The form object (not the class). """ choose_group_dialog.setObjectName('choose_group_dialog') choose_group_dialog.resize(399, 119) @@ -84,8 +83,7 @@ class Ui_ChooseGroupDialog(object): """ Translate the UI on the fly. - ``choose_group_dialog`` - The form object (not the class). + :param choose_group_dialog: The form object (not the class). """ choose_group_dialog.setWindowTitle(translate('ImagePlugin.ChooseGroupForm', 'Select Image Group')) self.group_question_label.setText(translate('ImagePlugin.ChooseGroupForm', 'Add images to group:')) diff --git a/openlp/plugins/images/forms/choosegroupform.py b/openlp/plugins/images/forms/choosegroupform.py index 52cd5b51b..a7dca7237 100644 --- a/openlp/plugins/images/forms/choosegroupform.py +++ b/openlp/plugins/images/forms/choosegroupform.py @@ -47,8 +47,7 @@ class ChooseGroupForm(QtGui.QDialog, Ui_ChooseGroupDialog): """ Show the form - ``selected_group`` - The ID of the group that should be selected by default when showing the dialog. + :param selected_group: The ID of the group that should be selected by default when showing the dialog. """ self.new_group_edit.clear() if selected_group is not None: diff --git a/openlp/plugins/images/imageplugin.py b/openlp/plugins/images/imageplugin.py index c03059815..693449530 100644 --- a/openlp/plugins/images/imageplugin.py +++ b/openlp/plugins/images/imageplugin.py @@ -84,8 +84,7 @@ class ImagePlugin(Plugin): """ Upgrade the settings of this plugin. - ``settings`` - The Settings object containing the old settings. + :param settings: The Settings object containing the old settings. """ files_from_config = settings.get_files_from_config(self) if files_from_config: @@ -124,13 +123,3 @@ class ImagePlugin(Plugin): log.info('Images config_update') background = QtGui.QColor(Settings().value(self.settings_section + '/background color')) self.image_manager.update_images_border(ImageSource.ImagePlugin, background) - - def _get_image_manager(self): - """ - Adds the image manager to the class dynamically - """ - if not hasattr(self, '_image_manager'): - self._image_manager = Registry().get('image_manager') - return self._image_manager - - image_manager = property(_get_image_manager) diff --git a/openlp/plugins/images/lib/db.py b/openlp/plugins/images/lib/db.py index 69bc70982..68ca3d11d 100644 --- a/openlp/plugins/images/lib/db.py +++ b/openlp/plugins/images/lib/db.py @@ -54,9 +54,7 @@ def init_schema(url): """ Setup the images database connection and initialise the database schema. - ``url`` - The database to setup - + :param url: The database to setup The images database contains the following tables: * image_groups diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 5e1412a39..01a28f9ca 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -32,7 +32,8 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.common import Registry, AppLocation, Settings, check_directory_exists, UiStrings, translate +from openlp.core.common import Registry, RegistryProperties, AppLocation, Settings, check_directory_exists, UiStrings,\ + translate from openlp.core.lib import ItemCapabilities, MediaManagerItem,MediaType, ServiceItem, ServiceItemContext, \ build_icon, check_item_selected from openlp.core.lib.ui import critical_error_message_box, create_horizontal_adjusting_combo_box @@ -51,7 +52,7 @@ DVD_ICON = build_icon(':/media/media_video.png') ERROR_ICON = build_icon(':/general/general_delete.png') -class MediaMediaItem(MediaManagerItem): +class MediaMediaItem(MediaManagerItem, RegistryProperties): """ This is the custom media manager item for Media Slides. """ diff --git a/openlp/plugins/media/mediaplugin.py b/openlp/plugins/media/mediaplugin.py index 0ec0940a7..6cf241d1d 100644 --- a/openlp/plugins/media/mediaplugin.py +++ b/openlp/plugins/media/mediaplugin.py @@ -31,7 +31,7 @@ import logging from PyQt4 import QtCore -from openlp.core.common import Registry, translate +from openlp.core.common import translate from openlp.core.lib import Plugin, StringContent, build_icon from openlp.plugins.media.lib import MediaMediaItem, MediaTab @@ -120,13 +120,3 @@ class MediaPlugin(Plugin): Add html code to htmlbuilder. """ return self.media_controller.get_media_display_html() - - def _get_media_controller(self): - """ - Adds the media controller to the class dynamically - """ - if not hasattr(self, '_media_controller'): - self._media_controller = Registry().get('media_controller') - return self._media_controller - - media_controller = property(_get_media_controller) diff --git a/openlp/plugins/presentations/lib/presentationcontroller.py b/openlp/plugins/presentations/lib/presentationcontroller.py index a64440881..2a90cf116 100644 --- a/openlp/plugins/presentations/lib/presentationcontroller.py +++ b/openlp/plugins/presentations/lib/presentationcontroller.py @@ -218,8 +218,7 @@ class PresentationDocument(object): """ Jumps directly to the requested slide. - ``slide_no`` - The slide to jump to, starting at 1 + :param slide_no: The slide to jump to, starting at 1 """ pass @@ -250,8 +249,8 @@ class PresentationDocument(object): """ Returns an image path containing a preview for the requested slide - ``slide_no`` - The slide an image is required for, starting at 1 + :param slide_no: The slide an image is required for, starting at 1 + :param check_exists: """ path = os.path.join(self.get_thumbnail_folder(), self.controller.thumbnail_prefix + str(slide_no) + '.png') if os.path.isfile(path) or not check_exists: @@ -470,17 +469,6 @@ class PresentationController(object): def close_presentation(self): pass - def _get_plugin_manager(self): - """ - Adds the plugin manager to the class dynamically - """ - if not hasattr(self, '_plugin_manager'): - self._plugin_manager = Registry().get('plugin_manager') - return self._plugin_manager - - plugin_manager = property(_get_plugin_manager) - - class TextType(object): """ Type Enumeration for Types of Text to request @@ -488,3 +476,4 @@ class TextType(object): Title = 0 SlideText = 1 Notes = 2 + diff --git a/openlp/plugins/remotes/lib/httprouter.py b/openlp/plugins/remotes/lib/httprouter.py index 45b09e8fb..813ab4e20 100644 --- a/openlp/plugins/remotes/lib/httprouter.py +++ b/openlp/plugins/remotes/lib/httprouter.py @@ -124,7 +124,7 @@ from urllib.parse import urlparse, parse_qs from mako.template import Template from PyQt4 import QtCore -from openlp.core.common import Registry, AppLocation, Settings, translate +from openlp.core.common import Registry, RegistryProperties, AppLocation, Settings, translate from openlp.core.lib import PluginStatus, StringContent, image_to_byte, ItemCapabilities log = logging.getLogger(__name__) @@ -139,7 +139,7 @@ FILE_TYPES = { } -class HttpRouter(object): +class HttpRouter(RegistryProperties): """ This code is called by the HttpServer upon a request and it processes it based on the routing table. This code is stateless and is created on each request. @@ -209,11 +209,8 @@ class HttpRouter(object): """ Invoke the route function passing the relevant values - ``function`` - The function to be calledL. - - ``*args`` - Any passed data. + :param function: The function to be called. + :param args: Any passed data. """ response = function['function'](*args) if response: @@ -224,11 +221,8 @@ class HttpRouter(object): """ Common function to process HTTP requests - ``url_path`` - The requested URL. - - ``*args`` - Any passed data. + :param url_path: The requested URL. + :param args: Any passed data. """ self.request_data = None url_path_split = urlparse(url_path) @@ -381,8 +375,7 @@ class HttpRouter(object): def get_content_type(self, file_name): """ - Examines the extension of the file and determines - what the content_type should be, defaults to text/plain + Examines the extension of the file and determines what the content_type should be, defaults to text/plain Returns the extension and the content_type """ content_type = 'text/plain' @@ -463,8 +456,7 @@ class HttpRouter(object): Hide or show the display screen. This is a cross Thread call and UI is updated so Events need to be used. - ``action`` - This is the action, either ``hide`` or ``show``. + :param action: This is the action, either ``hide`` or ``show``. """ self.live_controller.emit(QtCore.SIGNAL('slidecontroller_toggle_display'), action) self.do_json_header() @@ -532,11 +524,8 @@ class HttpRouter(object): """ Perform an action on the slide controller. - ``display_type`` - This is the type of slide controller, either ``preview`` or ``live``. - - ``action`` - The action to perform. + :param display_type: This is the type of slide controller, either ``preview`` or ``live``. + :param action: The action to perform. """ event = 'slidecontroller_%s_%s' % (display_type, action) if self.request_data: @@ -557,8 +546,6 @@ class HttpRouter(object): """ Handles requests for service items in the service manager - ``action`` - The action to perform. """ self.do_json_header() return json.dumps({'results': {'items': self._get_service_items()}}).encode() @@ -567,8 +554,7 @@ class HttpRouter(object): """ Handles requests for service items in the service manager - ``action`` - The action to perform. + :param action: The action to perform. """ event = 'servicemanager_%s_item' % action if self.request_data: @@ -586,9 +572,7 @@ class HttpRouter(object): """ Return plugin related information, based on the action. - ``action`` - The action to perform. If *search* return a list of plugin names - which support search. + :param action: The action to perform. If *search* return a list of plugin names which support search. """ if action == 'search': searches = [] @@ -602,8 +586,7 @@ class HttpRouter(object): """ Return a list of items that match the search text. - ``plugin`` - The plugin name to search in. + :param plugin_name: The plugin name to search in. """ try: text = json.loads(self.request_data)['request']['text'] @@ -645,52 +628,3 @@ class HttpRouter(object): plugin.media_item.emit(QtCore.SIGNAL('%s_add_to_service' % plugin_name), [item_id, True]) self.do_http_success() - def _get_service_manager(self): - """ - Adds the service manager to the class dynamically - """ - if not hasattr(self, '_service_manager'): - self._service_manager = Registry().get('service_manager') - return self._service_manager - - service_manager = property(_get_service_manager) - - def _get_live_controller(self): - """ - Adds the live controller to the class dynamically - """ - if not hasattr(self, '_live_controller'): - self._live_controller = Registry().get('live_controller') - return self._live_controller - - live_controller = property(_get_live_controller) - - def _get_plugin_manager(self): - """ - Adds the plugin manager to the class dynamically - """ - if not hasattr(self, '_plugin_manager'): - self._plugin_manager = Registry().get('plugin_manager') - return self._plugin_manager - - plugin_manager = property(_get_plugin_manager) - - def _get_alerts_manager(self): - """ - Adds the alerts manager to the class dynamically - """ - if not hasattr(self, '_alerts_manager'): - self._alerts_manager = Registry().get('alerts_manager') - return self._alerts_manager - - alerts_manager = property(_get_alerts_manager) - - def _get_image_manager(self): - """ - Adds the image manager to the class dynamically - """ - if not hasattr(self, '_image_manager'): - self._image_manager = Registry().get('image_manager') - return self._image_manager - - image_manager = property(_get_image_manager) \ No newline at end of file diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index d398caaee..b57bd29d3 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -83,8 +83,7 @@ class HttpThread(QtCore.QThread): """ Constructor for the thread class. - ``server`` - The http server class. + :param server: The http server class. """ super(HttpThread, self).__init__(None) self.http_server = server diff --git a/openlp/plugins/remotes/lib/remotetab.py b/openlp/plugins/remotes/lib/remotetab.py index ce87de694..540b8d212 100644 --- a/openlp/plugins/remotes/lib/remotetab.py +++ b/openlp/plugins/remotes/lib/remotetab.py @@ -56,7 +56,7 @@ class RemoteTab(SettingsTab): self.address_edit = QtGui.QLineEdit(self.server_settings_group_box) self.address_edit.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Fixed) self.address_edit.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'), - self)) + self)) self.address_edit.setObjectName('address_edit') self.server_settings_layout.addRow(self.address_label, self.address_edit) self.twelve_hour_check_box = QtGui.QCheckBox(self.server_settings_group_box) @@ -177,14 +177,13 @@ class RemoteTab(SettingsTab): self.live_url_label.setText(translate('RemotePlugin.RemoteTab', 'Live view URL:')) self.twelve_hour_check_box.setText(translate('RemotePlugin.RemoteTab', 'Display stage time in 12h format')) self.android_app_group_box.setTitle(translate('RemotePlugin.RemoteTab', 'Android App')) - self.qr_description_label.setText(translate('RemotePlugin.RemoteTab', - 'Scan the QR code or click <a href="https://play.google.com/store/' - 'apps/details?id=org.openlp.android">download</a> to install the ' - 'Android app from Google Play.')) + self.qr_description_label.setText( + translate('RemotePlugin.RemoteTab', 'Scan the QR code or click <a href="https://play.google.com/store/' + 'apps/details?id=org.openlp.android">download</a> to install the Android app from Google Play.')) self.https_settings_group_box.setTitle(translate('RemotePlugin.RemoteTab', 'HTTPS Server')) - self.https_error_label.setText(translate('RemotePlugin.RemoteTab', - 'Could not find an SSL certificate. The HTTPS server will not be available unless an SSL certificate ' - 'is found. Please see the manual for more information.')) + self.https_error_label.setText( + translate('RemotePlugin.RemoteTab', 'Could not find an SSL certificate. The HTTPS server will not be ' + 'available unless an SSL certificate is found. Please see the manual for more information.')) self.https_port_label.setText(self.port_label.text()) self.remote_https_url_label.setText(self.remote_url_label.text()) self.stage_https_url_label.setText(self.stage_url_label.text()) @@ -290,4 +289,3 @@ class RemoteTab(SettingsTab): Invert the HTTP group box based on Https group settings """ self.http_settings_group_box.setEnabled(not self.https_settings_group_box.isChecked()) - diff --git a/openlp/plugins/remotes/remoteplugin.py b/openlp/plugins/remotes/remoteplugin.py index 3eaec9cb1..ef1d74a84 100644 --- a/openlp/plugins/remotes/remoteplugin.py +++ b/openlp/plugins/remotes/remoteplugin.py @@ -91,9 +91,9 @@ class RemotesPlugin(Plugin): Information about this plugin """ about_text = translate('RemotePlugin', '<strong>Remote Plugin</strong>' - '<br />The remote plugin provides the ability to send messages to ' - 'a running version of OpenLP on a different computer via a web ' - 'browser or through the remote API.') + '<br />The remote plugin provides the ability to send messages to ' + 'a running version of OpenLP on a different computer via a web ' + 'browser or through the remote API.') return about_text def set_plugin_text_strings(self): diff --git a/openlp/plugins/songs/forms/authorsform.py b/openlp/plugins/songs/forms/authorsform.py index 5a3ee175d..89eaea0eb 100644 --- a/openlp/plugins/songs/forms/authorsform.py +++ b/openlp/plugins/songs/forms/authorsform.py @@ -52,8 +52,7 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog): """ Execute the dialog. - ``clear`` - Clear the form fields before displaying the dialog. + :param clear: Clear the form fields before displaying the dialog. """ if clear: self.first_name_edit.clear() @@ -69,8 +68,7 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog): When the first name is edited and the setting to automatically create a display name is True, then try to create a display name from the first and last names. - ``display_name`` - The text from the first_name_edit widget. + :param display_name: The text from the first_name_edit widget. """ if not self.auto_display_name: return @@ -85,8 +83,7 @@ class AuthorsForm(QtGui.QDialog, Ui_AuthorsDialog): When the last name is edited and the setting to automatically create a display name is True, then try to create a display name from the first and last names. - ``display_name`` - The text from the last_name_edit widget. + :param display_name: The text from the last_name_edit widget. """ if not self.auto_display_name: return diff --git a/openlp/plugins/songs/forms/duplicatesongremovalform.py b/openlp/plugins/songs/forms/duplicatesongremovalform.py index 2da9113d6..fc5e9a809 100644 --- a/openlp/plugins/songs/forms/duplicatesongremovalform.py +++ b/openlp/plugins/songs/forms/duplicatesongremovalform.py @@ -35,7 +35,7 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.common import Registry, translate +from openlp.core.common import Registry, RegistryProperties, translate from openlp.core.ui.wizard import OpenLPWizard, WizardStrings from openlp.plugins.songs.lib import delete_song from openlp.plugins.songs.lib.db import Song, MediaFile @@ -45,7 +45,7 @@ from openlp.plugins.songs.lib.songcompare import songs_probably_equal log = logging.getLogger(__name__) -class DuplicateSongRemovalForm(OpenLPWizard): +class DuplicateSongRemovalForm(OpenLPWizard, RegistryProperties): """ This is the Duplicate Song Removal Wizard. It provides functionality to search for and remove duplicate songs in the database. @@ -327,29 +327,4 @@ class DuplicateSongRemovalForm(OpenLPWizard): self.button(QtGui.QWizard.FinishButton).show() self.button(QtGui.QWizard.FinishButton).setEnabled(True) self.button(QtGui.QWizard.NextButton).hide() - self.button(QtGui.QWizard.CancelButton).hide() - - def _get_main_window(self): - """ - Adds the main window to the class dynamically. - """ - if not hasattr(self, '_main_window'): - self._main_window = Registry().get('main_window') - return self._main_window - - main_window = property(_get_main_window) - - def _get_application(self): - """ - Adds the openlp to the class dynamically. - Windows needs to access the application in a dynamic manner. - """ - if os.name == 'nt': - return Registry().get('application') - else: - if not hasattr(self, '_application'): - self._application = Registry().get('application') - return self._application - - application = property(_get_application) - + self.button(QtGui.QWizard.CancelButton).hide() \ No newline at end of file diff --git a/openlp/plugins/songs/forms/editsongdialog.py b/openlp/plugins/songs/forms/editsongdialog.py index 88576ca95..f2ef5af06 100644 --- a/openlp/plugins/songs/forms/editsongdialog.py +++ b/openlp/plugins/songs/forms/editsongdialog.py @@ -334,11 +334,8 @@ def create_combo_box(parent, name): """ Utility method to generate a standard combo box for this dialog. - ``parent`` - The parent widget for this combo box. - - ``name`` - The object name. + :param parent: The parent widget for this combo box. + :param name: The object name """ combo_box = QtGui.QComboBox(parent) combo_box.setSizeAdjustPolicy(QtGui.QComboBox.AdjustToMinimumContentsLength) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 4a4b772bc..06639fe18 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -38,7 +38,7 @@ import shutil from PyQt4 import QtCore, QtGui -from openlp.core.common import Registry, AppLocation, UiStrings, check_directory_exists, translate +from openlp.core.common import Registry, RegistryProperties, AppLocation, UiStrings, check_directory_exists, translate from openlp.core.lib import FileDialog, PluginStatus, MediaType, create_separated_list from openlp.core.lib.ui import set_case_insensitive_completer, critical_error_message_box, find_and_set_in_combo_box from openlp.plugins.songs.lib import VerseType, clean_song @@ -52,7 +52,7 @@ from openlp.plugins.songs.forms.mediafilesform import MediaFilesForm log = logging.getLogger(__name__) -class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): +class EditSongForm(QtGui.QDialog, Ui_EditSongDialog, RegistryProperties): """ Class to manage the editing of a song """ @@ -955,24 +955,4 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): log.exception('Could not remove directory: %s', save_path) clean_song(self.manager, self.song) self.manager.save_object(self.song) - self.media_item.auto_select_id = self.song.id - - def _get_plugin_manager(self): - """ - Adds the plugin manager to the class dynamically - """ - if not hasattr(self, '_plugin_manager'): - self._plugin_manager = Registry().get('plugin_manager') - return self._plugin_manager - - plugin_manager = property(_get_plugin_manager) - - def _get_theme_manager(self): - """ - Adds the theme manager to the class dynamically - """ - if not hasattr(self, '_theme_manager'): - self._theme_manager = Registry().get('theme_manager') - return self._theme_manager - - theme_manager = property(_get_theme_manager) + self.media_item.auto_select_id = self.song.id \ No newline at end of file diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index 4521ea1e4..e87c9f645 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -35,7 +35,7 @@ import os from PyQt4 import QtCore, QtGui -from openlp.core.common import Registry, Settings, UiStrings, translate +from openlp.core.common import RegistryProperties, Settings, UiStrings, translate from openlp.core.lib import FileDialog from openlp.core.lib.ui import critical_error_message_box from openlp.core.ui.wizard import OpenLPWizard, WizardStrings @@ -44,7 +44,7 @@ from openlp.plugins.songs.lib.importer import SongFormat, SongFormatSelect log = logging.getLogger(__name__) -class SongImportForm(OpenLPWizard): +class SongImportForm(OpenLPWizard, RegistryProperties): """ This is the Song Import Wizard, which allows easy importing of Songs into OpenLP from other formats like OpenLyrics, OpenSong and CCLI. @@ -480,26 +480,6 @@ class SongImportForm(OpenLPWizard): self.format_widgets[this_format]['import_widget'] = import_widget return import_widget - def _get_main_window(self): - """ - Adds the main window to the class dynamically - """ - if not hasattr(self, '_main_window'): - self._main_window = Registry().get('main_window') - return self._main_window - - main_window = property(_get_main_window) - - def _get_main_window(self): - """ - Adds the main window to the class dynamically - """ - if not hasattr(self, '_main_window'): - self._main_window = Registry().get('main_window') - return self._main_window - - main_window = property(_get_main_window) - class SongImportSourcePage(QtGui.QWizardPage): """ diff --git a/openlp/plugins/songs/forms/songmaintenanceform.py b/openlp/plugins/songs/forms/songmaintenanceform.py index c4e158727..8f92e9cae 100644 --- a/openlp/plugins/songs/forms/songmaintenanceform.py +++ b/openlp/plugins/songs/forms/songmaintenanceform.py @@ -32,7 +32,7 @@ import os from PyQt4 import QtGui, QtCore from sqlalchemy.sql import and_ -from openlp.core.common import Registry, UiStrings, translate +from openlp.core.common import Registry, RegistryProperties, UiStrings, translate from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.songs.forms.authorsform import AuthorsForm from openlp.plugins.songs.forms.topicsform import TopicsForm @@ -43,7 +43,7 @@ from .songmaintenancedialog import Ui_SongMaintenanceDialog log = logging.getLogger(__name__) -class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): +class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog, RegistryProperties): """ Class documentation goes here. """ @@ -82,8 +82,8 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): """ Show the dialog. - ``from_song_edit`` - Indicates if the maintenance dialog has been opened from song edit + + :param from_song_edit: Indicates if the maintenance dialog has been opened from song edit or from the media manager. Defaults to **False**. """ self.from_song_edit = from_song_edit @@ -531,18 +531,4 @@ class SongMaintenanceForm(QtGui.QDialog, Ui_SongMaintenanceDialog): edit_button.setEnabled(False) else: delete_button.setEnabled(True) - edit_button.setEnabled(True) - - def _get_application(self): - """ - Adds the openlp to the class dynamically. - Windows needs to access the application in a dynamic manner. - """ - if os.name == 'nt': - return Registry().get('application') - else: - if not hasattr(self, '_application'): - self._application = Registry().get('application') - return self._application - - application = property(_get_application) + edit_button.setEnabled(True) \ No newline at end of file diff --git a/openlp/plugins/songs/forms/songreviewwidget.py b/openlp/plugins/songs/forms/songreviewwidget.py index 3689e2d49..839174009 100644 --- a/openlp/plugins/songs/forms/songreviewwidget.py +++ b/openlp/plugins/songs/forms/songreviewwidget.py @@ -58,11 +58,8 @@ class SongReviewWidget(QtGui.QWidget): def __init__(self, parent, song): """ - ``parent`` - The QWidget-derived parent of the wizard. - - ``song`` - The Song which this SongReviewWidget should represent. + :param parent: The QWidget-derived parent of the wizard. + :param song: The Song which this SongReviewWidget should represent. """ super(SongReviewWidget, self).__init__(parent) self.song = song diff --git a/openlp/plugins/songs/lib/db.py b/openlp/plugins/songs/lib/db.py index 4f5712012..ad5bee1a1 100644 --- a/openlp/plugins/songs/lib/db.py +++ b/openlp/plugins/songs/lib/db.py @@ -92,9 +92,7 @@ def init_schema(url): """ Setup the songs database connection and initialise the database schema. - ``url`` - The database to setup - + :param url: The database to setup The song database contains the following tables: * authors diff --git a/openlp/plugins/songs/lib/foilpresenterimport.py b/openlp/plugins/songs/lib/foilpresenterimport.py index 5c88cc6a3..3b6d4e9a8 100644 --- a/openlp/plugins/songs/lib/foilpresenterimport.py +++ b/openlp/plugins/songs/lib/foilpresenterimport.py @@ -211,8 +211,7 @@ class FoilPresenter(object): """ Create and save a song from Foilpresenter format xml to the database. - ``xml`` - The XML to parse (unicode). + :param xml: The XML to parse (unicode). """ # No xml get out of here. if not xml: diff --git a/openlp/plugins/songs/lib/importer.py b/openlp/plugins/songs/lib/importer.py index 0d05d1fd3..662f73bf8 100644 --- a/openlp/plugins/songs/lib/importer.py +++ b/openlp/plugins/songs/lib/importer.py @@ -361,11 +361,8 @@ class SongFormat(object): """ Return requested song format attribute(s). - ``format`` - A song format from SongFormat. - - ``*attributes`` - Zero or more song format attributes from SongFormat. + :param format: A song format from SongFormat. + :param attributes: Zero or more song format attributes from SongFormat. Return type depends on number of supplied attributes: diff --git a/openlp/plugins/songs/lib/olpimport.py b/openlp/plugins/songs/lib/olpimport.py index 0dae2d5d0..171859432 100644 --- a/openlp/plugins/songs/lib/olpimport.py +++ b/openlp/plugins/songs/lib/olpimport.py @@ -65,8 +65,7 @@ class OpenLPSongImport(SongImport): """ Run the import for an OpenLP version 2 song database. - ``progress_dialog`` - The QProgressDialog used when importing songs from the FRW. + :param progress_dialog: The QProgressDialog used when importing songs from the FRW. """ class OldAuthor(BaseModel): diff --git a/openlp/plugins/songs/lib/openlyricsexport.py b/openlp/plugins/songs/lib/openlyricsexport.py index ff4c475f3..735ef3afe 100644 --- a/openlp/plugins/songs/lib/openlyricsexport.py +++ b/openlp/plugins/songs/lib/openlyricsexport.py @@ -35,14 +35,14 @@ import os from lxml import etree -from openlp.core.common import Registry, check_directory_exists, translate +from openlp.core.common import RegistryProperties, check_directory_exists, translate from openlp.core.utils import clean_filename from openlp.plugins.songs.lib.xml import OpenLyrics log = logging.getLogger(__name__) -class OpenLyricsExport(object): +class OpenLyricsExport(RegistryProperties): """ This provides the Openlyrics export. """ @@ -82,16 +82,3 @@ class OpenLyricsExport(object): pretty_print=True) return True - def _get_application(self): - """ - Adds the openlp to the class dynamically. - Windows needs to access the application in a dynamic manner. - """ - if os.name == 'nt': - return Registry().get('application') - else: - if not hasattr(self, '_application'): - self._application = Registry().get('application') - return self._application - - application = property(_get_application) diff --git a/openlp/plugins/songusage/forms/songusagedeleteform.py b/openlp/plugins/songusage/forms/songusagedeleteform.py index c3446cdd3..f7c05e0e6 100644 --- a/openlp/plugins/songusage/forms/songusagedeleteform.py +++ b/openlp/plugins/songusage/forms/songusagedeleteform.py @@ -29,12 +29,12 @@ from PyQt4 import QtGui -from openlp.core.common import Registry, translate +from openlp.core.common import RegistryProperties, translate from openlp.plugins.songusage.lib.db import SongUsageItem from .songusagedeletedialog import Ui_SongUsageDeleteDialog -class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog): +class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog, RegistryProperties): """ Class documentation goes here. """ @@ -70,14 +70,4 @@ class SongUsageDeleteForm(QtGui.QDialog, Ui_SongUsageDeleteDialog): ) self.accept() else: - self.reject() - - def _get_main_window(self): - """ - Adds the main window to the class dynamically - """ - if not hasattr(self, '_main_window'): - self._main_window = Registry().get('main_window') - return self._main_window - - main_window = property(_get_main_window) + self.reject() \ No newline at end of file diff --git a/openlp/plugins/songusage/forms/songusagedetailform.py b/openlp/plugins/songusage/forms/songusagedetailform.py index 2e96a4eb6..eb5963228 100644 --- a/openlp/plugins/songusage/forms/songusagedetailform.py +++ b/openlp/plugins/songusage/forms/songusagedetailform.py @@ -33,14 +33,14 @@ import os from PyQt4 import QtGui from sqlalchemy.sql import and_ -from openlp.core.common import Registry, Settings, check_directory_exists, translate +from openlp.core.common import RegistryProperties, Settings, check_directory_exists, translate from openlp.plugins.songusage.lib.db import SongUsageItem from .songusagedetaildialog import Ui_SongUsageDetailDialog log = logging.getLogger(__name__) -class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): +class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog, RegistryProperties): """ Class documentation goes here. """ @@ -118,13 +118,3 @@ class SongUsageDetailForm(QtGui.QDialog, Ui_SongUsageDetailDialog): if file_handle: file_handle.close() self.close() - - def _get_main_window(self): - """ - Adds the main window to the class dynamically - """ - if not hasattr(self, '_main_window'): - self._main_window = Registry().get('main_window') - return self._main_window - - main_window = property(_get_main_window) diff --git a/setup.py b/setup.py index fcdc28195..276188188 100755 --- a/setup.py +++ b/setup.py @@ -41,8 +41,7 @@ def try_int(s): Convert string s to an integer if possible. Fail silently and return the string as-is if it isn't an integer. - ``s`` - The string to try to convert. + :param s: The string to try to convert. """ try: return int(s) @@ -54,8 +53,7 @@ def natural_sort_key(s): """ Return a tuple by which s is sorted. - ``s`` - A string value from the list we want to sort. + :param s: A string value from the list we want to sort. """ return list(map(try_int, SPLIT_ALPHA_DIGITS.findall(s))) @@ -64,11 +62,8 @@ def natural_compare(a, b): """ Compare two strings naturally and return the result. - ``a`` - A string to compare. - - ``b`` - A string to compare. + :param a: A string to compare. + :param b: A string to compare. """ return cmp(natural_sort_key(a), natural_sort_key(b)) diff --git a/tests/functional/__init__.py b/tests/functional/__init__.py index d20aae496..7449a80ca 100644 --- a/tests/functional/__init__.py +++ b/tests/functional/__init__.py @@ -1,4 +1,31 @@ # -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### """ Base directory for tests """ diff --git a/tests/functional/openlp_core_common/test_registryproperties.py b/tests/functional/openlp_core_common/test_registryproperties.py index d12975f43..441860544 100644 --- a/tests/functional/openlp_core_common/test_registryproperties.py +++ b/tests/functional/openlp_core_common/test_registryproperties.py @@ -41,17 +41,23 @@ class TestRegistryProperties(TestCase, RegistryProperties): """ def setUp(self): """ - Create the UI + Create the Register """ Registry.create() def no_application_test(self): + """ + Test property if no registry value assigned + """ # GIVEN an Empty Registry # WHEN there is no Application # THEN the application should be none self.assertEquals(self.application, None, 'The application value should be None') def application_test(self): + """ + Test property if registry value assigned + """ # GIVEN an Empty Registry application = MagicMock() # WHEN the application is registered diff --git a/tests/functional/openlp_core_common/test_settings.py b/tests/functional/openlp_core_common/test_settings.py index 8f7d235f7..8c2ef92d6 100644 --- a/tests/functional/openlp_core_common/test_settings.py +++ b/tests/functional/openlp_core_common/test_settings.py @@ -29,16 +29,13 @@ """ Package to test the openlp.core.lib.settings package. """ -import os -from tempfile import mkstemp - from unittest import TestCase -from PyQt4 import QtGui from openlp.core.common import Settings +from tests.helpers.testmixin import TestMixin -class TestSettings(TestCase): +class TestSettings(TestCase, TestMixin): """ Test the functions in the Settings module """ @@ -46,18 +43,14 @@ class TestSettings(TestCase): """ Create the UI """ - Settings.setDefaultFormat(Settings.IniFormat) - self.fd, self.ini_file = mkstemp('.ini') - Settings().set_filename(self.ini_file) - self.application = QtGui.QApplication.instance() + self.get_application() + self.build_settings() def tearDown(self): """ Delete all the C++ objects at the end so that we don't have a segfault """ - del self.application - os.close(self.fd) - os.unlink(Settings().fileName()) + self.destroy_settings() def settings_basic_test(self): """ diff --git a/tests/functional/openlp_core_lib/__init__.py b/tests/functional/openlp_core_lib/__init__.py index e69de29bb..70585a1d1 100644 --- a/tests/functional/openlp_core_lib/__init__.py +++ b/tests/functional/openlp_core_lib/__init__.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### +""" +Package to test the openlp.core.lib package. +""" \ No newline at end of file diff --git a/tests/functional/openlp_core_lib/test_file_dialog.py b/tests/functional/openlp_core_lib/test_file_dialog.py index f42a865d7..1d8040525 100644 --- a/tests/functional/openlp_core_lib/test_file_dialog.py +++ b/tests/functional/openlp_core_lib/test_file_dialog.py @@ -7,6 +7,7 @@ from openlp.core.common import UiStrings from openlp.core.lib.filedialog import FileDialog from tests.functional import MagicMock, patch + class TestFileDialog(TestCase): """ Test the functions in the :mod:`filedialog` module. @@ -46,7 +47,7 @@ class TestFileDialog(TestCase): def returned_file_list_test(self): """ Test that FileDialog.getOpenFileNames handles a list of files properly when QFileList.getOpenFileNames - returns a good file name, a urlencoded file name and a non-existing file + returns a good file name, a url encoded file name and a non-existing file """ self.mocked_os.rest() self.mocked_qt_gui.reset() @@ -62,7 +63,7 @@ class TestFileDialog(TestCase): result = FileDialog.getOpenFileNames(self.mocked_parent) # THEN: os.path.exists should have been called with known args. QmessageBox.information should have been - # called. The returned result should corrilate with the input. + # called. The returned result should correlate with the input. self.mocked_os.path.exists.assert_callde_with('/Valid File') self.mocked_os.path.exists.assert_callde_with('/url%20encoded%20file%20%231') self.mocked_os.path.exists.assert_callde_with('/url encoded file #1') diff --git a/tests/functional/openlp_core_lib/test_image_manager.py b/tests/functional/openlp_core_lib/test_image_manager.py index a55aede59..3aa539a11 100644 --- a/tests/functional/openlp_core_lib/test_image_manager.py +++ b/tests/functional/openlp_core_lib/test_image_manager.py @@ -36,18 +36,19 @@ from PyQt4 import QtGui from openlp.core.common import Registry from openlp.core.lib import ImageManager, ScreenList +from tests.helpers.testmixin import TestMixin TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'resources')) -class TestImageManager(TestCase): +class TestImageManager(TestCase, TestMixin): def setUp(self): """ Create the UI """ Registry.create() - self.app = QtGui.QApplication.instance() + self.get_application() ScreenList.create(self.app.desktop()) self.image_manager = ImageManager() diff --git a/tests/functional/openlp_core_utils/__init__.py b/tests/functional/openlp_core_utils/__init__.py index e69de29bb..1f4f74a33 100644 --- a/tests/functional/openlp_core_utils/__init__.py +++ b/tests/functional/openlp_core_utils/__init__.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### \ No newline at end of file diff --git a/tests/functional/openlp_core_utils/test_actions.py b/tests/functional/openlp_core_utils/test_actions.py index 915f1e24d..092c96ac1 100644 --- a/tests/functional/openlp_core_utils/test_actions.py +++ b/tests/functional/openlp_core_utils/test_actions.py @@ -29,17 +29,16 @@ """ Package to test the openlp.core.utils.actions package. """ -import os -from tempfile import mkstemp from unittest import TestCase from PyQt4 import QtGui, QtCore from openlp.core.common import Settings from openlp.core.utils import ActionList +from tests.helpers.testmixin import TestMixin -class TestActionList(TestCase): +class TestActionList(TestCase, TestMixin): """ Test the ActionList class """ @@ -49,10 +48,8 @@ class TestActionList(TestCase): Prepare the tests """ self.action_list = ActionList.get_instance() - Settings.setDefaultFormat(Settings.IniFormat) + self.build_settings() self.settings = Settings() - self.fd, self.ini_file = mkstemp('.ini') - self.settings.set_filename(self.ini_file) self.settings.beginGroup('shortcuts') def tearDown(self): @@ -60,8 +57,7 @@ class TestActionList(TestCase): Clean up """ self.settings.endGroup() - os.close(self.fd) - os.unlink(Settings().fileName()) + self.destroy_settings() def test_add_action_same_parent(self): """ diff --git a/tests/functional/openlp_plugins/__init__.py b/tests/functional/openlp_plugins/__init__.py index 33507f08b..6b241e7fc 100644 --- a/tests/functional/openlp_plugins/__init__.py +++ b/tests/functional/openlp_plugins/__init__.py @@ -1 +1,28 @@ -__author__ = 'raoul' +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### diff --git a/tests/functional/openlp_plugins/bibles/__init__.py b/tests/functional/openlp_plugins/bibles/__init__.py index 1f4f74a33..4c8c00fec 100644 --- a/tests/functional/openlp_plugins/bibles/__init__.py +++ b/tests/functional/openlp_plugins/bibles/__init__.py @@ -25,4 +25,5 @@ # 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 # -############################################################################### \ No newline at end of file +############################################################################### + diff --git a/tests/functional/openlp_plugins/bibles/test_http.py b/tests/functional/openlp_plugins/bibles/test_http.py index 0878914cd..9a1be8d0e 100644 --- a/tests/functional/openlp_plugins/bibles/test_http.py +++ b/tests/functional/openlp_plugins/bibles/test_http.py @@ -63,6 +63,7 @@ from openlp.plugins.bibles.lib.http import BSExtract # get_soup_for_bible_ref # send_error_message + class TestBSExtract(TestCase): """ Test the BSExtractClass diff --git a/tests/functional/openlp_plugins/bibles/test_versereferencelist.py b/tests/functional/openlp_plugins/bibles/test_versereferencelist.py index 8b7c3f786..5fc9d9e84 100644 --- a/tests/functional/openlp_plugins/bibles/test_versereferencelist.py +++ b/tests/functional/openlp_plugins/bibles/test_versereferencelist.py @@ -49,7 +49,7 @@ class TestVerseReferenceList(TestCase): verse = 1 version = 'testVersion' copyright_ = 'testCopyright' - permission = 'testPermision' + permission = 'testPermission' # WHEN: We add it to the verse list reference_list.add(book, chapter, verse, version, copyright_, permission) @@ -57,9 +57,11 @@ class TestVerseReferenceList(TestCase): # THEN: The entries should be in the first entry of the list self.assertEqual(reference_list.current_index, 0, 'The current index should be 0') self.assertEqual(reference_list.verse_list[0]['book'], book, 'The book in first entry should be %s' % book) - self.assertEqual(reference_list.verse_list[0]['chapter'], chapter, 'The chapter in first entry should be %u' % chapter) + self.assertEqual(reference_list.verse_list[0]['chapter'], chapter, 'The chapter in first entry should be %u' % + chapter) self.assertEqual(reference_list.verse_list[0]['start'], verse, 'The start in first entry should be %u' % verse) - self.assertEqual(reference_list.verse_list[0]['version'], version, 'The version in first entry should be %s' % version) + self.assertEqual(reference_list.verse_list[0]['version'], version, 'The version in first entry should be %s' % + version) self.assertEqual(reference_list.verse_list[0]['end'], verse, 'The end in first entry should be %u' % verse) def add_next_verse_test(self): @@ -73,7 +75,7 @@ class TestVerseReferenceList(TestCase): next_verse = 2 version = 'testVersion' copyright_ = 'testCopyright' - permission = 'testPermision' + permission = 'testPermission' reference_list = VerseReferenceList() reference_list.add(book, chapter, verse, version, copyright_, permission) @@ -98,7 +100,7 @@ class TestVerseReferenceList(TestCase): another_verse = 5 version = 'testVersion' copyright_ = 'testCopyright' - permission = 'testPermision' + permission = 'testPermission' reference_list = VerseReferenceList() reference_list.add(book, chapter, verse, version, copyright_, permission) @@ -116,7 +118,7 @@ class TestVerseReferenceList(TestCase): reference_list = VerseReferenceList() version = 'testVersion' copyright_ = 'testCopyright' - permission = 'testPermision' + permission = 'testPermission' # WHEN: a not existing version will be added reference_list.add_version(version, copyright_, permission) @@ -135,7 +137,7 @@ class TestVerseReferenceList(TestCase): reference_list = VerseReferenceList() version = 'testVersion' copyright_ = 'testCopyright' - permission = 'testPermision' + permission = 'testPermission' reference_list.add_version(version, copyright_, permission) # WHEN: an existing version will be added diff --git a/tests/functional/openlp_plugins/images/__init__.py b/tests/functional/openlp_plugins/images/__init__.py index e69de29bb..1f4f74a33 100644 --- a/tests/functional/openlp_plugins/images/__init__.py +++ b/tests/functional/openlp_plugins/images/__init__.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### \ No newline at end of file diff --git a/tests/functional/openlp_plugins/presentations/__init__.py b/tests/functional/openlp_plugins/presentations/__init__.py index e69de29bb..1f4f74a33 100644 --- a/tests/functional/openlp_plugins/presentations/__init__.py +++ b/tests/functional/openlp_plugins/presentations/__init__.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### \ No newline at end of file diff --git a/tests/functional/openlp_plugins/presentations/test_mediaitem.py b/tests/functional/openlp_plugins/presentations/test_mediaitem.py index 0b2cf184c..2210c7d1f 100644 --- a/tests/functional/openlp_plugins/presentations/test_mediaitem.py +++ b/tests/functional/openlp_plugins/presentations/test_mediaitem.py @@ -31,14 +31,13 @@ This module contains tests for the lib submodule of the Presentations plugin. """ from unittest import TestCase -from PyQt4 import QtGui - from openlp.core.common import Registry from openlp.plugins.presentations.lib.mediaitem import PresentationMediaItem from tests.functional import patch, MagicMock +from tests.helpers.testmixin import TestMixin -class TestMediaItem(TestCase): +class TestMediaItem(TestCase, TestMixin): """ Test the mediaitem methods. """ @@ -52,13 +51,7 @@ class TestMediaItem(TestCase): with patch('openlp.plugins.presentations.lib.mediaitem.MediaManagerItem._setup'), \ patch('openlp.plugins.presentations.lib.mediaitem.PresentationMediaItem.setup_item'): self.media_item = PresentationMediaItem(None, MagicMock, MagicMock()) - self.application = QtGui.QApplication.instance() - - def tearDown(self): - """ - Delete all the C++ objects at the end so that we don't have a segfault - """ - del self.application + self.get_application() def build_file_mask_string_test(self): """ diff --git a/tests/functional/openlp_plugins/presentations/test_pdfcontroller.py b/tests/functional/openlp_plugins/presentations/test_pdfcontroller.py index ac4e812a0..65c7bf916 100644 --- a/tests/functional/openlp_plugins/presentations/test_pdfcontroller.py +++ b/tests/functional/openlp_plugins/presentations/test_pdfcontroller.py @@ -32,22 +32,21 @@ This module contains tests for the PdfController import os import shutil from unittest import TestCase, SkipTest -from tempfile import mkstemp, mkdtemp - -from PyQt4 import QtGui +from tempfile import mkdtemp from openlp.plugins.presentations.lib.pdfcontroller import PdfController, PdfDocument from tests.functional import MagicMock from openlp.core.common import Settings from openlp.core.lib import ScreenList from tests.utils.constants import TEST_RESOURCES_PATH +from tests.helpers.testmixin import TestMixin __default_settings__ = { 'presentations/enable_pdf_program': False } -class TestPdfController(TestCase): +class TestPdfController(TestCase, TestMixin): """ Test the PdfController. """ @@ -55,11 +54,9 @@ class TestPdfController(TestCase): """ Set up the components need for all tests. """ - Settings.setDefaultFormat(Settings.IniFormat) - self.fd, self.ini_file = mkstemp('.ini') - Settings().set_filename(self.ini_file) - self.application = QtGui.QApplication.instance() - ScreenList.create(self.application.desktop()) + self.get_application() + self.build_settings() + ScreenList.create(self.app.desktop()) Settings().extend_default_settings(__default_settings__) self.temp_folder = mkdtemp() self.thumbnail_folder = mkdtemp() @@ -70,10 +67,8 @@ class TestPdfController(TestCase): """ Delete all the C++ objects at the end so that we don't have a segfault """ - del self.application try: - os.close(self.fd) - os.unlink(Settings().fileName()) + self.destroy_settings() shutil.rmtree(self.thumbnail_folder) shutil.rmtree(self.temp_folder) except OSError: diff --git a/tests/functional/openlp_plugins/remotes/__init__.py b/tests/functional/openlp_plugins/remotes/__init__.py index e69de29bb..1f4f74a33 100644 --- a/tests/functional/openlp_plugins/remotes/__init__.py +++ b/tests/functional/openlp_plugins/remotes/__init__.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### \ No newline at end of file diff --git a/tests/functional/openlp_plugins/remotes/test_remotetab.py b/tests/functional/openlp_plugins/remotes/test_remotetab.py index ca965d234..7560c9ea7 100644 --- a/tests/functional/openlp_plugins/remotes/test_remotetab.py +++ b/tests/functional/openlp_plugins/remotes/test_remotetab.py @@ -32,13 +32,13 @@ This module contains tests for the lib submodule of the Remotes plugin. import os import re from unittest import TestCase -from tempfile import mkstemp from PyQt4 import QtGui from openlp.core.common import Settings from openlp.plugins.remotes.lib.remotetab import RemoteTab from tests.functional import patch +from tests.helpers.testmixin import TestMixin __default_settings__ = { 'remotes/twelve hour': True, @@ -54,7 +54,7 @@ ZERO_URL = '0.0.0.0' TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources')) -class TestRemoteTab(TestCase): +class TestRemoteTab(TestCase, TestMixin): """ Test the functions in the :mod:`lib` module. """ @@ -62,10 +62,8 @@ class TestRemoteTab(TestCase): """ Create the UI """ - Settings.setDefaultFormat(Settings.IniFormat) - self.fd, self.ini_file = mkstemp('.ini') - Settings().set_filename(self.ini_file) - self.application = QtGui.QApplication.instance() + self.get_application() + self.build_settings() Settings().extend_default_settings(__default_settings__) self.parent = QtGui.QMainWindow() self.form = RemoteTab(self.parent, 'Remotes', None, None) @@ -74,11 +72,9 @@ class TestRemoteTab(TestCase): """ Delete all the C++ objects at the end so that we don't have a segfault """ - del self.application del self.parent del self.form - os.close(self.fd) - os.unlink(Settings().fileName()) + self.destroy_settings() def get_ip_address_default_test(self): """ diff --git a/tests/functional/openlp_plugins/remotes/test_router.py b/tests/functional/openlp_plugins/remotes/test_router.py index ef4be045d..6d8e5de95 100644 --- a/tests/functional/openlp_plugins/remotes/test_router.py +++ b/tests/functional/openlp_plugins/remotes/test_router.py @@ -32,14 +32,12 @@ This module contains tests for the lib submodule of the Remotes plugin. import os import urllib.request from unittest import TestCase -from tempfile import mkstemp - -from PyQt4 import QtGui from openlp.core.common import Settings, Registry from openlp.plugins.remotes.lib.httpserver import HttpRouter from urllib.parse import urlparse from tests.functional import MagicMock, patch, mock_open +from tests.helpers.testmixin import TestMixin __default_settings__ = { 'remotes/twelve hour': True, @@ -55,7 +53,7 @@ __default_settings__ = { TEST_PATH = os.path.abspath(os.path.dirname(__file__)) -class TestRouter(TestCase): +class TestRouter(TestCase, TestMixin): """ Test the functions in the :mod:`lib` module. """ @@ -63,10 +61,8 @@ class TestRouter(TestCase): """ Create the UI """ - Settings.setDefaultFormat(Settings.IniFormat) - self.fd, self.ini_file = mkstemp('.ini') - Settings().set_filename(self.ini_file) - self.application = QtGui.QApplication.instance() + self.get_application() + self.build_settings() Settings().extend_default_settings(__default_settings__) self.router = HttpRouter() @@ -74,9 +70,7 @@ class TestRouter(TestCase): """ Delete all the C++ objects at the end so that we don't have a segfault """ - del self.application - os.close(self.fd) - os.unlink(Settings().fileName()) + self.destroy_settings() def password_encrypter_test(self): """ diff --git a/tests/functional/openlp_plugins/songs/__init__.py b/tests/functional/openlp_plugins/songs/__init__.py index 70026715f..40cf4e763 100644 --- a/tests/functional/openlp_plugins/songs/__init__.py +++ b/tests/functional/openlp_plugins/songs/__init__.py @@ -1,3 +1,31 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### """ Tests for the Songs plugin """ diff --git a/tests/functional/openlp_plugins/songs/test_mediaitem.py b/tests/functional/openlp_plugins/songs/test_mediaitem.py index 2fe812eb9..2b5f02483 100644 --- a/tests/functional/openlp_plugins/songs/test_mediaitem.py +++ b/tests/functional/openlp_plugins/songs/test_mediaitem.py @@ -11,9 +11,10 @@ from openlp.core.common import Registry, Settings from openlp.core.lib import ServiceItem from openlp.plugins.songs.lib.mediaitem import SongMediaItem from tests.functional import patch, MagicMock +from tests.helpers.testmixin import TestMixin -class TestMediaItem(TestCase): +class TestMediaItem(TestCase, TestMixin): """ Test the functions in the :mod:`lib` module. """ @@ -27,24 +28,15 @@ class TestMediaItem(TestCase): with patch('openlp.core.lib.mediamanageritem.MediaManagerItem._setup'), \ patch('openlp.plugins.songs.forms.editsongform.EditSongForm.__init__'): self.media_item = SongMediaItem(None, MagicMock()) - - Settings.setDefaultFormat(Settings.IniFormat) - self.fd, self.ini_file = mkstemp('.ini') - Settings().set_filename(self.ini_file) - self.application = QtGui.QApplication.instance() + self.get_application() + self.build_settings() QtCore.QLocale.setDefault(QtCore.QLocale('en_GB')) def tearDown(self): """ Delete all the C++ objects at the end so that we don't have a segfault """ - del self.application - # Not all tests use settings! - try: - os.close(self.fd) - os.unlink(Settings().fileName()) - except Exception: - pass + self.destroy_settings() def build_song_footer_one_author_test(self): """ diff --git a/tests/helpers/testmixin.py b/tests/helpers/testmixin.py index 69b5704e7..bda6d7291 100644 --- a/tests/helpers/testmixin.py +++ b/tests/helpers/testmixin.py @@ -39,6 +39,9 @@ from openlp.core.common import Settings class TestMixin(object): def get_application(self): + """ + Build or reuse the Application object + """ old_app_instance = QtCore.QCoreApplication.instance() if old_app_instance is None: self.app = QtGui.QApplication([]) @@ -46,11 +49,17 @@ class TestMixin(object): self.app = old_app_instance def build_settings(self): + """ + Build the settings Object and initialise it + """ Settings.setDefaultFormat(Settings.IniFormat) fd, self.ini_file = mkstemp('.ini') Settings().set_filename(self.ini_file) def destroy_settings(self): + """ + Destroy the Settings Object + """ if hasattr(self, 'fd'): os.close(self.fd) os.unlink(Settings().fileName()) diff --git a/tests/interfaces/__init__.py b/tests/interfaces/__init__.py index 7ba934446..2002486cc 100644 --- a/tests/interfaces/__init__.py +++ b/tests/interfaces/__init__.py @@ -1,4 +1,31 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# 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 sip sip.setapi('QDate', 2) sip.setapi('QDateTime', 2) diff --git a/tests/interfaces/openlp_core_lib/__init__.py b/tests/interfaces/openlp_core_lib/__init__.py index e69de29bb..1f4f74a33 100644 --- a/tests/interfaces/openlp_core_lib/__init__.py +++ b/tests/interfaces/openlp_core_lib/__init__.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### \ No newline at end of file diff --git a/tests/interfaces/openlp_core_lib/test_pluginmanager.py b/tests/interfaces/openlp_core_lib/test_pluginmanager.py index c1b7348f9..2949a46fb 100644 --- a/tests/interfaces/openlp_core_lib/test_pluginmanager.py +++ b/tests/interfaces/openlp_core_lib/test_pluginmanager.py @@ -1,20 +1,48 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### """ Package to test the openlp.core.lib.pluginmanager package. """ -import os import sys import shutil -from tempfile import mkstemp, mkdtemp +from tempfile import mkdtemp from unittest import TestCase -from PyQt4 import QtGui, QtCore +from PyQt4 import QtGui from openlp.core.common import Registry, Settings from openlp.core.lib.pluginmanager import PluginManager from tests.interfaces import MagicMock +from tests.helpers.testmixin import TestMixin -class TestPluginManager(TestCase): +class TestPluginManager(TestCase, TestMixin): """ Test the PluginManager class """ @@ -24,25 +52,19 @@ class TestPluginManager(TestCase): Some pre-test setup required. """ Settings.setDefaultFormat(Settings.IniFormat) - self.fd, self.ini_file = mkstemp('.ini') + self.build_settings() self.temp_dir = mkdtemp('openlp') - Settings().set_filename(self.ini_file) Settings().setValue('advanced/data path', self.temp_dir) Registry.create() Registry().register('service_list', MagicMock()) - old_app_instance = QtCore.QCoreApplication.instance() - if old_app_instance is None: - self.app = QtGui.QApplication([]) - else: - self.app = old_app_instance + self.get_application() self.main_window = QtGui.QMainWindow() Registry().register('main_window', self.main_window) def tearDown(self): del self.main_window - os.close(self.fd) - os.unlink(Settings().fileName()) Settings().remove('advanced/data path') + self.destroy_settings() shutil.rmtree(self.temp_dir) def find_plugins_test(self): diff --git a/tests/interfaces/openlp_core_ui/__init__.py b/tests/interfaces/openlp_core_ui/__init__.py index 8b1378917..6b241e7fc 100644 --- a/tests/interfaces/openlp_core_ui/__init__.py +++ b/tests/interfaces/openlp_core_ui/__init__.py @@ -1 +1,28 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### diff --git a/tests/interfaces/openlp_core_ui/test_filerenamedialog.py b/tests/interfaces/openlp_core_ui/test_filerenamedialog.py index 3bba2b19b..905f167e9 100644 --- a/tests/interfaces/openlp_core_ui/test_filerenamedialog.py +++ b/tests/interfaces/openlp_core_ui/test_filerenamedialog.py @@ -31,7 +31,7 @@ """ from unittest import TestCase -from PyQt4 import QtCore, QtGui, QtTest +from PyQt4 import QtGui, QtTest from openlp.core.common import Registry from openlp.core.ui import filerenameform diff --git a/tests/interfaces/openlp_core_ui/test_listpreviewwidget.py b/tests/interfaces/openlp_core_ui/test_listpreviewwidget.py index 7b91ce152..aced3127f 100644 --- a/tests/interfaces/openlp_core_ui/test_listpreviewwidget.py +++ b/tests/interfaces/openlp_core_ui/test_listpreviewwidget.py @@ -1,30 +1,55 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### """ Package to test the openlp.core.ui.listpreviewwidget. """ from unittest import TestCase -from PyQt4 import QtGui, QtCore +from PyQt4 import QtGui from openlp.core.common import Registry from openlp.core.lib import ServiceItem from openlp.core.ui import listpreviewwidget from tests.interfaces import MagicMock, patch from tests.utils.osdinteraction import read_service_from_file +from tests.helpers.testmixin import TestMixin -class TestListPreviewWidget(TestCase): +class TestListPreviewWidget(TestCase, TestMixin): def setUp(self): """ Create the UI. """ Registry.create() - old_app_instance = QtCore.QCoreApplication.instance() - if old_app_instance is None: - self.app = QtGui.QApplication([]) - else: - self.app = old_app_instance + self.get_application() self.main_window = QtGui.QMainWindow() self.image = QtGui.QImage(1, 1, QtGui.QImage.Format_RGB32) self.image_manager = MagicMock() diff --git a/tests/interfaces/openlp_core_ui/test_mainwindow.py b/tests/interfaces/openlp_core_ui/test_mainwindow.py index db55f53ec..de5452632 100644 --- a/tests/interfaces/openlp_core_ui/test_mainwindow.py +++ b/tests/interfaces/openlp_core_ui/test_mainwindow.py @@ -1,16 +1,44 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### """ Package to test the openlp.core.ui.mainwindow package. """ from unittest import TestCase -from PyQt4 import QtGui, QtCore from openlp.core.common import Registry from openlp.core.ui.mainwindow import MainWindow from tests.interfaces import MagicMock, patch +from tests.helpers.testmixin import TestMixin -class TestMainWindow(TestCase): +class TestMainWindow(TestCase, TestMixin): def setUp(self): """ @@ -18,11 +46,7 @@ class TestMainWindow(TestCase): """ Registry.create() self.registry = Registry() - old_app_instance = QtCore.QCoreApplication.instance() - if old_app_instance is None: - self.app = QtGui.QApplication([]) - else: - self.app = old_app_instance + self.get_application() # Mock cursor busy/normal methods. self.app.set_busy_cursor = MagicMock() self.app.set_normal_cursor = MagicMock() diff --git a/tests/interfaces/openlp_core_ui/test_servicemanager.py b/tests/interfaces/openlp_core_ui/test_servicemanager.py index 933f66f32..f4f5f26fc 100644 --- a/tests/interfaces/openlp_core_ui/test_servicemanager.py +++ b/tests/interfaces/openlp_core_ui/test_servicemanager.py @@ -1,29 +1,52 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### """ Package to test the openlp.core.lib package. """ from unittest import TestCase -from PyQt4 import QtGui, QtTest, QtCore - from openlp.core.common import Registry from openlp.core.lib import ScreenList, ServiceItem, ItemCapabilities from openlp.core.ui.mainwindow import MainWindow from tests.interfaces import MagicMock, patch +from tests.helpers.testmixin import TestMixin -class TestServiceManager(TestCase): +class TestServiceManager(TestCase, TestMixin): def setUp(self): """ Create the UI """ Registry.create() - old_app_instance = QtCore.QCoreApplication.instance() - if old_app_instance is None: - self.app = QtGui.QApplication([]) - else: - self.app = old_app_instance + self.get_application() ScreenList.create(self.app.desktop()) Registry().register('application', MagicMock()) with patch('openlp.core.lib.PluginManager'): diff --git a/tests/interfaces/openlp_core_ui/test_servicenotedialog.py b/tests/interfaces/openlp_core_ui/test_servicenotedialog.py index c085d82b7..7344dc633 100644 --- a/tests/interfaces/openlp_core_ui/test_servicenotedialog.py +++ b/tests/interfaces/openlp_core_ui/test_servicenotedialog.py @@ -36,20 +36,17 @@ from PyQt4 import QtCore, QtGui, QtTest from openlp.core.common import Registry from openlp.core.ui import servicenoteform from tests.interfaces import patch +from tests.helpers.testmixin import TestMixin -class TestStartNoteDialog(TestCase): +class TestStartNoteDialog(TestCase, TestMixin): def setUp(self): """ Create the UI """ Registry.create() - old_app_instance = QtCore.QCoreApplication.instance() - if old_app_instance is None: - self.app = QtGui.QApplication([]) - else: - self.app = old_app_instance + self.get_application() self.main_window = QtGui.QMainWindow() Registry().register('main_window', self.main_window) self.form = servicenoteform.ServiceNoteForm() diff --git a/tests/interfaces/openlp_core_ui/test_settings_form.py b/tests/interfaces/openlp_core_ui/test_settings_form.py index 83e02cb3c..012b78036 100644 --- a/tests/interfaces/openlp_core_ui/test_settings_form.py +++ b/tests/interfaces/openlp_core_ui/test_settings_form.py @@ -31,13 +31,13 @@ Package to test the openlp.core.lib.settingsform package. """ from unittest import TestCase -from PyQt4 import QtCore, QtTest, QtGui +from PyQt4 import QtCore, QtTest from openlp.core.common import Registry from openlp.core.ui import settingsform from openlp.core.lib import ScreenList from tests.interfaces import MagicMock, patch - +from tests.helpers.testmixin import TestMixin SCREEN = { 'primary': False, @@ -46,7 +46,7 @@ SCREEN = { } -class TestSettingsForm(TestCase): +class TestSettingsForm(TestCase, TestMixin): """ Test the PluginManager class """ @@ -59,11 +59,7 @@ class TestSettingsForm(TestCase): self.dummy2 = MagicMock() self.dummy3 = MagicMock() self.desktop = MagicMock() - old_app_instance = QtCore.QCoreApplication.instance() - if old_app_instance is None: - self.app = QtGui.QApplication([]) - else: - self.app = old_app_instance + self.get_application() self.desktop.primaryScreen.return_value = SCREEN['primary'] self.desktop.screenCount.return_value = SCREEN['number'] self.desktop.screenGeometry.return_value = SCREEN['size'] diff --git a/tests/interfaces/openlp_core_ui/test_starttimedialog.py b/tests/interfaces/openlp_core_ui/test_starttimedialog.py index b9d16852a..c959bb817 100644 --- a/tests/interfaces/openlp_core_ui/test_starttimedialog.py +++ b/tests/interfaces/openlp_core_ui/test_starttimedialog.py @@ -1,3 +1,31 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### """ Package to test the openlp.core.ui package. """ @@ -8,20 +36,17 @@ from PyQt4 import QtCore, QtGui, QtTest from openlp.core.common import Registry from openlp.core.ui import starttimeform from tests.interfaces import MagicMock, patch +from tests.helpers.testmixin import TestMixin -class TestStartTimeDialog(TestCase): +class TestStartTimeDialog(TestCase, TestMixin): def setUp(self): """ Create the UI """ Registry.create() - old_app_instance = QtCore.QCoreApplication.instance() - if old_app_instance is None: - self.app = QtGui.QApplication([]) - else: - self.app = old_app_instance + self.get_application() self.main_window = QtGui.QMainWindow() Registry().register('main_window', self.main_window) self.form = starttimeform.StartTimeForm() diff --git a/tests/interfaces/openlp_core_utils/__init__.py b/tests/interfaces/openlp_core_utils/__init__.py index e69de29bb..1f4f74a33 100644 --- a/tests/interfaces/openlp_core_utils/__init__.py +++ b/tests/interfaces/openlp_core_utils/__init__.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### \ No newline at end of file diff --git a/tests/interfaces/openlp_core_utils/test_utils.py b/tests/interfaces/openlp_core_utils/test_utils.py index cbc7f35d7..3c3879b34 100644 --- a/tests/interfaces/openlp_core_utils/test_utils.py +++ b/tests/interfaces/openlp_core_utils/test_utils.py @@ -1,15 +1,43 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### """ Functional tests to test the AppLocation class and related methods. """ import os from unittest import TestCase -from PyQt4 import QtCore, QtGui from openlp.core.utils import is_not_image_file from tests.utils.constants import TEST_RESOURCES_PATH +from tests.helpers.testmixin import TestMixin -class TestUtils(TestCase): +class TestUtils(TestCase, TestMixin): """ A test suite to test out various methods around the Utils functions. """ @@ -18,11 +46,7 @@ class TestUtils(TestCase): """ Some pre-test setup required. """ - old_app_instance = QtCore.QCoreApplication.instance() - if old_app_instance is None: - self.app = QtGui.QApplication([]) - else: - self.app = old_app_instance + self.get_application() def is_not_image_empty_test(self): """ diff --git a/tests/interfaces/openlp_plugins/__init__.py b/tests/interfaces/openlp_plugins/__init__.py index e69de29bb..1f4f74a33 100644 --- a/tests/interfaces/openlp_plugins/__init__.py +++ b/tests/interfaces/openlp_plugins/__init__.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### \ No newline at end of file diff --git a/tests/interfaces/openlp_plugins/custom/forms/__init__.py b/tests/interfaces/openlp_plugins/custom/forms/__init__.py index e69de29bb..1f4f74a33 100644 --- a/tests/interfaces/openlp_plugins/custom/forms/__init__.py +++ b/tests/interfaces/openlp_plugins/custom/forms/__init__.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### \ No newline at end of file diff --git a/tests/interfaces/openlp_plugins/custom/forms/test_customform.py b/tests/interfaces/openlp_plugins/custom/forms/test_customform.py index e5fffabc0..93b271797 100644 --- a/tests/interfaces/openlp_plugins/custom/forms/test_customform.py +++ b/tests/interfaces/openlp_plugins/custom/forms/test_customform.py @@ -38,9 +38,10 @@ from openlp.core.common import Registry from openlp.plugins.custom.lib.mediaitem import CustomMediaItem from openlp.plugins.custom.forms.editcustomform import EditCustomForm from tests.interfaces import MagicMock, patch +from tests.helpers.testmixin import TestMixin -class TestEditCustomForm(TestCase): +class TestEditCustomForm(TestCase, TestMixin): """ Test the EditCustomForm. """ @@ -49,11 +50,7 @@ class TestEditCustomForm(TestCase): Create the UI """ Registry.create() - old_app_instance = QtCore.QCoreApplication.instance() - if old_app_instance is None: - self.app = QtGui.QApplication([]) - else: - self.app = old_app_instance + self.get_application() self.main_window = QtGui.QMainWindow() Registry().register('main_window', self.main_window) media_item = MagicMock() diff --git a/tests/interfaces/openlp_plugins/custom/forms/test_customslideform.py b/tests/interfaces/openlp_plugins/custom/forms/test_customslideform.py index ece444b07..a2bfb1f10 100644 --- a/tests/interfaces/openlp_plugins/custom/forms/test_customslideform.py +++ b/tests/interfaces/openlp_plugins/custom/forms/test_customslideform.py @@ -1,16 +1,45 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### """ Module to test the EditCustomSlideForm. """ from unittest import TestCase -from PyQt4 import QtGui, QtCore +from PyQt4 import QtGui from openlp.core.common import Registry from openlp.plugins.custom.forms.editcustomslideform import EditCustomSlideForm from tests.interfaces import MagicMock, patch +from tests.helpers.testmixin import TestMixin -class TestEditCustomSlideForm(TestCase): +class TestEditCustomSlideForm(TestCase, TestMixin): """ Test the EditCustomSlideForm. """ @@ -19,11 +48,7 @@ class TestEditCustomSlideForm(TestCase): Create the UI """ Registry.create() - old_app_instance = QtCore.QCoreApplication.instance() - if old_app_instance is None: - self.app = QtGui.QApplication([]) - else: - self.app = old_app_instance + self.get_application() self.main_window = QtGui.QMainWindow() Registry().register('main_window', self.main_window) self.form = EditCustomSlideForm() diff --git a/tests/interfaces/openlp_plugins/remotes/__init__.py b/tests/interfaces/openlp_plugins/remotes/__init__.py index e69de29bb..1f4f74a33 100644 --- a/tests/interfaces/openlp_plugins/remotes/__init__.py +++ b/tests/interfaces/openlp_plugins/remotes/__init__.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### \ No newline at end of file diff --git a/tests/interfaces/openlp_plugins/songs/__init__.py b/tests/interfaces/openlp_plugins/songs/__init__.py index e69de29bb..1f4f74a33 100644 --- a/tests/interfaces/openlp_plugins/songs/__init__.py +++ b/tests/interfaces/openlp_plugins/songs/__init__.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### \ No newline at end of file diff --git a/tests/interfaces/openlp_plugins/songs/forms/__init__.py b/tests/interfaces/openlp_plugins/songs/forms/__init__.py index e69de29bb..1f4f74a33 100644 --- a/tests/interfaces/openlp_plugins/songs/forms/__init__.py +++ b/tests/interfaces/openlp_plugins/songs/forms/__init__.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### \ No newline at end of file diff --git a/tests/interfaces/openlp_plugins/songs/forms/test_authorsform.py b/tests/interfaces/openlp_plugins/songs/forms/test_authorsform.py index 0aea0a626..5d965c042 100644 --- a/tests/interfaces/openlp_plugins/songs/forms/test_authorsform.py +++ b/tests/interfaces/openlp_plugins/songs/forms/test_authorsform.py @@ -1,3 +1,31 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### """ Package to test the openlp.plugins.songs.forms.authorsform package. """ @@ -7,9 +35,10 @@ from PyQt4 import QtGui, QtCore from openlp.core.common import Registry from openlp.plugins.songs.forms.authorsform import AuthorsForm +from tests.helpers.testmixin import TestMixin -class TestAuthorsForm(TestCase): +class TestAuthorsForm(TestCase, TestMixin): """ Test the AuthorsForm class """ @@ -19,11 +48,7 @@ class TestAuthorsForm(TestCase): Create the UI """ Registry.create() - old_app_instance = QtCore.QCoreApplication.instance() - if old_app_instance is None: - self.app = QtGui.QApplication([]) - else: - self.app = old_app_instance + self.get_application() self.main_window = QtGui.QMainWindow() Registry().register('main_window', self.main_window) self.form = AuthorsForm() diff --git a/tests/interfaces/openlp_plugins/songs/forms/test_editsongform.py b/tests/interfaces/openlp_plugins/songs/forms/test_editsongform.py index 010d9d0f0..2f57a3002 100644 --- a/tests/interfaces/openlp_plugins/songs/forms/test_editsongform.py +++ b/tests/interfaces/openlp_plugins/songs/forms/test_editsongform.py @@ -1,16 +1,45 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### """ Package to test the openlp.plugins.songs.forms.editsongform package. """ from unittest import TestCase -from PyQt4 import QtGui, QtCore +from PyQt4 import QtGui from openlp.core.common import Registry from openlp.plugins.songs.forms.editsongform import EditSongForm from tests.interfaces import MagicMock +from tests.helpers.testmixin import TestMixin -class TestEditSongForm(TestCase): +class TestEditSongForm(TestCase, TestMixin): """ Test the EditSongForm class """ @@ -20,11 +49,7 @@ class TestEditSongForm(TestCase): Create the UI """ Registry.create() - old_app_instance = QtCore.QCoreApplication.instance() - if old_app_instance is None: - self.app = QtGui.QApplication([]) - else: - self.app = old_app_instance + self.get_application() self.main_window = QtGui.QMainWindow() Registry().register('main_window', self.main_window) Registry().register('theme_manager', MagicMock()) diff --git a/tests/interfaces/openlp_plugins/songs/forms/test_editverseform.py b/tests/interfaces/openlp_plugins/songs/forms/test_editverseform.py index 592827546..284d850c4 100644 --- a/tests/interfaces/openlp_plugins/songs/forms/test_editverseform.py +++ b/tests/interfaces/openlp_plugins/songs/forms/test_editverseform.py @@ -1,3 +1,31 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### """ Package to test the openlp.plugins.songs.forms.editverseform package. """ @@ -7,9 +35,10 @@ from PyQt4 import QtCore, QtGui, QtTest from openlp.core.common import Registry from openlp.plugins.songs.forms.editverseform import EditVerseForm +from tests.helpers.testmixin import TestMixin -class TestEditVerseForm(TestCase): +class TestEditVerseForm(TestCase, TestMixin): """ Test the EditVerseForm class """ @@ -19,11 +48,7 @@ class TestEditVerseForm(TestCase): Create the UI """ Registry.create() - old_app_instance = QtCore.QCoreApplication.instance() - if old_app_instance is None: - self.app = QtGui.QApplication([]) - else: - self.app = old_app_instance + self.get_application() self.main_window = QtGui.QMainWindow() Registry().register('main_window', self.main_window) self.form = EditVerseForm() diff --git a/tests/interfaces/openlp_plugins/songs/forms/test_topicsform.py b/tests/interfaces/openlp_plugins/songs/forms/test_topicsform.py index 7fde007f0..c30c7838c 100644 --- a/tests/interfaces/openlp_plugins/songs/forms/test_topicsform.py +++ b/tests/interfaces/openlp_plugins/songs/forms/test_topicsform.py @@ -1,3 +1,31 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2014 Raoul Snyman # +# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, # +# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. # +# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, # +# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, # +# Frode Woldsund, Martin Zibricky, Patrick Zimmermann # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### """ Package to test the openlp.plugins.songs.forms.topicsform package. """ @@ -7,9 +35,10 @@ from PyQt4 import QtGui, QtCore from openlp.core.common import Registry from openlp.plugins.songs.forms.topicsform import TopicsForm +from tests.helpers.testmixin import TestMixin -class TestTopicsForm(TestCase): +class TestTopicsForm(TestCase, TestMixin): """ Test the TopicsForm class """ @@ -19,11 +48,7 @@ class TestTopicsForm(TestCase): Create the UI """ Registry.create() - old_app_instance = QtCore.QCoreApplication.instance() - if old_app_instance is None: - self.app = QtGui.QApplication([]) - else: - self.app = old_app_instance + self.get_application() self.main_window = QtGui.QMainWindow() Registry().register('main_window', self.main_window) self.form = TopicsForm()