move registry to common

This commit is contained in:
Tim Bentley 2013-12-13 17:44:05 +00:00
parent 5fcc9deb80
commit cd9f9e4c8d
91 changed files with 137 additions and 426 deletions

View File

@ -43,8 +43,8 @@ from traceback import format_exception
from PyQt4 import QtCore, QtGui
from openlp.core.common import AppLocation, Settings, UiStrings, check_directory_exists
from openlp.core.lib import ScreenList, Registry
from openlp.core.common import Registry, AppLocation, Settings, UiStrings, check_directory_exists
from openlp.core.lib import ScreenList
from openlp.core.resources import qInitResources
from openlp.core.ui.mainwindow import MainWindow
from openlp.core.ui.firsttimelanguageform import FirstTimeLanguageForm

View File

@ -103,6 +103,7 @@ class SlideLimits(object):
Wrap = 2
Next = 3
from .registry import Registry
from .uistrings import UiStrings
from .settings import Settings
from .applocation import AppLocation

View File

@ -329,7 +329,6 @@ def create_separated_list(string_list):
return translate('OpenLP.core.lib', '%s, %s', 'Locale list separator: start') % (string_list[0], merged)
from .registry import Registry
from .filedialog import FileDialog
from .screen import ScreenList
from .listwidgetwithdnd import ListWidgetWithDnD

View File

@ -39,7 +39,8 @@ import queue
from PyQt4 import QtCore
from openlp.core.lib import Registry, ScreenList, resize_image, image_to_byte
from openlp.core.common import Registry
from openlp.core.lib import ScreenList, resize_image, image_to_byte
log = logging.getLogger(__name__)

View File

@ -33,7 +33,7 @@ import os
from PyQt4 import QtCore, QtGui
from openlp.core.lib import Registry
from openlp.core.common import Registry
class ListWidgetWithDnD(QtGui.QListWidget):

View File

@ -35,9 +35,9 @@ import re
from PyQt4 import QtCore, QtGui
from openlp.core.common import Settings, UiStrings, translate
from openlp.core.common import Registry, Settings, UiStrings, translate
from openlp.core.lib import FileDialog, OpenLPToolbar, ServiceItem, StringContent, ListWidgetWithDnD, \
ServiceItemContext, Registry
ServiceItemContext
from openlp.core.lib.searchedit import SearchEdit
from openlp.core.lib.ui import create_widget_action, critical_error_message_box

View File

@ -34,8 +34,7 @@ import os
from PyQt4 import QtCore
from openlp.core.common import Settings, UiStrings
from openlp.core.lib import Registry
from openlp.core.common import Registry, Settings, UiStrings
from openlp.core.utils import get_application_version
log = logging.getLogger(__name__)

View File

@ -34,8 +34,8 @@ import sys
import logging
import imp
from openlp.core.lib import Plugin, PluginStatus, Registry
from openlp.core.common import AppLocation
from openlp.core.lib import Plugin, PluginStatus
from openlp.core.common import AppLocation, Registry
log = logging.getLogger(__name__)

View File

@ -1,167 +0,0 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
# Copyright (c) 2008-2013 Raoul Snyman #
# Portions copyright (c) 2008-2013 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 #
###############################################################################
"""
Provide Registry Services
"""
import logging
import sys
log = logging.getLogger(__name__)
class Registry(object):
"""
This is the Component Registry. It is a singleton object and is used to provide a look up service for common
objects.
"""
log.info('Registry loaded')
__instance__ = None
def __new__(cls):
"""
Re-implement the __new__ method to make sure we create a true singleton.
"""
if not cls.__instance__:
cls.__instance__ = object.__new__(cls)
return cls.__instance__
@classmethod
def create(cls):
"""
The constructor for the component registry providing a single registry of objects.
"""
log.info('Registry Initialising')
registry = cls()
registry.service_list = {}
registry.functions_list = {}
registry.running_under_test = False
# Allow the tests to remove Registry entries but not the live system
if 'nose' in sys.argv[0]:
registry.running_under_test = True
return registry
def get(self, key):
"""
Extracts the registry value from the list based on the key passed in
``key``
The service to be retrieved.
"""
if key in self.service_list:
return self.service_list[key]
else:
log.error('Service %s not found in list' % key)
raise KeyError('Service %s not found in list' % key)
def register(self, key, reference):
"""
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.
"""
if key in self.service_list:
log.error('Duplicate service exception %s' % key)
raise KeyError('Duplicate service exception %s' % key)
else:
self.service_list[key] = reference
def remove(self, key):
"""
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.
"""
if key in self.service_list:
del self.service_list[key]
def register_function(self, event, function):
"""
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
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.
"""
if event in self.functions_list:
self.functions_list[event].append(function)
else:
self.functions_list[event] = [function]
def remove_function(self, event, function):
"""
Remove an event and associated handler
``event``
The function description..
``function``
The function to be called when the event happens.
"""
if self.running_under_test is False:
log.error('Invalid Method call for key %s' % event)
raise KeyError('Invalid Method call for key %s' % event)
if event in self.functions_list:
self.functions_list[event].remove(function)
def execute(self, event, *args, **kwargs):
"""
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.
"""
results = []
if event in self.functions_list:
for function in self.functions_list[event]:
try:
result = function(*args, **kwargs)
if result:
results.append(result)
except TypeError:
# Who has called me can help in debugging
import inspect
log.debug(inspect.currentframe().f_back.f_locals)
log.exception('Exception for function %s', function)
return results

