From db87a9e7dd1b363fa1eed226ebac99b57360f4f0 Mon Sep 17 00:00:00 2001
From: Jon Tibble
Date: Tue, 27 Jul 2010 16:07:00 +0100
Subject: [PATCH 1/9] Exception handling fixes in bible import
---
openlp/plugins/bibles/forms/importwizardform.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/openlp/plugins/bibles/forms/importwizardform.py b/openlp/plugins/bibles/forms/importwizardform.py
index ba48ed5fb..371dcfa56 100644
--- a/openlp/plugins/bibles/forms/importwizardform.py
+++ b/openlp/plugins/bibles/forms/importwizardform.py
@@ -327,6 +327,7 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
#Load and store Crosswalk Bibles
filepath = AppLocation.get_directory(AppLocation.PluginsDir)
filepath = os.path.join(filepath, u'bibles', u'resources')
+ books_file = None
try:
self.web_bible_list[WebDownload.Crosswalk] = {}
books_file = open(
@@ -348,6 +349,7 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
if books_file:
books_file.close()
#Load and store BibleGateway Bibles
+ books_file = None
try:
self.web_bible_list[WebDownload.BibleGateway] = {}
books_file = open(os.path.join(filepath, u'biblegateway.csv'), 'r')
From 3b5c29dc073bb893ef8d76fc78a304f4a613cafd Mon Sep 17 00:00:00 2001
From: Jon Tibble
Date: Wed, 28 Jul 2010 13:44:33 +0100
Subject: [PATCH 2/9] Missing space
---
openlp/core/ui/generaltab.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py
index ce33c65f0..ec0d10743 100644
--- a/openlp/core/ui/generaltab.py
+++ b/openlp/core/ui/generaltab.py
@@ -120,7 +120,7 @@ class GeneralTab(SettingsTab):
self.settingsLayout.addWidget(self.timeoutLabel, 2, 0, 1, 1)
self.timeoutSpinBox = QtGui.QSpinBox(self.settingsGroupBox)
self.timeoutSpinBox.setObjectName("timeoutSpinBox")
- self.settingsLayout.addWidget(self.timeoutSpinBox, 2,1, 1, 1)
+ self.settingsLayout.addWidget(self.timeoutSpinBox, 2, 1, 1, 1)
self.generalLeftLayout.addWidget(self.settingsGroupBox)
self.generalLeftSpacer = QtGui.QSpacerItem(20, 40,
QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
From 2bd442ff4fd120afbbb24a729a4e415ac7e6d87d Mon Sep 17 00:00:00 2001
From: Jon Tibble
Date: Wed, 28 Jul 2010 14:15:39 +0100
Subject: [PATCH 3/9] More naming cleanup
---
openlp/core/ui/servicemanager.py | 143 +++++++++---------
openlp/core/utils/languagemanager.py | 6 +-
openlp/plugins/alerts/alertsplugin.py | 6 +-
openlp/plugins/bibles/bibleplugin.py | 30 ++--
.../plugins/bibles/forms/importwizardform.py | 8 +-
openlp/plugins/bibles/lib/biblestab.py | 8 +-
openlp/plugins/bibles/lib/manager.py | 12 +-
7 files changed, 104 insertions(+), 109 deletions(-)
diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py
index a9f7af20c..b1ccce77e 100644
--- a/openlp/core/ui/servicemanager.py
+++ b/openlp/core/ui/servicemanager.py
@@ -112,60 +112,60 @@ class ServiceManager(QtGui.QWidget):
self.serviceNoteForm = ServiceNoteForm(self.parent)
self.serviceItemEditForm = ServiceItemEditForm(self.parent)
#start with the layout
- self.Layout = QtGui.QVBoxLayout(self)
- self.Layout.setSpacing(0)
- self.Layout.setMargin(0)
+ self.layout = QtGui.QVBoxLayout(self)
+ self.layout.setSpacing(0)
+ self.layout.setMargin(0)
# Create the top toolbar
- self.Toolbar = OpenLPToolbar(self)
- self.Toolbar.addToolbarButton(
+ self.toolbar = OpenLPToolbar(self)
+ self.toolbar.addToolbarButton(
translate('OpenLP.ServiceManager', 'New Service'),
u':/general/general_new.png',
translate('OpenLP.ServiceManager', 'Create a new service'),
self.onNewService)
- self.Toolbar.addToolbarButton(
+ self.toolbar.addToolbarButton(
translate('OpenLP.ServiceManager', 'Open Service'),
u':/general/general_open.png',
translate('OpenLP.ServiceManager', 'Load an existing service'),
self.onLoadService)
- self.Toolbar.addToolbarButton(
+ self.toolbar.addToolbarButton(
translate('OpenLP.ServiceManager', 'Save Service'),
u':/general/general_save.png',
translate('OpenLP.ServiceManager', 'Save this service'),
self.onQuickSaveService)
- self.Toolbar.addSeparator()
- self.ThemeLabel = QtGui.QLabel(translate('OpenLP.ServiceManager',
+ self.toolbar.addSeparator()
+ self.themeLabel = QtGui.QLabel(translate('OpenLP.ServiceManager',
'Theme:'), self)
- self.ThemeLabel.setMargin(3)
- self.Toolbar.addToolbarWidget(u'ThemeLabel', self.ThemeLabel)
- self.ThemeComboBox = QtGui.QComboBox(self.Toolbar)
- self.ThemeComboBox.setToolTip(translate('OpenLP.ServiceManager',
+ self.themeLabel.setMargin(3)
+ self.toolbar.addToolbarWidget(u'ThemeLabel', self.themeLabel)
+ self.themeComboBox = QtGui.QComboBox(self.toolbar)
+ self.themeComboBox.setToolTip(translate('OpenLP.ServiceManager',
'Select a theme for the service'))
- self.ThemeComboBox.setSizeAdjustPolicy(
+ self.themeComboBox.setSizeAdjustPolicy(
QtGui.QComboBox.AdjustToContents)
- self.Toolbar.addToolbarWidget(u'ThemeWidget', self.ThemeComboBox)
- self.Layout.addWidget(self.Toolbar)
+ self.toolbar.addToolbarWidget(u'ThemeWidget', self.themeComboBox)
+ self.layout.addWidget(self.toolbar)
# Create the service manager list
- self.ServiceManagerList = ServiceManagerList(self)
- self.ServiceManagerList.setEditTriggers(
+ self.serviceManagerList = ServiceManagerList(self)
+ self.serviceManagerList.setEditTriggers(
QtGui.QAbstractItemView.CurrentChanged |
QtGui.QAbstractItemView.DoubleClicked |
QtGui.QAbstractItemView.EditKeyPressed)
- self.ServiceManagerList.setDragDropMode(
+ self.serviceManagerList.setDragDropMode(
QtGui.QAbstractItemView.DragDrop)
- self.ServiceManagerList.setAlternatingRowColors(True)
- self.ServiceManagerList.setHeaderHidden(True)
- self.ServiceManagerList.setExpandsOnDoubleClick(False)
- self.ServiceManagerList.setContextMenuPolicy(
+ self.serviceManagerList.setAlternatingRowColors(True)
+ self.serviceManagerList.setHeaderHidden(True)
+ self.serviceManagerList.setExpandsOnDoubleClick(False)
+ self.serviceManagerList.setContextMenuPolicy(
QtCore.Qt.CustomContextMenu)
- QtCore.QObject.connect(self.ServiceManagerList,
+ QtCore.QObject.connect(self.serviceManagerList,
QtCore.SIGNAL('customContextMenuRequested(QPoint)'),
self.contextMenu)
- self.ServiceManagerList.setObjectName(u'ServiceManagerList')
+ self.serviceManagerList.setObjectName(u'serviceManagerList')
# enable drop
- self.ServiceManagerList.__class__.dragEnterEvent = self.dragEnterEvent
- self.ServiceManagerList.__class__.dragMoveEvent = self.dragEnterEvent
- self.ServiceManagerList.__class__.dropEvent = self.dropEvent
- self.Layout.addWidget(self.ServiceManagerList)
+ self.serviceManagerList.__class__.dragEnterEvent = self.dragEnterEvent
+ self.serviceManagerList.__class__.dragMoveEvent = self.dragEnterEvent
+ self.serviceManagerList.__class__.dropEvent = self.dropEvent
+ self.layout.addWidget(self.serviceManagerList)
# Add the bottom toolbar
self.OrderToolbar = OpenLPToolbar(self)
self.OrderToolbar.addToolbarButton(
@@ -199,15 +199,15 @@ class ServiceManager(QtGui.QWidget):
translate('OpenLP.ServiceManager',
'Delete the selected item from the service.'),
self.onDeleteFromService)
- self.Layout.addWidget(self.OrderToolbar)
+ self.layout.addWidget(self.OrderToolbar)
# Connect up our signals and slots
- QtCore.QObject.connect(self.ThemeComboBox,
+ QtCore.QObject.connect(self.themeComboBox,
QtCore.SIGNAL(u'activated(int)'), self.onThemeComboBoxSelected)
- QtCore.QObject.connect(self.ServiceManagerList,
+ QtCore.QObject.connect(self.serviceManagerList,
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'), self.makeLive)
- QtCore.QObject.connect(self.ServiceManagerList,
+ QtCore.QObject.connect(self.serviceManagerList,
QtCore.SIGNAL(u'itemCollapsed(QTreeWidgetItem*)'), self.collapsed)
- QtCore.QObject.connect(self.ServiceManagerList,
+ QtCore.QObject.connect(self.serviceManagerList,
QtCore.SIGNAL(u'itemExpanded(QTreeWidgetItem*)'), self.expanded)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'theme_update_list'), self.updateThemeList)
@@ -268,7 +268,7 @@ class ServiceManager(QtGui.QWidget):
self.suffixes.append(suffix)
def contextMenu(self, point):
- item = self.ServiceManagerList.itemAt(point)
+ item = self.serviceManagerList.itemAt(point)
if item is None:
return
if item.parent() is None:
@@ -289,7 +289,7 @@ class ServiceManager(QtGui.QWidget):
self.themeMenu.menuAction().setVisible(False)
if serviceItem[u'service_item'].is_text():
self.themeMenu.menuAction().setVisible(True)
- action = self.menu.exec_(self.ServiceManagerList.mapToGlobal(point))
+ action = self.menu.exec_(self.serviceManagerList.mapToGlobal(point))
if action == self.editAction:
self.remoteEdit()
if action == self.maintainAction:
@@ -326,14 +326,14 @@ class ServiceManager(QtGui.QWidget):
Called by the SlideController to select the
next service item
"""
- if len(self.ServiceManagerList.selectedItems()) == 0:
+ if len(self.serviceManagerList.selectedItems()) == 0:
return
- selected = self.ServiceManagerList.selectedItems()[0]
+ selected = self.serviceManagerList.selectedItems()[0]
lookFor = 0
- serviceIterator = QtGui.QTreeWidgetItemIterator(self.ServiceManagerList)
+ serviceIterator = QtGui.QTreeWidgetItemIterator(self.serviceManagerList)
while serviceIterator.value():
if lookFor == 1 and serviceIterator.value().parent() is None:
- self.ServiceManagerList.setCurrentItem(serviceIterator.value())
+ self.serviceManagerList.setCurrentItem(serviceIterator.value())
self.makeLive()
return
if serviceIterator.value() == selected:
@@ -345,15 +345,15 @@ class ServiceManager(QtGui.QWidget):
Called by the SlideController to select the
previous service item
"""
- if len(self.ServiceManagerList.selectedItems()) == 0:
+ if len(self.serviceManagerList.selectedItems()) == 0:
return
- selected = self.ServiceManagerList.selectedItems()[0]
+ selected = self.serviceManagerList.selectedItems()[0]
prevItem = None
- serviceIterator = QtGui.QTreeWidgetItemIterator(self.ServiceManagerList)
+ serviceIterator = QtGui.QTreeWidgetItemIterator(self.serviceManagerList)
while serviceIterator.value():
if serviceIterator.value() == selected:
if prevItem:
- self.ServiceManagerList.setCurrentItem(prevItem)
+ self.serviceManagerList.setCurrentItem(prevItem)
self.makeLive()
return
if serviceIterator.value().parent() is None:
@@ -370,9 +370,9 @@ class ServiceManager(QtGui.QWidget):
"""
Makes a specific item in the service live
"""
- if index >= 0 and index < self.ServiceManagerList.topLevelItemCount:
- item = self.ServiceManagerList.topLevelItem(index)
- self.ServiceManagerList.setCurrentItem(item)
+ if index >= 0 and index < self.serviceManagerList.topLevelItemCount:
+ item = self.serviceManagerList.topLevelItem(index)
+ self.serviceManagerList.setCurrentItem(item)
self.makeLive()
def onMoveSelectionUp(self):
@@ -380,7 +380,7 @@ class ServiceManager(QtGui.QWidget):
Moves the selection up the window
Called by the up arrow
"""
- serviceIterator = QtGui.QTreeWidgetItemIterator(self.ServiceManagerList)
+ serviceIterator = QtGui.QTreeWidgetItemIterator(self.serviceManagerList)
tempItem = None
setLastItem = False
while serviceIterator:
@@ -405,7 +405,7 @@ class ServiceManager(QtGui.QWidget):
Moves the selection down the window
Called by the down arrow
"""
- serviceIterator = QtGui.QTreeWidgetItemIterator(self.ServiceManagerList)
+ serviceIterator = QtGui.QTreeWidgetItemIterator(self.serviceManagerList)
firstItem = serviceIterator
setSelected = False
while serviceIterator:
@@ -503,7 +503,7 @@ class ServiceManager(QtGui.QWidget):
QtGui.QMessageBox.Save)
if ret == QtGui.QMessageBox.Save:
self.onSaveService()
- self.ServiceManagerList.clear()
+ self.serviceManagerList.clear()
self.serviceItems = []
self.serviceName = u''
self.isNew = True
@@ -531,10 +531,10 @@ class ServiceManager(QtGui.QWidget):
item[u'order'] = count
count += 1
#Repaint the screen
- self.ServiceManagerList.clear()
+ self.serviceManagerList.clear()
for itemcount, item in enumerate(self.serviceItems):
serviceitem = item[u'service_item']
- treewidgetitem = QtGui.QTreeWidgetItem(self.ServiceManagerList)
+ treewidgetitem = QtGui.QTreeWidgetItem(self.serviceManagerList)
if serviceitem.is_valid:
if serviceitem.notes:
icon = QtGui.QImage(serviceitem.icon)
@@ -565,7 +565,7 @@ class ServiceManager(QtGui.QWidget):
if serviceItem == itemcount and serviceItemCount == count:
#preserve expanding status as setCurrentItem sets it to True
temp = item[u'expanded']
- self.ServiceManagerList.setCurrentItem(treewidgetitem1)
+ self.serviceManagerList.setCurrentItem(treewidgetitem1)
item[u'expanded'] = temp
treewidgetitem.setExpanded(item[u'expanded'])
@@ -758,7 +758,7 @@ class ServiceManager(QtGui.QWidget):
"""
Set the theme for the current service
"""
- self.service_theme = unicode(self.ThemeComboBox.currentText())
+ self.service_theme = unicode(self.themeComboBox.currentText())
self.parent.RenderManager.set_service_theme(self.service_theme)
QtCore.QSettings().setValue(
self.parent.serviceSettingsSection + u'/service theme',
@@ -771,11 +771,11 @@ class ServiceManager(QtGui.QWidget):
sure the theme combo box is in the correct state.
"""
if self.parent.RenderManager.theme_level == ThemeLevel.Global:
- self.Toolbar.actions[u'ThemeLabel'].setVisible(False)
- self.Toolbar.actions[u'ThemeWidget'].setVisible(False)
+ self.toolbar.actions[u'ThemeLabel'].setVisible(False)
+ self.toolbar.actions[u'ThemeWidget'].setVisible(False)
else:
- self.Toolbar.actions[u'ThemeLabel'].setVisible(True)
- self.Toolbar.actions[u'ThemeWidget'].setVisible(True)
+ self.toolbar.actions[u'ThemeLabel'].setVisible(True)
+ self.toolbar.actions[u'ThemeWidget'].setVisible(True)
def regenerateServiceItems(self):
"""
@@ -786,7 +786,7 @@ class ServiceManager(QtGui.QWidget):
self.parent.RenderManager.themedata = None
if self.serviceItems:
tempServiceItems = self.serviceItems
- self.ServiceManagerList.clear()
+ self.serviceManagerList.clear()
self.serviceItems = []
self.isNew = True
for item in tempServiceItems:
@@ -903,7 +903,7 @@ class ServiceManager(QtGui.QWidget):
"""
Finds a ServiceItem in the list
"""
- items = self.ServiceManagerList.selectedItems()
+ items = self.serviceManagerList.selectedItems()
pos = 0
count = 0
for item in items:
@@ -923,7 +923,6 @@ class ServiceManager(QtGui.QWidget):
``event``
Handle of the event pint passed
-
"""
event.accept()
@@ -939,7 +938,7 @@ class ServiceManager(QtGui.QWidget):
link = event.mimeData()
if link.hasText():
plugin = event.mimeData().text()
- item = self.ServiceManagerList.itemAt(event.pos())
+ item = self.serviceManagerList.itemAt(event.pos())
#ServiceManager started the drag and drop
if plugin == u'ServiceManager':
startpos, startCount = self.findServiceItem()
@@ -983,23 +982,21 @@ class ServiceManager(QtGui.QWidget):
``theme_list``
A list of current themes to be displayed
"""
- self.ThemeComboBox.clear()
+ self.themeComboBox.clear()
self.themeMenu.clear()
- self.ThemeComboBox.addItem(u'')
+ self.themeComboBox.addItem(u'')
for theme in theme_list:
- self.ThemeComboBox.addItem(theme)
- action = context_menu_action(
- self.ServiceManagerList,
- None,
- theme , self.onThemeChangeAction)
+ self.themeComboBox.addItem(theme)
+ action = context_menu_action(self.serviceManagerList, None, theme,
+ self.onThemeChangeAction)
self.themeMenu.addAction(action)
- id = self.ThemeComboBox.findText(self.service_theme,
+ index = self.themeComboBox.findText(self.service_theme,
QtCore.Qt.MatchExactly)
# Not Found
- if id == -1:
- id = 0
+ if index == -1:
+ index = 0
self.service_theme = u''
- self.ThemeComboBox.setCurrentIndex(id)
+ self.themeComboBox.setCurrentIndex(index)
self.parent.RenderManager.set_service_theme(self.service_theme)
self.regenerateServiceItems()
diff --git a/openlp/core/utils/languagemanager.py b/openlp/core/utils/languagemanager.py
index 6b939d9b2..275d6985b 100644
--- a/openlp/core/utils/languagemanager.py
+++ b/openlp/core/utils/languagemanager.py
@@ -54,10 +54,10 @@ class LanguageManager(object):
"""
if LanguageManager.AutoLanguage:
language = QtCore.QLocale.system().name()
- lang_Path = AppLocation.get_directory(AppLocation.AppDir)
- lang_Path = os.path.join(lang_Path, u'resources', u'i18n')
+ lang_path = AppLocation.get_directory(AppLocation.AppDir)
+ lang_path = os.path.join(lang_path, u'resources', u'i18n')
app_translator = QtCore.QTranslator()
- if app_translator.load("openlp_" + language, lang_Path):
+ if app_translator.load("openlp_" + language, lang_path):
return app_translator
@staticmethod
diff --git a/openlp/plugins/alerts/alertsplugin.py b/openlp/plugins/alerts/alertsplugin.py
index c62f088a6..c4e1f50ea 100644
--- a/openlp/plugins/alerts/alertsplugin.py
+++ b/openlp/plugins/alerts/alertsplugin.py
@@ -66,11 +66,9 @@ class AlertsPlugin(Plugin):
"""
log.info(u'add tools menu')
self.toolsAlertItem = QtGui.QAction(tools_menu)
- AlertIcon = build_icon(u':/plugins/plugin_alerts.png')
- self.toolsAlertItem.setIcon(AlertIcon)
+ self.toolsAlertItem.setIcon(build_icon(u':/plugins/plugin_alerts.png'))
self.toolsAlertItem.setObjectName(u'toolsAlertItem')
- self.toolsAlertItem.setText(
- translate('AlertsPlugin', '&Alert'))
+ self.toolsAlertItem.setText(translate('AlertsPlugin', '&Alert'))
self.toolsAlertItem.setStatusTip(
translate('AlertsPlugin', 'Show an alert message.'))
self.toolsAlertItem.setShortcut(u'F7')
diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py
index d81aed399..5550dd90e 100644
--- a/openlp/plugins/bibles/bibleplugin.py
+++ b/openlp/plugins/bibles/bibleplugin.py
@@ -50,14 +50,14 @@ class BiblePlugin(Plugin):
if self.manager is None:
self.manager = BibleManager(self)
Plugin.initialise(self)
- self.ImportBibleItem.setVisible(True)
- self.ExportBibleItem.setVisible(True)
+ self.importBibleItem.setVisible(True)
+ self.exportBibleItem.setVisible(True)
def finalise(self):
log.info(u'Plugin Finalise')
Plugin.finalise(self)
- self.ImportBibleItem.setVisible(False)
- self.ExportBibleItem.setVisible(False)
+ self.importBibleItem.setVisible(False)
+ self.exportBibleItem.setVisible(False)
def getSettingsTab(self):
return BiblesTab(self.name)
@@ -67,23 +67,23 @@ class BiblePlugin(Plugin):
return BibleMediaItem(self, self.icon, self.name)
def addImportMenuItem(self, import_menu):
- self.ImportBibleItem = QtGui.QAction(import_menu)
- self.ImportBibleItem.setObjectName(u'ImportBibleItem')
- import_menu.addAction(self.ImportBibleItem)
- self.ImportBibleItem.setText(
+ self.importBibleItem = QtGui.QAction(import_menu)
+ self.importBibleItem.setObjectName(u'importBibleItem')
+ import_menu.addAction(self.importBibleItem)
+ self.importBibleItem.setText(
translate('BiblesPlugin', '&Bible'))
# signals and slots
- QtCore.QObject.connect(self.ImportBibleItem,
+ QtCore.QObject.connect(self.importBibleItem,
QtCore.SIGNAL(u'triggered()'), self.onBibleImportClick)
- self.ImportBibleItem.setVisible(False)
+ self.importBibleItem.setVisible(False)
def addExportMenuItem(self, export_menu):
- self.ExportBibleItem = QtGui.QAction(export_menu)
- self.ExportBibleItem.setObjectName(u'ExportBibleItem')
- export_menu.addAction(self.ExportBibleItem)
- self.ExportBibleItem.setText(translate(
+ self.exportBibleItem = QtGui.QAction(export_menu)
+ self.exportBibleItem.setObjectName(u'exportBibleItem')
+ export_menu.addAction(self.exportBibleItem)
+ self.exportBibleItem.setText(translate(
'BiblesPlugin', '&Bible'))
- self.ExportBibleItem.setVisible(False)
+ self.exportBibleItem.setVisible(False)
def onBibleImportClick(self):
if self.mediaItem:
diff --git a/openlp/plugins/bibles/forms/importwizardform.py b/openlp/plugins/bibles/forms/importwizardform.py
index 371dcfa56..c955847c6 100644
--- a/openlp/plugins/bibles/forms/importwizardform.py
+++ b/openlp/plugins/bibles/forms/importwizardform.py
@@ -50,8 +50,8 @@ class WebDownload(object):
}
@classmethod
- def get_name(cls, id):
- return cls.Names[id]
+ def get_name(cls, name):
+ return cls.Names[name]
class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
@@ -260,8 +260,8 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
if self.currentId() == 3:
Receiver.send_message(u'bibles_stop_import')
- def onCurrentIdChanged(self, id):
- if id == 3:
+ def onCurrentIdChanged(self, pageId):
+ if pageId == 3:
self.preImport()
self.performImport()
self.postImport()
diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py
index 162ab13d2..8399ee1d4 100644
--- a/openlp/plugins/bibles/lib/biblestab.py
+++ b/openlp/plugins/bibles/lib/biblestab.py
@@ -241,10 +241,10 @@ class BiblesTab(SettingsTab):
self.BibleThemeComboBox.addItem(u'')
for theme in theme_list:
self.BibleThemeComboBox.addItem(theme)
- id = self.BibleThemeComboBox.findText(
+ index = self.BibleThemeComboBox.findText(
unicode(self.bible_theme), QtCore.Qt.MatchExactly)
- if id == -1:
+ if index == -1:
# Not Found
- id = 0
+ index = 0
self.bible_theme = u''
- self.BibleThemeComboBox.setCurrentIndex(id)
+ self.BibleThemeComboBox.setCurrentIndex(index)
diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py
index 0f06764ad..5c2767d0e 100644
--- a/openlp/plugins/bibles/lib/manager.py
+++ b/openlp/plugins/bibles/lib/manager.py
@@ -63,20 +63,20 @@ class BibleFormat(object):
WebDownload = 3
@staticmethod
- def get_class(id):
+ def get_class(format):
"""
Return the appropriate imeplementation class.
- ``id``
+ ``format``
The Bible format.
"""
- if id == BibleFormat.OSIS:
+ if format == BibleFormat.OSIS:
return OSISBible
- elif id == BibleFormat.CSV:
+ elif format == BibleFormat.CSV:
return CSVBible
- elif id == BibleFormat.OpenSong:
+ elif format == BibleFormat.OpenSong:
return OpenSongBible
- elif id == BibleFormat.WebDownload:
+ elif format == BibleFormat.WebDownload:
return HTTPBible
else:
return None
From c099e6f8083bad8fdbaa4aca0abbd41788175b55 Mon Sep 17 00:00:00 2001
From: Jon Tibble
Date: Wed, 28 Jul 2010 14:32:12 +0100
Subject: [PATCH 4/9] Naming cleanup
---
openlp/plugins/custom/lib/customtab.py | 38 +++++++++++++-------------
openlp/plugins/songs/lib/__init__.py | 12 ++++----
2 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/openlp/plugins/custom/lib/customtab.py b/openlp/plugins/custom/lib/customtab.py
index 0081524b6..77ef0f3f6 100644
--- a/openlp/plugins/custom/lib/customtab.py
+++ b/openlp/plugins/custom/lib/customtab.py
@@ -38,29 +38,29 @@ class CustomTab(SettingsTab):
def setupUi(self):
self.setObjectName(u'CustomTab')
self.tabTitleVisible = translate('CustomPlugin.CustomTab', 'Custom')
- self.CustomLayout = QtGui.QFormLayout(self)
- self.CustomLayout.setSpacing(8)
- self.CustomLayout.setMargin(8)
- self.CustomLayout.setObjectName(u'CustomLayout')
- self.CustomModeGroupBox = QtGui.QGroupBox(self)
- self.CustomModeGroupBox.setObjectName(u'CustomModeGroupBox')
- self.CustomModeLayout = QtGui.QVBoxLayout(self.CustomModeGroupBox)
- self.CustomModeLayout.setSpacing(8)
- self.CustomModeLayout.setMargin(8)
- self.CustomModeLayout.setObjectName(u'CustomModeLayout')
- self.DisplayFooterCheckBox = QtGui.QCheckBox(self.CustomModeGroupBox)
- self.DisplayFooterCheckBox.setObjectName(u'DisplayFooterCheckBox')
- self.CustomModeLayout.addWidget(self.DisplayFooterCheckBox)
- self.CustomLayout.setWidget(
- 0, QtGui.QFormLayout.LabelRole, self.CustomModeGroupBox)
- QtCore.QObject.connect(self.DisplayFooterCheckBox,
+ self.customLayout = QtGui.QFormLayout(self)
+ self.customLayout.setSpacing(8)
+ self.customLayout.setMargin(8)
+ self.customLayout.setObjectName(u'customLayout')
+ self.customModeGroupBox = QtGui.QGroupBox(self)
+ self.customModeGroupBox.setObjectName(u'customModeGroupBox')
+ self.customModeLayout = QtGui.QVBoxLayout(self.customModeGroupBox)
+ self.customModeLayout.setSpacing(8)
+ self.customModeLayout.setMargin(8)
+ self.customModeLayout.setObjectName(u'customModeLayout')
+ self.displayFooterCheckBox = QtGui.QCheckBox(self.customModeGroupBox)
+ self.displayFooterCheckBox.setObjectName(u'displayFooterCheckBox')
+ self.customModeLayout.addWidget(self.displayFooterCheckBox)
+ self.customLayout.setWidget(
+ 0, QtGui.QFormLayout.LabelRole, self.customModeGroupBox)
+ QtCore.QObject.connect(self.displayFooterCheckBox,
QtCore.SIGNAL(u'stateChanged(int)'),
self.onDisplayFooterCheckBoxChanged)
def retranslateUi(self):
- self.CustomModeGroupBox.setTitle(translate('CustomPlugin.CustomTab',
+ self.customModeGroupBox.setTitle(translate('CustomPlugin.CustomTab',
'Custom Display'))
- self.DisplayFooterCheckBox.setText(
+ self.displayFooterCheckBox.setText(
translate('CustomPlugin.CustomTab', 'Display footer'))
def onDisplayFooterCheckBoxChanged(self, check_state):
@@ -73,7 +73,7 @@ class CustomTab(SettingsTab):
self.displayFooter = QtCore.QSettings().value(
self.settingsSection + u'/display footer',
QtCore.QVariant(True)).toBool()
- self.DisplayFooterCheckBox.setChecked(self.displayFooter)
+ self.displayFooterCheckBox.setChecked(self.displayFooter)
def save(self):
QtCore.QSettings().setValue(self.settingsSection + u'/display footer',
diff --git a/openlp/plugins/songs/lib/__init__.py b/openlp/plugins/songs/lib/__init__.py
index 23bbc2a52..b8f4d9a05 100644
--- a/openlp/plugins/songs/lib/__init__.py
+++ b/openlp/plugins/songs/lib/__init__.py
@@ -42,20 +42,20 @@ class SongFormat(object):
CSV = 3
@staticmethod
- def get_class(id):
+ def get_class(format):
"""
Return the appropriate imeplementation class.
- ``id``
+ ``format``
The song format.
"""
-# if id == SongFormat.OpenLyrics:
+# if format == SongFormat.OpenLyrics:
# return OpenLyricsSong
-# elif id == SongFormat.OpenSong:
+# elif format == SongFormat.OpenSong:
# return OpenSongSong
-# elif id == SongFormat.CCLI:
+# elif format == SongFormat.CCLI:
# return CCLISong
-# elif id == SongFormat.CSV:
+# elif format == SongFormat.CSV:
# return CSVSong
# else:
return None
From 8838e9563eab69ac44925f9b5aad69f03ba8757c Mon Sep 17 00:00:00 2001
From: Jon Tibble
Date: Wed, 28 Jul 2010 14:36:29 +0100
Subject: [PATCH 5/9] Naming cleanup fixes
---
openlp/core/ui/mainwindow.py | 6 +++---
openlp/core/ui/thememanager.py | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py
index cbbe7f5bd..1730e02d8 100644
--- a/openlp/core/ui/mainwindow.py
+++ b/openlp/core/ui/mainwindow.py
@@ -220,17 +220,17 @@ class Ui_MainWindow(object):
# Create the menu items
self.FileNewItem = QtGui.QAction(MainWindow)
self.FileNewItem.setIcon(
- self.ServiceManagerContents.Toolbar.getIconFromTitle(
+ self.ServiceManagerContents.toolbar.getIconFromTitle(
u'New Service'))
self.FileNewItem.setObjectName(u'FileNewItem')
self.FileOpenItem = QtGui.QAction(MainWindow)
self.FileOpenItem.setIcon(
- self.ServiceManagerContents.Toolbar.getIconFromTitle(
+ self.ServiceManagerContents.toolbar.getIconFromTitle(
u'Open Service'))
self.FileOpenItem.setObjectName(u'FileOpenItem')
self.FileSaveItem = QtGui.QAction(MainWindow)
self.FileSaveItem.setIcon(
- self.ServiceManagerContents.Toolbar.getIconFromTitle(
+ self.ServiceManagerContents.toolbar.getIconFromTitle(
u'Save Service'))
self.FileSaveItem.setObjectName(u'FileSaveItem')
self.FileSaveAsItem = QtGui.QAction(MainWindow)
diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py
index 5198c0ea4..760d8b059 100644
--- a/openlp/core/ui/thememanager.py
+++ b/openlp/core/ui/thememanager.py
@@ -49,7 +49,7 @@ class ThemeManager(QtGui.QWidget):
QtGui.QWidget.__init__(self, parent)
self.parent = parent
self.settingsSection = u'themes'
- self.serviceComboBox = self.parent.ServiceManagerContents.ThemeComboBox
+ self.serviceComboBox = self.parent.ServiceManagerContents.themeComboBox
self.layout = QtGui.QVBoxLayout(self)
self.layout.setSpacing(0)
self.layout.setMargin(0)
From fc849398a916277176b180805c5174380f7993a3 Mon Sep 17 00:00:00 2001
From: Jon Tibble
Date: Thu, 29 Jul 2010 15:36:02 +0100
Subject: [PATCH 6/9] Bible reference refactor
---
openlp/plugins/bibles/lib/__init__.py | 160 +++++++++++++++-
openlp/plugins/bibles/lib/common.py | 256 --------------------------
openlp/plugins/bibles/lib/http.py | 7 +-
openlp/plugins/bibles/lib/manager.py | 2 +-
4 files changed, 164 insertions(+), 261 deletions(-)
delete mode 100644 openlp/plugins/bibles/lib/common.py
diff --git a/openlp/plugins/bibles/lib/__init__.py b/openlp/plugins/bibles/lib/__init__.py
index 3ad4fe39b..fbb292db5 100644
--- a/openlp/plugins/bibles/lib/__init__.py
+++ b/openlp/plugins/bibles/lib/__init__.py
@@ -23,8 +23,166 @@
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
+"""
+The :mod:`lib` module contains all the library functionality for the bibles
+plugin.
+"""
+import logging
+import re
+
+log = logging.getLogger(__name__)
+
+###############################################################################
+# BIBLE_REFERENCE regular expression produces the following match groups:
+#
+# 0 This is a special group consisting of the whole string that matched.
+# 1 [\w ]+ The book the reference is from.
+# 2 [0-9]+ The first (possibly only) chapter in the reference.
+# 3 None|[0-9]+ None or the only verse or the first verse in a
+# verse range or the start verse in a chapter range.
+# 4 None|[0-9]+|end None or the end verse of the first verse range or
+# the end chapter of a chapter range.
+# 5 None|[0-9]+ None or the second chapter in multiple (non-ranged)
+# chapters.
+# 6 None|[0-9]+|end None, the start of the second verse range or the
+# end of a chapter range.
+# 7 None|[0-9]+|end None or the end of the second verse range.
+###############################################################################
+
+BIBLE_REFERENCE = re.compile(
+ r'^([\w ]+?) *([0-9]+)' # Initial book and chapter
+ r'(?: *[:|v|V] *([0-9]+))?' # Verse for first chapter
+ r'(?: *- *([0-9]+|end$))?' # Range for verses or chapters
+ r'(?:(?:,([0-9]+))?' # Second chapter
+ r' *[,|:|v|V] *([0-9]+|end$)' # More range for verses or chapters
+ r'(?: *- *([0-9]+|end$))?)?$', # End of second verse range
+ re.UNICODE)
+
+def check_end(match_group):
+ """
+ Check if a regular expression match group contains the text u'end' or
+ should be converted to an int.
+
+ ``match_group``
+ The match group to check.
+ """
+ if match_group == u'end':
+ return -1
+ else:
+ return int(match_group)
+
+def parse_reference(reference):
+ """
+ This is the über-awesome function that takes a person's typed in string
+ and converts it to a reference list, a list of references to be queried
+ from the Bible database files.
+
+ The reference list is a list of tuples, with each tuple structured like
+ this::
+ (book, chapter, start_verse, end_verse)
+
+ ``reference``
+ The bible reference to parse.
+
+ Returns None or a reference list.
+ """
+ reference = reference.strip()
+ log.debug('parse_reference("%s")', reference)
+ unified_ref_list = []
+ match = BIBLE_REFERENCE.match(reference)
+ if match:
+ log.debug(u'Matched reference %s' % reference)
+ book = match.group(1)
+ chapter = int(match.group(2))
+ if match.group(7):
+ # Two verse ranges
+ vr1_start = int(match.group(3))
+ vr1_end = int(match.group(4))
+ unified_ref_list.append((book, chapter, vr1_start, vr1_end))
+ vr2_start = int(match.group(6))
+ vr2_end = check_end(match.group(7))
+ if match.group(5):
+ # One verse range per chapter
+ chapter2 = int(match.group(5))
+ unified_ref_list.append((book, chapter2, vr2_start, vr2_end))
+ else:
+ unified_ref_list.append((book, chapter, vr2_start, vr2_end))
+ elif match.group(6):
+ # Chapter range with verses
+ if match.group(3):
+ vr1_start = int(match.group(3))
+ else:
+ vr1_start = 1
+ if match.group(2) == match.group(4):
+ vr1_end = int(match.group(6))
+ unified_ref_list.append((book, chapter, vr1_start, vr1_end))
+ else:
+ vr1_end = -1
+ unified_ref_list.append((book, chapter, vr1_start, vr1_end))
+ vr2_end = check_end(match.group(6))
+ if int(match.group(4)) > chapter:
+ for x in range(chapter + 1, int(match.group(4)) + 1):
+ if x == int(match.group(4)):
+ unified_ref_list.append((book, x, 1, vr2_end))
+ else:
+ unified_ref_list.append((book, x, 1, -1))
+ elif match.group(4):
+ # Chapter range or chapter and verse range
+ if match.group(3):
+ vr1_start = int(match.group(3))
+ vr1_end = check_end(match.group(4))
+ if vr1_end == -1 or vr1_end > vr1_start:
+ unified_ref_list.append((book, chapter, vr1_start, vr1_end))
+ else:
+ log.debug(u'Ambiguous reference: %s' % reference)
+ return None
+ elif match.group(4) != u'end':
+ for x in range(chapter, int(match.group(4)) + 1):
+ unified_ref_list.append((book, x, 1, -1))
+ else:
+ log.debug(u'Unsupported reference: %s' % reference)
+ return None
+ elif match.group(3):
+ # Single chapter and verse
+ verse = int(match.group(3))
+ unified_ref_list.append((book, chapter, verse, verse))
+ else:
+ # Single chapter
+ unified_ref_list.append((book, chapter, -1, -1))
+ else:
+ log.debug(u'Invalid reference: %s' % reference)
+ return None
+ return unified_ref_list
+
+
+class SearchResults(object):
+ """
+ Encapsulate a set of search results. This is Bible-type independant.
+ """
+ def __init__(self, book, chapter, verselist):
+ """
+ Create the search result object.
+
+ ``book``
+ The book of the Bible.
+
+ ``chapter``
+ The chapter of the book.
+
+ ``verselist``
+ The list of verses for this reading
+ """
+ self.book = book
+ self.chapter = chapter
+ self.verselist = verselist
+
+ def has_verselist(self):
+ """
+ Returns whether or not the verse list contains verses.
+ """
+ return len(self.verselist) > 0
+
-from common import BibleCommon
from manager import BibleManager
from biblestab import BiblesTab
from mediaitem import BibleMediaItem
diff --git a/openlp/plugins/bibles/lib/common.py b/openlp/plugins/bibles/lib/common.py
deleted file mode 100644
index 5308495a3..000000000
--- a/openlp/plugins/bibles/lib/common.py
+++ /dev/null
@@ -1,256 +0,0 @@
-# -*- coding: utf-8 -*-
-# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
-
-###############################################################################
-# OpenLP - Open Source Lyrics Projection #
-# --------------------------------------------------------------------------- #
-# Copyright (c) 2008-2010 Raoul Snyman #
-# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael #
-# Gorven, Scott Guerrieri, Meinert Jordan, Andreas Preikschat, Christian #
-# Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon Tibble, #
-# Carsten Tinggaard, Frode Woldsund #
-# --------------------------------------------------------------------------- #
-# 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 urllib2
-import logging
-import re
-import chardet
-import htmlentitydefs
-
-only_verses = re.compile(r'([\w .]+)[ ]+([0-9]+)[ ]*[:|v|V][ ]*([0-9]+)'
- r'(?:[ ]*-[ ]*([0-9]+|end))?(?:[ ]*,[ ]*([0-9]+)'
- r'(?:[ ]*-[ ]*([0-9]+|end))?)?',
- re.UNICODE)
-chapter_range = re.compile(r'([\w .]+)[ ]+([0-9]+)[ ]*[:|v|V][ ]*'
- r'([0-9]+|end)[ ]*-[ ]*([0-9]+)[ ]*[:|v|V][ ]*([0-9]+|end)',
- re.UNICODE)
-
-log = logging.getLogger(__name__)
-
-def parse_reference(reference):
- """
- This is the über-awesome function that takes a person's typed in string
- and converts it to a reference list, a list of references to be queried
- from the Bible database files.
-
- The reference list is a list of tuples, with each tuple structured like
- this::
-
- (book, chapter, start_verse, end_verse)
- """
- reference = reference.strip()
- log.debug('parse_reference("%s")', reference)
- reference_list = []
- # We start with the most "complicated" match first, so that they are found
- # first, and we don't have any "false positives".
- match = chapter_range.match(reference)
- if match:
- log.debug('Found a chapter range.')
- book = match.group(1)
- from_verse = match.group(3)
- to_verse = match.group(5)
- if int(match.group(2)) == int(match.group(4)):
- reference_list.append(
- (book, int(match.group(2)), from_verse, to_verse)
- )
- else:
- if int(match.group(2)) > int(match.group(4)):
- from_chapter = int(match.group(4))
- to_chapter = int(match.group(2))
- else:
- from_chapter = int(match.group(2))
- to_chapter = int(match.group(4))
- for chapter in xrange(from_chapter, to_chapter + 1):
- if chapter == from_chapter:
- reference_list.append((book, chapter, from_verse, -1))
- elif chapter == to_chapter:
- reference_list.append((book, chapter, 1, to_verse))
- else:
- reference_list.append((book, chapter, 1, -1))
- else:
- match = only_verses.match(reference)
- if match:
- log.debug('Found a verse range.')
- book = match.group(1)
- chapter = match.group(2)
- verse = match.group(3)
- if match.group(4) is None:
- reference_list.append((book, chapter, verse, verse))
- elif match.group(5) is None:
- end_verse = match.group(4)
- if end_verse == u'end':
- end_verse = -1
- reference_list.append((book, chapter, verse, end_verse))
- elif match.group(6) is None:
- reference_list.extend([
- (book, chapter, verse, match.group(4)),
- (book, chapter, match.group(5), match.group(5))
- ])
- else:
- end_verse = match.group(6)
- if end_verse == u'end':
- end_verse = -1
- reference_list.extend([
- (book, chapter, verse, match.group(4)),
- (book, chapter, match.group(5), end_verse)
- ])
- else:
- log.debug('Didn\'t find anything.')
- log.debug(reference_list)
- return reference_list
-
-class SearchResults(object):
- """
- Encapsulate a set of search results. This is Bible-type independant.
- """
- def __init__(self, book, chapter, verselist):
- """
- Create the search result object.
-
- ``book``
- The book of the Bible.
-
- ``chapter``
- The chapter of the book.
-
- ``verselist``
- The list of verses for this reading
- """
- self.book = book
- self.chapter = chapter
- self.verselist = verselist
-
- def has_verselist(self):
- """
- Returns whether or not the verse list contains verses.
- """
- return len(self.verselist) > 0
-
-
-class BibleCommon(object):
- """
- A common ancestor for bible download sites.
- """
- log.info(u'BibleCommon')
-
- def _get_web_text(self, urlstring, proxyurl):
- """
- Get the HTML from the web page.
-
- ``urlstring``
- The URL of the page to open.
-
- ``proxyurl``
- The URL of a proxy server used to access the Internet.
- """
- log.debug(u'get_web_text %s %s', proxyurl, urlstring)
- if proxyurl:
- proxy_support = urllib2.ProxyHandler({'http': self.proxyurl})
- http_support = urllib2.HTTPHandler()
- opener = urllib2.build_opener(proxy_support, http_support)
- urllib2.install_opener(opener)
- xml_string = u''
- req = urllib2.Request(urlstring)
- #Make us look like an IE Browser on XP to stop blocking by web site
- req.add_header(u'User-Agent',
- u'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)')
- try:
- handle = urllib2.urlopen(req)
- html = handle.read()
- details = chardet.detect(html)
- xml_string = unicode(html, details[u'encoding'])
- except IOError, e:
- if hasattr(e, u'reason'):
- log.exception(u'Reason for failure: %s', e.reason)
- return xml_string
-
- def _clean_text(self, text):
- """
- Clean up text and remove extra characters after been downloaded from
- the Internet.
-
- ``text``
- The text from the web page that needs to be cleaned up.
- """
- #return text.rstrip()
- # Remove Headings from the Text
- start_tag = text.find(u' -1:
- end_tag = text.find(u'')
- while start_tag > -1:
- end_tag = text.find(u'')
- text = text[:start_tag] + text[end_tag + 6:len(text)]
- start_tag = text.find(u'')
- start_tag = text.find(u'')
- while start_tag > -1:
- end_tag = text.find(u'')
- text = text[:start_tag] + text[end_tag + 6:len(text)]
- start_tag = text.find(u'')
- # Static Clean ups
- text = text.replace(u'\n', u'')
- text = text.replace(u'\r', u'')
- text = text.replace(u' ', u'')
- text = text.replace(u'', u'')
- text = text.replace(u'', u'')
- text = text.replace(u'', u'')
- text = text.replace(u'
', u'')
- text = text.replace(u'', u'')
- text = text.replace(u'
', u'')
- text = text.replace(u'
', u'')
- text = text.replace(u'
', u'')
- text = text.replace(u'"', u'\"')
- text = text.replace(u''', u'\'')
- # Remove some other tags
- start_tag = text.find(u'<')
- while start_tag > -1:
- end_tag = text.find(u'>', start_tag)
- text = text[:start_tag] + text[end_tag + 1:]
- start_tag = text.find(u'<')
- text = text.replace(u'>', u'')
- return text.rstrip().lstrip()
-
-
-def unescape(text):
- """
- Removes HTML or XML character references and entities from a text string.
- Courtesy of Fredrik Lundh, http://effbot.org/zone/re-sub.htm#unescape-html
-
- @param text The HTML (or XML) source text.
- @return The plain text, as a Unicode string, if necessary.
- """
- def fixup(markup):
- text = markup.group(0)
- if text.startswith(u''):
- # character reference
- try:
- if text.startswith(u''):
- return unichr(int(text[3:-1], 16))
- else:
- return unichr(int(text[2:-1]))
- except ValueError:
- pass
- else:
- # named entity
- try:
- text = unichr(htmlentitydefs.name2codepoint[text[1:-1]])
- except KeyError:
- pass
- return text # leave as is
- return re.sub(u'?\w+;', fixup, text)
diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py
index 971677fde..415a0cde5 100644
--- a/openlp/plugins/bibles/lib/http.py
+++ b/openlp/plugins/bibles/lib/http.py
@@ -36,7 +36,7 @@ from BeautifulSoup import BeautifulSoup, NavigableString
from openlp.core.lib import Receiver
from openlp.core.utils import AppLocation
-from openlp.plugins.bibles.lib.common import BibleCommon, SearchResults
+from openlp.plugins.bibles.lib import SearchResults
from openlp.plugins.bibles.lib.db import BibleDB, Book
log = logging.getLogger(__name__)
@@ -177,7 +177,7 @@ class HTTPBooks(object):
return 0
-class BGExtract(BibleCommon):
+class BGExtract(object):
"""
Extract verses from BibleGateway
"""
@@ -239,7 +239,8 @@ class BGExtract(BibleCommon):
found_count += 1
return SearchResults(bookname, chapter, verse_list)
-class CWExtract(BibleCommon):
+
+class CWExtract(object):
"""
Extract verses from CrossWalk/BibleStudyTools
"""
diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py
index 5c2767d0e..ebca8ca97 100644
--- a/openlp/plugins/bibles/lib/manager.py
+++ b/openlp/plugins/bibles/lib/manager.py
@@ -30,9 +30,9 @@ from PyQt4 import QtCore
from openlp.core.lib import SettingsManager
from openlp.core.utils import AppLocation
+from openlp.plugins.bibles.lib import parse_reference
from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta
-from common import parse_reference
from opensong import OpenSongBible
from osis import OSISBible
from csvbible import CSVBible
From 7729ba3ced6a2ab0b81187ae2435290dd5943cdb Mon Sep 17 00:00:00 2001
From: Jon Tibble
Date: Thu, 29 Jul 2010 16:04:09 +0100
Subject: [PATCH 7/9] Bible reference error message
---
openlp/plugins/bibles/lib/manager.py | 26 +++++++++++++++++++++++---
openlp/plugins/bibles/lib/mediaitem.py | 8 ++------
2 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py
index ebca8ca97..45c39f72b 100644
--- a/openlp/plugins/bibles/lib/manager.py
+++ b/openlp/plugins/bibles/lib/manager.py
@@ -26,9 +26,9 @@
import logging
-from PyQt4 import QtCore
+from PyQt4 import QtCore, QtGui
-from openlp.core.lib import SettingsManager
+from openlp.core.lib import SettingsManager, translate
from openlp.core.utils import AppLocation
from openlp.plugins.bibles.lib import parse_reference
from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta
@@ -229,13 +229,33 @@ class BibleManager(object):
``versetext``
Unicode. The scripture reference. Valid scripture references are:
+ - Genesis 1
+ - Genesis 1-2
- Genesis 1:1
- Genesis 1:1-10
+ - Genesis 1:1-10,15-20
- Genesis 1:1-2:10
+ - Genesis 1:1-10,2:1-10
"""
log.debug(u'BibleManager.get_verses("%s", "%s")', bible, versetext)
reflist = parse_reference(versetext)
- return self.db_cache[bible].get_verses(reflist)
+ if reflist:
+ return self.db_cache[bible].get_verses(reflist)
+ else:
+ QtGui.QMessageBox.information(self.parent.mediaitem,
+ translate('BiblesPlugin.BibleManager',
+ 'Scripture Reference Error'),
+ translate('BiblesPlugin.BibleManager', 'Your scripture '
+ 'reference is either not supported by OpenLP or invalid. '
+ 'Please make sure your reference conforms to one of the '
+ 'following patterns:\n\n'
+ 'Book Chapter\n'
+ 'Book Chapter-Chapter\n'
+ 'Book Chapter:Verse-Verse\n'
+ 'Book Chapter:Verse-Verse,Verse-Verse\n'
+ 'Book Chapter:Verse-Verse,Chapter:Verse-Verse\n'
+ 'Book Chapter:Verse-Chapter:Verse\n'))
+ return None
def save_meta_data(self, bible, version, copyright, permissions):
"""
diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py
index 5d6984231..bc9c6d1c5 100644
--- a/openlp/plugins/bibles/lib/mediaitem.py
+++ b/openlp/plugins/bibles/lib/mediaitem.py
@@ -431,8 +431,8 @@ class BibleMediaItem(MediaManagerItem):
chapter_to = int(self.AdvancedToChapter.currentText())
verse_from = int(self.AdvancedFromVerse.currentText())
verse_to = int(self.AdvancedToVerse.currentText())
- versetext = u'%s %s:%s-%s:%s' % (book, chapter_from, verse_from, \
- chapter_to, verse_to)
+ versetext = u'%s %s:%s-%s:%s' % (book, chapter_from, verse_from,
+ chapter_to, verse_to)
self.search_results = self.parent.manager.get_verses(bible, versetext)
if self.ClearAdvancedSearchComboBox.currentIndex() == 0:
self.listView.clear()
@@ -656,7 +656,3 @@ class BibleMediaItem(MediaManagerItem):
row = self.listView.setCurrentRow(count)
if row:
row.setSelected(True)
-
- def searchByReference(self, bible, search):
- log.debug(u'searchByReference %s, %s', bible, search)
- self.search_results = self.parent.manager.get_verses(bible, search)
From 26bae2e35bfe9ac32981106809a351a8a9ccfd3c Mon Sep 17 00:00:00 2001
From: Jon Tibble
Date: Thu, 29 Jul 2010 16:10:40 +0100
Subject: [PATCH 8/9] Fix message parenting
---
openlp/plugins/bibles/lib/manager.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py
index 45c39f72b..a0734aa98 100644
--- a/openlp/plugins/bibles/lib/manager.py
+++ b/openlp/plugins/bibles/lib/manager.py
@@ -242,7 +242,7 @@ class BibleManager(object):
if reflist:
return self.db_cache[bible].get_verses(reflist)
else:
- QtGui.QMessageBox.information(self.parent.mediaitem,
+ QtGui.QMessageBox.information(self.parent.mediaItem,
translate('BiblesPlugin.BibleManager',
'Scripture Reference Error'),
translate('BiblesPlugin.BibleManager', 'Your scripture '
From 9df8cb11f9c0be8e6e1106b3117bfa8c4428e23e Mon Sep 17 00:00:00 2001
From: Jon Tibble
Date: Fri, 30 Jul 2010 13:04:15 +0100
Subject: [PATCH 9/9] Fix doc text location
---
openlp/plugins/bibles/lib/__init__.py | 31 ++++++++++++---------------
1 file changed, 14 insertions(+), 17 deletions(-)
diff --git a/openlp/plugins/bibles/lib/__init__.py b/openlp/plugins/bibles/lib/__init__.py
index fbb292db5..284a10c44 100644
--- a/openlp/plugins/bibles/lib/__init__.py
+++ b/openlp/plugins/bibles/lib/__init__.py
@@ -32,23 +32,6 @@ import re
log = logging.getLogger(__name__)
-###############################################################################
-# BIBLE_REFERENCE regular expression produces the following match groups:
-#
-# 0 This is a special group consisting of the whole string that matched.
-# 1 [\w ]+ The book the reference is from.
-# 2 [0-9]+ The first (possibly only) chapter in the reference.
-# 3 None|[0-9]+ None or the only verse or the first verse in a
-# verse range or the start verse in a chapter range.
-# 4 None|[0-9]+|end None or the end verse of the first verse range or
-# the end chapter of a chapter range.
-# 5 None|[0-9]+ None or the second chapter in multiple (non-ranged)
-# chapters.
-# 6 None|[0-9]+|end None, the start of the second verse range or the
-# end of a chapter range.
-# 7 None|[0-9]+|end None or the end of the second verse range.
-###############################################################################
-
BIBLE_REFERENCE = re.compile(
r'^([\w ]+?) *([0-9]+)' # Initial book and chapter
r'(?: *[:|v|V] *([0-9]+))?' # Verse for first chapter
@@ -77,6 +60,20 @@ def parse_reference(reference):
and converts it to a reference list, a list of references to be queried
from the Bible database files.
+ BIBLE_REFERENCE regular expression produces the following match groups:
+ 0 This is a special group consisting of the whole string that matched.
+ 1 [\w ]+ The book the reference is from.
+ 2 [0-9]+ The first (or only) chapter in the reference.
+ 3 None|[0-9]+ None or the only verse or the first verse in a
+ verse range or the start verse in a chapter range.
+ 4 None|[0-9]+|end None or the end verse of the first verse range or
+ the end chapter of a chapter range.
+ 5 None|[0-9]+ None or the second chapter in multiple
+ (non-ranged) chapters.
+ 6 None|[0-9]+|end None, the start of the second verse range or the
+ end of a chapter range.
+ 7 None|[0-9]+|end None or the end of the second verse range.
+
The reference list is a list of tuples, with each tuple structured like
this::
(book, chapter, start_verse, end_verse)