View File

@ -31,9 +31,9 @@ import logging
from PyQt4 import QtGui, QtCore, QtWebKit
from openlp.core.common import Settings
from openlp.core.lib import FormattingTags, ImageSource, ItemCapabilities, Registry, ScreenList, \
ServiceItem, expand_tags, build_lyrics_format_css, build_lyrics_outline_css
from openlp.core.common import Registry, 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
from openlp.core.ui import MainDisplay

View File

@ -36,8 +36,7 @@ import copy
from PyQt4 import QtCore
from openlp.core.common import Settings, translate
from openlp.core.lib import Registry
from openlp.core.common import Registry, Settings, translate
log = logging.getLogger(__name__)

View File

@ -39,8 +39,8 @@ import uuid
from PyQt4 import QtGui
from openlp.core.common import Settings, translate
from openlp.core.lib import ImageSource, Registry, build_icon, clean_tags, expand_tags
from openlp.core.common import Registry, Settings, translate
from openlp.core.lib import ImageSource, build_icon, clean_tags, expand_tags
log = logging.getLogger(__name__)

View File

@ -35,7 +35,7 @@ own tab to the settings dialog.
from PyQt4 import QtGui
from openlp.core.lib import Registry
from openlp.core.common import Registry
class SettingsTab(QtGui.QWidget):

View File

@ -33,7 +33,7 @@ import os
from PyQt4 import QtCore, QtGui
from openlp.core.lib import Registry
from openlp.core.common import Registry
class TreeWidgetWithDnD(QtGui.QTreeWidget):

View File

@ -33,8 +33,8 @@ import logging
from PyQt4 import QtCore, QtGui
from openlp.core.common import UiStrings, translate
from openlp.core.lib import Registry, build_icon
from openlp.core.common import Registry, UiStrings, translate
from openlp.core.lib import build_icon
from openlp.core.utils.actions import ActionList

View File

@ -38,7 +38,7 @@ import bs4
import sqlalchemy
from lxml import etree
from openlp.core.lib import Registry
from openlp.core.common import Registry
from PyQt4 import Qt, QtCore, QtGui, QtWebKit

View File

@ -34,8 +34,7 @@ from PyQt4 import QtGui
from .filerenamedialog import Ui_FileRenameDialog
from openlp.core.common import translate
from openlp.core.lib import Registry
from openlp.core.common import Registry, translate
class FileRenameForm(QtGui.QDialog, Ui_FileRenameDialog):

View File

@ -41,8 +41,8 @@ from configparser import SafeConfigParser
from PyQt4 import QtCore, QtGui
from openlp.core.common import AppLocation, Settings, check_directory_exists, translate
from openlp.core.lib import PluginStatus, Registry, build_icon
from openlp.core.common import Registry, 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

View File

@ -33,8 +33,8 @@ import logging
from PyQt4 import QtCore, QtGui
from openlp.core.common import Settings, UiStrings, translate
from openlp.core.lib import Registry, SettingsTab, ScreenList
from openlp.core.common import Registry, Settings, UiStrings, translate
from openlp.core.lib import SettingsTab, ScreenList
log = logging.getLogger(__name__)

View File

@ -33,7 +33,8 @@ It is based on a QTableWidget but represents its contents in list form.
from PyQt4 import QtCore, QtGui
from openlp.core.lib import ImageSource, Registry, ServiceItem
from openlp.core.common import Registry
from openlp.core.lib import ImageSource, ServiceItem
class ListPreviewWidget(QtGui.QTableWidget):

View File

@ -44,8 +44,8 @@ import sys
from PyQt4 import QtCore, QtGui, QtWebKit, QtOpenGL
from PyQt4.phonon import Phonon
from openlp.core.common import Settings, translate
from openlp.core.lib import ServiceItem, ImageSource, Registry, build_html, expand_tags, image_to_byte
from openlp.core.common import Registry, Settings, translate
from openlp.core.lib import ServiceItem, ImageSource, build_html, expand_tags, image_to_byte
from openlp.core.lib.theme import BackgroundType
from openlp.core.lib import ScreenList

View File

@ -41,8 +41,9 @@ from datetime import datetime
from PyQt4 import QtCore, QtGui
from openlp.core.lib import Renderer, OpenLPDockWidget, PluginManager, ImageManager, PluginStatus, Registry, \
ScreenList, build_icon
from openlp.core.common import Registry
from openlp.core.lib import Renderer, OpenLPDockWidget, PluginManager, ImageManager, PluginStatus, ScreenList, \
build_icon
from openlp.core.lib.ui import UiStrings, create_action
from openlp.core.ui import AboutForm, SettingsForm, ServiceManager, ThemeManager, SlideController, PluginForm, \
MediaDockManager, ShortcutListForm, FormattingTagForm

View File

@ -35,8 +35,8 @@ import os
import datetime
from PyQt4 import QtCore, QtGui
from openlp.core.common import Settings, UiStrings, translate
from openlp.core.lib import OpenLPToolbar, Registry
from openlp.core.common import Registry, 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
from openlp.core.ui.media.mediaplayer import MediaPlayer

View File

@ -31,7 +31,7 @@ The :mod:`~openlp.core.ui.media.mediaplayer` module contains the MediaPlayer cla
"""
import os
from openlp.core.lib import Registry
from openlp.core.common import Registry
from openlp.core.ui.media import MediaState

View File

@ -31,8 +31,8 @@ The :mod:`~openlp.core.ui.media.playertab` module holds the configuration tab fo
"""
from PyQt4 import QtCore, QtGui
from openlp.core.common import Settings, UiStrings, translate
from openlp.core.lib import Registry, SettingsTab
from openlp.core.common import Registry, Settings, UiStrings, translate
from openlp.core.lib import SettingsTab
from openlp.core.lib.ui import create_button
from openlp.core.ui.media import get_media_players, set_media_players

View File

@ -34,8 +34,8 @@ import os
from PyQt4 import QtGui
from openlp.core.common import translate
from openlp.core.lib import PluginStatus, Registry
from openlp.core.common import Registry, translate
from openlp.core.lib import PluginStatus
from .plugindialog import Ui_PluginViewDialog
log = logging.getLogger(__name__)

View File

@ -36,8 +36,8 @@ import os
from PyQt4 import QtCore, QtGui
from lxml import html
from openlp.core.common import Settings, UiStrings, translate
from openlp.core.lib import Registry, get_text_file_string
from openlp.core.common import Registry, 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

View File

@ -30,7 +30,7 @@
The service item edit dialog
"""
from PyQt4 import QtGui
from openlp.core.lib import Registry
from openlp.core.common import Registry
from .serviceitemeditdialog import Ui_ServiceItemEditDialog

View File

@ -42,8 +42,8 @@ log = logging.getLogger(__name__)
from PyQt4 import QtCore, QtGui
from openlp.core.common import AppLocation, Settings, ThemeLevel, check_directory_exists, UiStrings, translate
from openlp.core.lib import OpenLPToolbar, ServiceItem, ItemCapabilities, PluginStatus, Registry, build_icon
from openlp.core.common import Registry, AppLocation, Settings, ThemeLevel, 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
from openlp.core.ui.printserviceform import PrintServiceForm

View File

@ -31,8 +31,8 @@ The :mod:`~openlp.core.ui.servicenoteform` module contains the `ServiceNoteForm`
"""
from PyQt4 import QtGui
from openlp.core.common import translate
from openlp.core.lib import SpellTextEdit, Registry
from openlp.core.common import Registry, translate
from openlp.core.lib import SpellTextEdit
from openlp.core.lib.ui import create_button_box

View File

@ -33,7 +33,8 @@ import logging
from PyQt4 import QtGui
from openlp.core.lib import PluginStatus, Registry, build_icon
from openlp.core.common import Registry
from openlp.core.lib import PluginStatus, build_icon
from openlp.core.ui import AdvancedTab, GeneralTab, ThemesTab
from openlp.core.ui.media import PlayerTab
from .settingsdialog import Ui_SettingsDialog

View File

@ -33,8 +33,7 @@ import re
from PyQt4 import QtCore, QtGui
from openlp.core.lib import Registry
from openlp.core.common import Settings, translate
from openlp.core.common import Registry, Settings, translate
from openlp.core.utils.actions import ActionList
from .shortcutlistdialog import Ui_ShortcutListDialog

View File

@ -37,8 +37,8 @@ from collections import deque
from PyQt4 import QtCore, QtGui
from openlp.core.common import Settings, SlideLimits, UiStrings, translate
from openlp.core.lib import OpenLPToolbar, ItemCapabilities, ServiceItem, ImageSource, ServiceItemAction, Registry, \
from openlp.core.common import Registry, Settings, SlideLimits, UiStrings, translate
from openlp.core.lib import OpenLPToolbar, ItemCapabilities, ServiceItem, ImageSource, ServiceItemAction, \
ScreenList, build_icon, build_html
from openlp.core.ui import HideMode, MainDisplay, Display, DisplayControllerType
from openlp.core.lib.ui import create_action

View File

@ -33,8 +33,7 @@ from PyQt4 import QtGui
from .starttimedialog import Ui_StartTimeDialog
from openlp.core.common import UiStrings, translate
from openlp.core.lib import Registry
from openlp.core.common import Registry, UiStrings, translate
from openlp.core.lib.ui import critical_error_message_box

View File

@ -34,8 +34,7 @@ import os
from PyQt4 import QtCore, QtGui
from openlp.core.common import UiStrings, translate
from openlp.core.lib import Registry
from openlp.core.common import Registry, 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

View File

@ -37,8 +37,8 @@ import logging
from xml.etree.ElementTree import ElementTree, XML
from PyQt4 import QtCore, QtGui
from openlp.core.common import AppLocation, Settings, check_directory_exists, UiStrings, translate
from openlp.core.lib import FileDialog, ImageSource, OpenLPToolbar, Registry, get_text_file_string, build_icon, \
from openlp.core.common import Registry, AppLocation, Settings, 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
from openlp.core.lib.ui import critical_error_message_box, create_widget_action

View File

@ -33,8 +33,8 @@ The Themes configuration tab
from PyQt4 import QtCore, QtGui
from openlp.core.common import Settings, ThemeLevel, UiStrings, translate
from openlp.core.lib import Registry, SettingsTab
from openlp.core.common import Registry, Settings, ThemeLevel, UiStrings, translate
from openlp.core.lib import SettingsTab
from openlp.core.lib.ui import find_and_set_in_combo_box

View File

@ -34,8 +34,8 @@ import os
from PyQt4 import QtGui
from openlp.core.common import Settings, UiStrings, translate
from openlp.core.lib import Registry, build_icon
from openlp.core.common import Registry, Settings, UiStrings, translate
from openlp.core.lib import build_icon
from openlp.core.lib.ui import add_welcome_page
log = logging.getLogger(__name__)

View File

@ -43,8 +43,7 @@ import urllib.parse
from PyQt4 import QtGui, QtCore
from openlp.core.common import AppLocation, Settings
from openlp.core.lib import Registry
from openlp.core.common import Registry, AppLocation, Settings
if sys.platform != 'win32' and sys.platform != 'darwin':

View File

@ -35,8 +35,7 @@ import logging
from PyQt4 import QtCore
from openlp.core.common import translate
from openlp.core.lib import Registry
from openlp.core.common import Registry, translate
log = logging.getLogger(__name__)

View File

@ -36,8 +36,7 @@ from tempfile import gettempdir
from PyQt4 import QtCore, QtGui
from openlp.core.common import AppLocation, UiStrings, Settings, check_directory_exists, translate
from openlp.core.lib import Registry
from openlp.core.common import Registry, AppLocation, UiStrings, Settings, check_directory_exists, translate
from openlp.core.lib.ui import critical_error_message_box
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
from openlp.core.utils import delete_file

View File

@ -33,8 +33,7 @@ import re
from PyQt4 import QtGui
from openlp.core.common import UiStrings, translate
from openlp.core.lib import Registry
from openlp.core.common import Registry, UiStrings, translate
from openlp.core.lib.ui import critical_error_message_box
from .editbibledialog import Ui_EditBibleDialog
from openlp.plugins.bibles.lib import BibleStrings

View File

@ -31,8 +31,8 @@ import logging
from PyQt4 import QtCore, QtGui
from openlp.core.common import Settings, UiStrings, translate
from openlp.core.lib import Registry, SettingsTab
from openlp.core.common import Registry, Settings, UiStrings, translate
from openlp.core.lib import SettingsTab
from openlp.core.lib.ui import find_and_set_in_combo_box
from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, update_reference_separators, \
get_reference_separator, LanguageSelection

View File

@ -38,8 +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 AppLocation, translate
from openlp.core.lib import Registry
from openlp.core.common import Registry, 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

View File

@ -38,8 +38,7 @@ from html.parser import HTMLParseError
from bs4 import BeautifulSoup, NavigableString, Tag
from openlp.core.common import translate
from openlp.core.lib import Registry
from openlp.core.common import Registry, 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

View File

@ -30,8 +30,7 @@
import logging
import os
from openlp.core.common import AppLocation, Settings, translate
from openlp.core.lib import Registry
from openlp.core.common import Registry, 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

View File

@ -31,8 +31,8 @@ import logging
from PyQt4 import QtCore, QtGui
from openlp.core.common import Settings, UiStrings, translate
from openlp.core.lib import Registry, MediaManagerItem, ItemCapabilities, ServiceItemContext, create_separated_list
from openlp.core.common import Registry, Settings, UiStrings, translate
from openlp.core.lib import MediaManagerItem, ItemCapabilities, ServiceItemContext, create_separated_list
from openlp.core.lib.searchedit import SearchEdit
from openlp.core.lib.ui import set_case_insensitive_completer, create_horizontal_adjusting_combo_box, \
critical_error_message_box, find_and_set_in_combo_box, build_icon

View File

@ -31,7 +31,7 @@ import logging
from PyQt4 import QtGui
from openlp.core.lib import Registry, translate
from openlp.core.common import Registry, translate
from openlp.core.lib.ui import critical_error_message_box, find_and_set_in_combo_box
from openlp.plugins.custom.lib import CustomXMLBuilder, CustomXMLParser
from openlp.plugins.custom.lib.db import CustomSlide

View File

@ -32,8 +32,8 @@ import logging
from PyQt4 import QtCore, QtGui
from sqlalchemy.sql import or_, func, and_
from openlp.core.common import Settings, UiStrings, translate
from openlp.core.lib import Registry, MediaManagerItem, ItemCapabilities, ServiceItemContext, PluginStatus,\
from openlp.core.common import Registry, Settings, UiStrings, translate
from openlp.core.lib import MediaManagerItem, ItemCapabilities, ServiceItemContext, PluginStatus,\
check_item_selected
from openlp.plugins.custom.forms.editcustomform import EditCustomForm
from openlp.plugins.custom.lib import CustomXMLParser, CustomXMLBuilder

View File

@ -31,8 +31,8 @@ from PyQt4 import QtGui
import logging
from openlp.core.common import Settings, translate
from openlp.core.lib import Plugin, StringContent, Registry, ImageSource, build_icon
from openlp.core.common import Registry, Settings, translate
from openlp.core.lib import Plugin, StringContent, ImageSource, build_icon
from openlp.core.lib.db import Manager
from openlp.plugins.images.lib import ImageMediaItem, ImageTab
from openlp.plugins.images.lib.db import init_schema

View File

@ -32,9 +32,9 @@ import os
from PyQt4 import QtCore, QtGui
from openlp.core.common import AppLocation, Settings, UiStrings, check_directory_exists, translate
from openlp.core.lib import ItemCapabilities, MediaManagerItem, Registry, ServiceItemContext, \
StringContent, TreeWidgetWithDnD, build_icon, check_item_selected, create_thumb, validate_thumb
from openlp.core.common import Registry, AppLocation, Settings, UiStrings, check_directory_exists, translate
from openlp.core.lib import ItemCapabilities, MediaManagerItem, ServiceItemContext, StringContent, TreeWidgetWithDnD,\
build_icon, check_item_selected, create_thumb, validate_thumb
from openlp.core.lib.ui import create_widget_action, critical_error_message_box
from openlp.core.utils import delete_file, get_locale_key, get_images_filter
from openlp.plugins.images.forms import AddGroupForm, ChooseGroupForm

View File

@ -32,8 +32,8 @@ import os
from PyQt4 import QtCore, QtGui
from openlp.core.common import AppLocation, Settings, check_directory_exists, UiStrings, translate
from openlp.core.lib import ItemCapabilities, MediaManagerItem,MediaType, Registry, ServiceItem, ServiceItemContext, \
from openlp.core.common import Registry, 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
from openlp.core.ui import DisplayController, Display, DisplayControllerType

View File

@ -31,8 +31,8 @@ import logging
from PyQt4 import QtCore
from openlp.core.common import translate
from openlp.core.lib import Plugin, Registry, StringContent, build_icon
from openlp.core.common import Registry, translate
from openlp.core.lib import Plugin, StringContent, build_icon
from openlp.plugins.media.lib import MediaMediaItem, MediaTab

View File

@ -32,8 +32,8 @@ import os
from PyQt4 import QtCore, QtGui
from openlp.core.common import Settings, UiStrings, translate
from openlp.core.lib import MediaManagerItem, Registry, ItemCapabilities, ServiceItemContext,\
from openlp.core.common import Registry, Settings, UiStrings, translate
from openlp.core.lib import MediaManagerItem, ItemCapabilities, ServiceItemContext,\
build_icon, check_item_selected, create_thumb, validate_thumb
from openlp.core.lib.ui import critical_error_message_box, create_horizontal_adjusting_combo_box
from openlp.core.utils import get_locale_key

View File

@ -31,7 +31,7 @@ import logging
from PyQt4 import QtCore
from openlp.core.lib import Registry
from openlp.core.common import Registry
from openlp.core.ui import HideMode
log = logging.getLogger(__name__)

View File

@ -33,8 +33,8 @@ import shutil
from PyQt4 import QtCore
from openlp.core.common import AppLocation, Settings, check_directory_exists
from openlp.core.lib import Registry, create_thumb, validate_thumb
from openlp.core.common import Registry, AppLocation, Settings, check_directory_exists
from openlp.core.lib import create_thumb, validate_thumb
log = logging.getLogger(__name__)

View File

@ -124,8 +124,8 @@ from urllib.parse import urlparse, parse_qs
from mako.template import Template
from PyQt4 import QtCore
from openlp.core.common import AppLocation, Settings, translate
from openlp.core.lib import Registry, PluginStatus, StringContent, image_to_byte
from openlp.core.common import Registry, AppLocation, Settings, translate
from openlp.core.lib import PluginStatus, StringContent, image_to_byte
log = logging.getLogger(__name__)
FILE_TYPES = {

View File

@ -35,7 +35,7 @@ import os
from PyQt4 import QtCore, QtGui
from openlp.core.lib import Registry, translate
from openlp.core.common import Registry, 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

View File

@ -38,8 +38,8 @@ import shutil
from PyQt4 import QtCore, QtGui
from openlp.core.common import AppLocation, UiStrings, check_directory_exists, translate
from openlp.core.lib import FileDialog, Registry, PluginStatus, MediaType, create_separated_list
from openlp.core.common import Registry, 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
from openlp.plugins.songs.lib.db import Book, Song, Author, Topic, MediaFile

View File

@ -34,8 +34,8 @@ import logging
from PyQt4 import QtCore, QtGui
from openlp.core.common import UiStrings, translate
from openlp.core.lib import Registry, create_separated_list, build_icon
from openlp.core.common import Registry, UiStrings, translate
from openlp.core.lib import create_separated_list, build_icon
from openlp.core.lib.ui import critical_error_message_box
from openlp.core.ui.wizard import OpenLPWizard, WizardStrings
from openlp.plugins.songs.lib.db import Song

View File

@ -35,9 +35,8 @@ import os
from PyQt4 import QtCore, QtGui
from openlp.core.common import UiStrings, translate
from openlp.core.common import Settings
from openlp.core.lib import FileDialog, Registry
from openlp.core.common import Registry, 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
from openlp.plugins.songs.lib.importer import SongFormat, SongFormatSelect

View File

@ -32,8 +32,7 @@ import os
from PyQt4 import QtGui, QtCore
from sqlalchemy.sql import and_
from openlp.core.common import UiStrings, translate
from openlp.core.lib import Registry
from openlp.core.common import Registry, 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

View File

@ -35,8 +35,8 @@ import shutil
from PyQt4 import QtCore, QtGui
from sqlalchemy.sql import or_
from openlp.core.common import AppLocation, Settings, check_directory_exists, UiStrings, translate
from openlp.core.lib import Registry, MediaManagerItem, ItemCapabilities, PluginStatus, ServiceItemContext, \
from openlp.core.common import Registry, AppLocation, Settings, check_directory_exists, UiStrings, translate
from openlp.core.lib import MediaManagerItem, ItemCapabilities, PluginStatus, ServiceItemContext, \
check_item_selected, create_separated_list
from openlp.core.lib.ui import create_widget_action
from openlp.plugins.songs.forms.editsongform import EditSongForm

View File

@ -35,8 +35,7 @@ import os
from lxml import etree
from openlp.core.common import check_directory_exists, translate
from openlp.core.lib import Registry
from openlp.core.common import Registry, check_directory_exists, translate
from openlp.core.utils import clean_filename
from openlp.plugins.songs.lib.xml import OpenLyrics

View File

@ -34,8 +34,7 @@ import os
from PyQt4 import QtCore
from openlp.core.common import AppLocation, check_directory_exists, translate
from openlp.core.lib import Registry
from openlp.core.common import Registry, AppLocation, check_directory_exists, translate
from openlp.core.ui.wizard import WizardStrings
from openlp.plugins.songs.lib import clean_song, VerseType
from openlp.plugins.songs.lib.db import Song, Author, Topic, Book, MediaFile

View File

@ -29,8 +29,7 @@
from PyQt4 import QtGui
from openlp.core.common import translate
from openlp.core.lib import Registry
from openlp.core.common import Registry, translate
from openlp.plugins.songusage.lib.db import SongUsageItem
from .songusagedeletedialog import Ui_SongUsageDeleteDialog

View File

@ -33,8 +33,7 @@ import os
from PyQt4 import QtGui
from sqlalchemy.sql import and_
from openlp.core.common import Settings, check_directory_exists, translate
from openlp.core.lib import Registry
from openlp.core.common import Registry, Settings, check_directory_exists, translate
from openlp.plugins.songusage.lib.db import SongUsageItem
from .songusagedetaildialog import Ui_SongUsageDetailDialog

View File

@ -32,8 +32,8 @@ from datetime import datetime
from PyQt4 import QtCore, QtGui
from openlp.core.common import Settings, translate
from openlp.core.lib import Plugin, Registry, StringContent, build_icon
from openlp.core.common import Registry, Settings, translate
from openlp.core.lib import Plugin, StringContent, build_icon
from openlp.core.lib.db import Manager
from openlp.core.lib.ui import create_action
from openlp.core.utils.actions import ActionList

View File

@ -34,7 +34,8 @@ import os
from unittest import TestCase
from PyQt4 import QtGui
from openlp.core.lib import Registry, ImageManager, ScreenList
from openlp.core.common import Registry
from openlp.core.lib import ImageManager, ScreenList
TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'resources'))

View File

@ -31,9 +31,9 @@ Package to test the openlp.core.lib.pluginmanager package.
"""
from unittest import TestCase
from openlp.core.common import Settings
from openlp.core.common import Registry, Settings
from openlp.core.lib.pluginmanager import PluginManager
from openlp.core.lib import Registry, PluginStatus
from openlp.core.lib import PluginStatus
from tests.functional import MagicMock

View File

@ -1,112 +0,0 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
# Copyright (c) 2008-2013 Raoul Snyman #
# Portions copyright (c) 2008-2013 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.
"""
import os
from unittest import TestCase
from openlp.core.lib import Registry
from tests.functional import MagicMock
TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'resources'))
class TestRegistry(TestCase):
def registry_service_test(self):
"""
Test the registry creation and its usage
"""
# GIVEN: A new registry
Registry.create()
# WHEN: I add a component it should save it
mock_1 = MagicMock()
Registry().register('test1', mock_1)
# THEN: we should be able retrieve the saved component
assert Registry().get('test1') == mock_1, 'The saved service can be retrieved and matches'
# WHEN: I add a component for the second time I am mad.
# THEN and I will get an exception
with self.assertRaises(KeyError) as context:
Registry().register('test1', mock_1)
self.assertEqual(context.exception.args[0], 'Duplicate service exception test1',
'KeyError exception should have been thrown for duplicate service')
# WHEN I try to get back a non existent component
# THEN I will get an exception
with self.assertRaises(KeyError) as context:
temp = Registry().get('test2')
self.assertEqual(context.exception.args[0], 'Service test2 not found in list',
'KeyError exception should have been thrown for missing service')
# WHEN I try to replace a component I should be allowed (testing only)
Registry().remove('test1')
# THEN I will get an exception
with self.assertRaises(KeyError) as context:
temp = Registry().get('test1')
self.assertEqual(context.exception.args[0], 'Service test1 not found in list',
'KeyError exception should have been thrown for deleted service')
def registry_function_test(self):
"""
Test the registry function creation and their usages
"""
# GIVEN: An existing registry register a function
Registry.create()
Registry().register_function('test1', self.dummy_function_1)
# WHEN: I execute the function
return_value = Registry().execute('test1')
# THEN: I expect then function to have been called and a return given
self.assertEqual(return_value[0], 'function_1', 'A return value is provided and matches')
# WHEN: I execute the a function with the same reference and execute the function
Registry().register_function('test1', self.dummy_function_1)
return_value = Registry().execute('test1')
# THEN: I expect then function to have been called and a return given
self.assertEqual(return_value, ['function_1', 'function_1'], 'A return value list is provided and matches')
# WHEN: I execute the a 2nd function with the different reference and execute the function
Registry().register_function('test2', self.dummy_function_2)
return_value = Registry().execute('test2')
# THEN: I expect then function to have been called and a return given
self.assertEqual(return_value[0], 'function_2', 'A return value is provided and matches')
def dummy_function_1(self):
return "function_1"
def dummy_function_2(self):
return "function_2"

View File

@ -33,7 +33,8 @@ from unittest import TestCase
from PyQt4 import QtGui, QtCore
from openlp.core.lib import Registry, ScreenList
from openlp.core.common import Registry
from openlp.core.lib import ScreenList
from tests.functional import MagicMock
SCREEN = {

View File

@ -36,7 +36,8 @@ from unittest import TestCase
from tests.functional import MagicMock, patch
from tests.utils import assert_length, convert_file_service_item
from openlp.core.lib import ItemCapabilities, ServiceItem, Registry
from openlp.core.common import Registry
from openlp.core.lib import ItemCapabilities, ServiceItem
VERSE = 'The Lord said to {r}Noah{/r}: \n'\

View File

@ -31,7 +31,7 @@ This module contains tests for the lib submodule of the Images plugin.
"""
from unittest import TestCase
from openlp.core.lib import Registry
from openlp.core.common import Registry
from openlp.plugins.images.lib.db import ImageFilenames, ImageGroups
from openlp.plugins.images.lib.mediaitem import ImageMediaItem
from tests.functional import MagicMock, patch

View File

@ -33,7 +33,7 @@ from unittest import TestCase
from PyQt4 import QtGui
from openlp.core.lib import Registry
from openlp.core.common import Registry
from openlp.plugins.presentations.lib.mediaitem import PresentationMediaItem
from tests.functional import patch, MagicMock

View File

@ -7,8 +7,8 @@ from unittest import TestCase
from PyQt4 import QtCore, QtGui
from openlp.core.common import Settings
from openlp.core.lib import Registry, ServiceItem
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

View File

@ -9,9 +9,8 @@ from unittest import TestCase
from PyQt4 import QtGui
from openlp.core.common import Settings
from openlp.core.common import Registry, Settings
from openlp.core.lib.pluginmanager import PluginManager
from openlp.core.lib import Registry
from tests.interfaces import MagicMock

View File

@ -5,7 +5,7 @@ from unittest import TestCase
from PyQt4 import QtGui, QtTest
from openlp.core.lib import Registry
from openlp.core.common import Registry
from openlp.core.ui import filerenameform
from tests.interfaces import MagicMock, patch

View File

@ -6,7 +6,8 @@ from unittest import TestCase
from PyQt4 import QtGui
from openlp.core.lib import Registry, ServiceItem
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

View File

@ -5,7 +5,7 @@ from unittest import TestCase
from PyQt4 import QtGui
from openlp.core.lib import Registry
from openlp.core.common import Registry
from openlp.core.ui.mainwindow import MainWindow
from tests.interfaces import MagicMock, patch

View File

@ -6,7 +6,8 @@ from unittest import TestCase
from PyQt4 import QtGui
from openlp.core.lib import Registry, ScreenList, ServiceItem
from openlp.core.common import Registry
from openlp.core.lib import ScreenList, ServiceItem
from openlp.core.ui.mainwindow import MainWindow
from tests.interfaces import MagicMock, patch

View File

@ -5,7 +5,7 @@ from unittest import TestCase
from PyQt4 import QtCore, QtGui, QtTest
from openlp.core.lib import Registry
from openlp.core.common import Registry
from openlp.core.ui import servicenoteform
from tests.interfaces import patch

View File

@ -5,8 +5,9 @@ from unittest import TestCase
from PyQt4 import QtCore, QtTest, QtGui
from openlp.core.common import Registry
from openlp.core.ui import settingsform
from openlp.core.lib import Registry, ScreenList
from openlp.core.lib import ScreenList
from tests.interfaces import MagicMock, patch

View File

@ -5,7 +5,7 @@ from unittest import TestCase
from PyQt4 import QtCore, QtGui, QtTest
from openlp.core.lib import Registry
from openlp.core.common import Registry
from openlp.core.ui import starttimeform
from tests.interfaces import MagicMock, patch

View File

@ -3,7 +3,7 @@
"""
from unittest import TestCase
from openlp.core.lib import Registry
from openlp.core.common import Registry
from openlp.plugins.bibles.lib.http import BGExtract, CWExtract
from tests.interfaces import MagicMock

View File

@ -5,7 +5,7 @@ from unittest import TestCase
from PyQt4 import QtGui, QtTest, QtCore
from openlp.core.lib import Registry
from openlp.core.common import Registry
# Import needed due to import problems.
from openlp.plugins.custom.lib.mediaitem import CustomMediaItem
from openlp.plugins.custom.forms.editcustomform import EditCustomForm

View File

@ -5,7 +5,7 @@ from unittest import TestCase
from PyQt4 import QtGui
from openlp.core.lib import Registry
from openlp.core.common import Registry
from openlp.plugins.custom.forms.editcustomslideform import EditCustomSlideForm
from tests.interfaces import MagicMock, patch

View File

@ -5,7 +5,7 @@ from unittest import TestCase
from PyQt4 import QtGui
from openlp.core.lib import Registry
from openlp.core.common import Registry
from openlp.plugins.songs.forms.authorsform import AuthorsForm

View File

@ -5,7 +5,7 @@ from unittest import TestCase
from PyQt4 import QtGui
from openlp.core.lib import Registry
from openlp.core.common import Registry
from openlp.plugins.songs.forms.editsongform import EditSongForm
from tests.interfaces import MagicMock

View File

@ -5,7 +5,7 @@ from unittest import TestCase
from PyQt4 import QtCore, QtGui, QtTest
from openlp.core.lib import Registry
from openlp.core.common import Registry
from openlp.plugins.songs.forms.editverseform import EditVerseForm

View File

@ -5,7 +5,7 @@ from unittest import TestCase
from PyQt4 import QtGui
from openlp.core.lib import Registry
from openlp.core.common import Registry
from openlp.plugins.songs.forms.topicsform import TopicsForm