openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #15379
[Merge] lp:~raoul-snyman/openlp/refactoring into lp:openlp
Raoul Snyman has proposed merging lp:~raoul-snyman/openlp/refactoring into lp:openlp.
Requested reviews:
Tim Bentley (trb143)
Andreas Preikschat (googol)
For more details, see:
https://code.launchpad.net/~raoul-snyman/openlp/refactoring/+merge/103159
A bunch of refactoring, including more sensible naming conventions.
--
https://code.launchpad.net/~raoul-snyman/openlp/refactoring/+merge/103159
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/lib/__init__.py'
--- openlp/core/lib/__init__.py 2012-04-12 14:16:12 +0000
+++ openlp/core/lib/__init__.py 2012-04-23 19:30:30 +0000
@@ -62,6 +62,7 @@
PreviousLastSlide = 2
Next = 3
+
def translate(context, text, comment=None,
encoding=QtCore.QCoreApplication.CodecForTr, n=-1,
translate=QtCore.QCoreApplication.translate):
@@ -83,6 +84,7 @@
"""
return translate(context, text, comment, encoding, n)
+
def get_text_file_string(text_file):
"""
Open a file and return its content as unicode string. If the supplied file
@@ -111,6 +113,7 @@
file_handle.close()
return content_string
+
def str_to_bool(stringvalue):
"""
Convert a string version of a boolean into a real boolean.
@@ -122,6 +125,7 @@
return stringvalue
return unicode(stringvalue).strip().lower() in (u'true', u'yes', u'y')
+
def build_icon(icon):
"""
Build a QIcon instance from an existing QIcon, a resource location, or a
@@ -148,6 +152,7 @@
QtGui.QIcon.Normal, QtGui.QIcon.Off)
return button_icon
+
def image_to_byte(image):
"""
Resize an image to fit on the current screen for the web and returns
@@ -166,6 +171,7 @@
# convert to base64 encoding so does not get missed!
return byte_array.toBase64()
+
def create_thumb(image_path, thumb_path, return_icon=True, size=None):
"""
Create a thumbnail from the given image path and depending on
@@ -201,6 +207,7 @@
# Fallback for files with animation support.
return build_icon(unicode(image_path))
+
def validate_thumb(file_path, thumb_path):
"""
Validates whether an file's thumb still exists and if is up to date.
@@ -219,6 +226,7 @@
thumb_date = os.stat(thumb_path).st_mtime
return image_date <= thumb_date
+
def resize_image(image_path, width, height, background=u'#000000'):
"""
Resize an image to fit on the current screen.
@@ -266,6 +274,7 @@
painter.drawImage((width - realw) / 2, (height - realh) / 2, preview)
return new_image
+
def check_item_selected(list_widget, message):
"""
Check if a list item is selected so an action may be performed on it
@@ -282,6 +291,7 @@
return False
return True
+
def clean_tags(text):
"""
Remove Tags from text for display
@@ -294,6 +304,7 @@
text = text.replace(tag[u'end tag'], u'')
return text
+
def expand_tags(text):
"""
Expand tags HTML for display
@@ -303,6 +314,7 @@
text = text.replace(tag[u'end tag'], tag[u'end html'])
return text
+
def check_directory_exists(dir):
"""
Check a theme directory exists and if not create it
@@ -317,6 +329,7 @@
except IOError:
pass
+
def create_separated_list(stringlist):
"""
Returns a string that represents a join of a list of strings with a
@@ -345,6 +358,7 @@
return unicode(translate('OpenLP.core.lib', '%1, %2',
u'Locale list separator: start').arg(stringlist[0], merged))
+
from eventreceiver import Receiver
from listwidgetwithdnd import ListWidgetWithDnD
from formattingtags import FormattingTags
=== modified file 'openlp/core/lib/mediamanageritem.py'
--- openlp/core/lib/mediamanageritem.py 2012-04-02 00:19:16 +0000
+++ openlp/core/lib/mediamanageritem.py 2012-04-23 19:30:30 +0000
@@ -582,7 +582,7 @@
Common method for generating a service item
"""
serviceItem = ServiceItem(self.plugin)
- serviceItem.add_icon(self.plugin.icon_path)
+ serviceItem.add_icon(self.plugin.iconPath)
if self.generateSlideData(serviceItem, item, xmlVersion, remote):
return serviceItem
else:
=== modified file 'openlp/core/lib/plugin.py'
--- openlp/core/lib/plugin.py 2012-03-17 10:54:33 +0000
+++ openlp/core/lib/plugin.py 2012-04-23 19:30:30 +0000
@@ -155,9 +155,9 @@
self.version = get_application_version()[u'version']
self.settingsSection = self.name
self.icon = None
- self.media_item_class = media_item_class
- self.settings_tab_class = settings_tab_class
- self.settings_tab = None
+ self.mediaItemClass = media_item_class
+ self.settingsTabClass = settings_tab_class
+ self.settingsTab = None
self.mediaItem = None
self.weight = 0
self.status = PluginStatus.Inactive
@@ -166,9 +166,9 @@
self.renderer = plugin_helpers[u'renderer']
self.serviceManager = plugin_helpers[u'service']
self.settingsForm = plugin_helpers[u'settings form']
- self.mediadock = plugin_helpers[u'toolbox']
+ self.mediaDock = plugin_helpers[u'toolbox']
self.pluginManager = plugin_helpers[u'pluginmanager']
- self.formparent = plugin_helpers[u'formparent']
+ self.formParent = plugin_helpers[u'formparent']
self.mediaController = plugin_helpers[u'mediacontroller']
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'%s_add_service_item' % self.name),
@@ -219,8 +219,8 @@
Construct a MediaManagerItem object with all the buttons and things
you need, and return it for integration into OpenLP.
"""
- if self.media_item_class:
- self.mediaItem = self.media_item_class(self.mediadock.media_dock,
+ if self.mediaItemClass:
+ self.mediaItem = self.mediaItemClass(self.mediaDock.media_dock,
self, self.icon)
def addImportMenuItem(self, importMenu):
@@ -255,10 +255,10 @@
Create a tab for the settings window to display the configurable options
for this plugin to the user.
"""
- if self.settings_tab_class:
- self.settings_tab = self.settings_tab_class(parent, self.name,
+ if self.settingsTabClass:
+ self.settingsTab = self.settingsTabClass(parent, self.name,
self.getString(StringContent.VisibleName)[u'title'],
- self.icon_path)
+ self.iconPath)
def addToMenu(self, menubar):
"""
@@ -294,14 +294,14 @@
"""
if self.mediaItem:
self.mediaItem.initialise()
- self.mediadock.insert_dock(self.mediaItem, self.icon, self.weight)
+ self.mediaDock.insert_dock(self.mediaItem, self.icon, self.weight)
def finalise(self):
"""
Called by the plugin Manager to cleanup things.
"""
if self.mediaItem:
- self.mediadock.remove_dock(self.mediaItem)
+ self.mediaDock.remove_dock(self.mediaItem)
def appStartup(self):
"""
=== modified file 'openlp/core/lib/settingstab.py'
--- openlp/core/lib/settingstab.py 2012-04-02 00:19:16 +0000
+++ openlp/core/lib/settingstab.py 2012-04-23 19:30:30 +0000
@@ -47,7 +47,7 @@
self.tabTitleVisible = visible_title
self.settingsSection = self.tabTitle.lower()
if icon_path:
- self.icon_path = icon_path
+ self.iconPath = icon_path
self.setupUi()
self.retranslateUi()
self.initialise()
=== modified file 'openlp/core/lib/ui.py'
--- openlp/core/lib/ui.py 2012-04-13 20:08:05 +0000
+++ openlp/core/lib/ui.py 2012-04-23 19:30:30 +0000
@@ -143,6 +143,7 @@
self.View = translate('OpenLP.Ui', 'View')
self.ViewMode = translate('OpenLP.Ui', 'View Mode')
+
def add_welcome_page(parent, image):
"""
Generate an opening welcome page for a wizard using a provided image.
@@ -170,6 +171,7 @@
parent.welcomeLayout.addStretch()
parent.addPage(parent.welcomePage)
+
def create_button_box(dialog, name, standard_buttons, custom_buttons=[]):
"""
Creates a QDialogButtonBox with the given buttons. The ``accepted()`` and
@@ -216,6 +218,7 @@
dialog.reject)
return button_box
+
def critical_error_message_box(title=None, message=None, parent=None,
question=False):
"""
@@ -242,6 +245,7 @@
data[u'title'] = title if title else UiStrings().Error
return Receiver.send_message(u'openlp_error_message', data)
+
def create_horizontal_adjusting_combo_box(parent, name):
"""
Creates a QComboBox with adapting width for media items.
@@ -258,6 +262,7 @@
combo.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
return combo
+
def create_button(parent, name, **kwargs):
"""
Return an button with the object name set and the given parameters.
@@ -324,6 +329,7 @@
log.warn(u'Parameter %s was not consumed in create_button().', key)
return button
+
def create_action(parent, name, **kwargs):
"""
Return an action with the object name set and the given parameters.
@@ -411,6 +417,7 @@
log.warn(u'Parameter %s was not consumed in create_action().', key)
return action
+
def create_widget_action(parent, name=u'', **kwargs):
"""
Return a new QAction by calling ``create_action(parent, name, **kwargs)``.
@@ -422,6 +429,7 @@
parent.addAction(action)
return action
+
def set_case_insensitive_completer(cache, widget):
"""
Sets a case insensitive text completer for a widget.
@@ -436,6 +444,7 @@
completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive)
widget.setCompleter(completer)
+
def create_valign_selection_widgets(parent):
"""
Creates a standard label and combo box for asking users to select a
@@ -455,6 +464,7 @@
label.setBuddy(combo_box)
return label, combo_box
+
def find_and_set_in_combo_box(combo_box, value_to_find):
"""
Find a string in a combo box and set it as the selected item if present
=== modified file 'openlp/core/ui/advancedtab.py'
--- openlp/core/ui/advancedtab.py 2012-04-03 17:59:34 +0000
+++ openlp/core/ui/advancedtab.py 2012-04-23 19:30:30 +0000
@@ -59,7 +59,7 @@
'#strftime-strptime-behavior for more information.'))
self.defaultImage = u':/graphics/openlp-splash-screen.png'
self.defaultColor = u'#ffffff'
- self.icon_path = u':/system/system_settings.png'
+ self.iconPath = u':/system/system_settings.png'
advanced_translated = translate('OpenLP.AdvancedTab', 'Advanced')
SettingsTab.__init__(self, parent, u'Advanced', advanced_translated)
=== modified file 'openlp/core/ui/generaltab.py'
--- openlp/core/ui/generaltab.py 2012-04-09 10:01:06 +0000
+++ openlp/core/ui/generaltab.py 2012-04-23 19:30:30 +0000
@@ -43,7 +43,7 @@
Initialise the general settings tab
"""
self.screens = ScreenList.get_instance()
- self.icon_path = u':/icon/openlp-logo-16x16.png'
+ self.iconPath = u':/icon/openlp-logo-16x16.png'
generalTranslated = translate('OpenLP.GeneralTab', 'General')
SettingsTab.__init__(self, parent, u'General', generalTranslated)
=== modified file 'openlp/core/ui/mainwindow.py'
--- openlp/core/ui/mainwindow.py 2012-04-04 07:26:51 +0000
+++ openlp/core/ui/mainwindow.py 2012-04-23 19:30:30 +0000
@@ -554,9 +554,9 @@
# (not for use by plugins)
self.uiSettingsSection = u'user interface'
self.generalSettingsSection = u'general'
- self.advancedlSettingsSection = u'advanced'
+ self.advancedSettingsSection = u'advanced'
self.shortcutsSettingsSection = u'shortcuts'
- self.servicemanagerSettingsSection = u'servicemanager'
+ self.serviceManagerSettingsSection = u'servicemanager'
self.songsSettingsSection = u'songs'
self.themesSettingsSection = u'themes'
self.displayTagsSection = u'displayTags'
@@ -568,8 +568,8 @@
self.shortcutForm = ShortcutListForm(self)
self.recentFiles = QtCore.QStringList()
# Set up the path with plugins
- pluginpath = AppLocation.get_directory(AppLocation.PluginsDir)
- self.pluginManager = PluginManager(pluginpath)
+ plugin_path = AppLocation.get_directory(AppLocation.PluginsDir)
+ self.pluginManager = PluginManager(plugin_path)
self.pluginHelpers = {}
self.imageManager = ImageManager()
self.mediaController = MediaController(self)
@@ -661,7 +661,7 @@
self.pluginHelpers[u'pluginmanager'] = self.pluginManager
self.pluginHelpers[u'formparent'] = self
self.pluginHelpers[u'mediacontroller'] = self.mediaController
- self.pluginManager.find_plugins(pluginpath, self.pluginHelpers)
+ self.pluginManager.find_plugins(plugin_path, self.pluginHelpers)
# hook methods have to happen after find_plugins. Find plugins needs
# the controllers hence the hooks have moved from setupUI() to here
# Find and insert settings tabs
@@ -944,10 +944,10 @@
setting_sections = []
# Add main sections.
setting_sections.extend([self.generalSettingsSection])
- setting_sections.extend([self.advancedlSettingsSection])
+ setting_sections.extend([self.advancedSettingsSection])
setting_sections.extend([self.uiSettingsSection])
setting_sections.extend([self.shortcutsSettingsSection])
- setting_sections.extend([self.servicemanagerSettingsSection])
+ setting_sections.extend([self.serviceManagerSettingsSection])
setting_sections.extend([self.themesSettingsSection])
setting_sections.extend([self.displayTagsSection])
setting_sections.extend([self.headerSection])
@@ -1027,10 +1027,10 @@
setting_sections = []
# Add main sections.
setting_sections.extend([self.generalSettingsSection])
- setting_sections.extend([self.advancedlSettingsSection])
+ setting_sections.extend([self.advancedSettingsSection])
setting_sections.extend([self.uiSettingsSection])
setting_sections.extend([self.shortcutsSettingsSection])
- setting_sections.extend([self.servicemanagerSettingsSection])
+ setting_sections.extend([self.serviceManagerSettingsSection])
setting_sections.extend([self.themesSettingsSection])
setting_sections.extend([self.displayTagsSection])
# Add plugin sections.
@@ -1314,10 +1314,10 @@
u'/enable slide loop'):
if QtCore.QSettings().value(self.generalSettingsSection +
u'/enable slide loop', QtCore.QVariant(True)).toBool():
- QtCore.QSettings().setValue(self.advancedlSettingsSection +
+ QtCore.QSettings().setValue(self.advancedSettingsSection +
u'/slide limits', QtCore.QVariant(SlideLimits.Wrap))
else:
- QtCore.QSettings().setValue(self.advancedlSettingsSection +
+ QtCore.QSettings().setValue(self.advancedSettingsSection +
u'/slide limits', QtCore.QVariant(SlideLimits.End))
QtCore.QSettings().remove(self.generalSettingsSection +
u'/enable slide loop')
=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py 2012-04-10 19:39:20 +0000
+++ openlp/core/ui/servicemanager.py 2012-04-23 19:30:30 +0000
@@ -272,7 +272,7 @@
QtCore.SIGNAL(u'service_item_update'), self.serviceItemUpdate)
# Last little bits of setting up
self.service_theme = unicode(QtCore.QSettings().value(
- self.mainwindow.servicemanagerSettingsSection + u'/service theme',
+ self.mainwindow.serviceManagerSettingsSection + u'/service theme',
QtCore.QVariant(u'')).toString())
self.servicePath = AppLocation.get_section_data_path(u'servicemanager')
# build the drag and drop context menu
@@ -411,7 +411,7 @@
self.mainwindow,
translate('OpenLP.ServiceManager', 'Open File'),
SettingsManager.get_last_dir(
- self.mainwindow.servicemanagerSettingsSection),
+ self.mainwindow.serviceManagerSettingsSection),
translate('OpenLP.ServiceManager',
'OpenLP Service Files (*.osz)')))
if not fileName:
@@ -419,7 +419,7 @@
else:
fileName = loadFile
SettingsManager.set_last_dir(
- self.mainwindow.servicemanagerSettingsSection,
+ self.mainwindow.serviceManagerSettingsSection,
split_filename(fileName)[0])
self.loadFile(fileName)
@@ -469,7 +469,7 @@
service_file_name = '%s.osd' % basename
log.debug(u'ServiceManager.saveFile - %s', path_file_name)
SettingsManager.set_last_dir(
- self.mainwindow.servicemanagerSettingsSection,
+ self.mainwindow.serviceManagerSettingsSection,
path)
service = []
write_list = []
@@ -622,7 +622,7 @@
else:
default_filename = u''
directory = unicode(SettingsManager.get_last_dir(
- self.mainwindow.servicemanagerSettingsSection))
+ self.mainwindow.serviceManagerSettingsSection))
path = os.path.join(directory, default_filename)
fileName = unicode(QtGui.QFileDialog.getSaveFileName(self.mainwindow,
UiStrings().SaveService, path,
@@ -1107,7 +1107,7 @@
self.service_theme = unicode(self.themeComboBox.currentText())
self.mainwindow.renderer.set_service_theme(self.service_theme)
QtCore.QSettings().setValue(
- self.mainwindow.servicemanagerSettingsSection +
+ self.mainwindow.serviceManagerSettingsSection +
u'/service theme',
QtCore.QVariant(self.service_theme))
self.regenerateServiceItems(True)
=== modified file 'openlp/core/ui/settingsform.py'
--- openlp/core/ui/settingsform.py 2012-03-12 22:12:16 +0000
+++ openlp/core/ui/settingsform.py 2012-04-23 19:30:30 +0000
@@ -65,8 +65,8 @@
self.insertTab(self.advancedTab, 2, PluginStatus.Active)
count = 3
for plugin in self.plugins:
- if plugin.settings_tab:
- self.insertTab(plugin.settings_tab, count, plugin.status)
+ if plugin.settingsTab:
+ self.insertTab(plugin.settingsTab, count, plugin.status)
count += 1
self.settingListWidget.setCurrentRow(0)
return QtGui.QDialog.exec_(self)
@@ -80,7 +80,7 @@
pos = self.stackedLayout.addWidget(tab)
if is_active:
item_name = QtGui.QListWidgetItem(tab.tabTitleVisible)
- icon = build_icon(tab.icon_path)
+ icon = build_icon(tab.iconPath)
item_name.setIcon(icon)
self.settingListWidget.insertItem(location, item_name)
else:
@@ -114,8 +114,8 @@
self.themesTab.postSetUp()
self.advancedTab.postSetUp()
for plugin in self.plugins:
- if plugin.settings_tab:
- plugin.settings_tab.postSetUp()
+ if plugin.settingsTab:
+ plugin.settingsTab.postSetUp()
def tabChanged(self, tabIndex):
"""
=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py 2012-04-02 21:00:24 +0000
+++ openlp/core/ui/slidecontroller.py 2012-04-23 19:30:30 +0000
@@ -648,8 +648,8 @@
def onSongBarHandler(self):
request = unicode(self.sender().text())
- slideno = self.slideList[request]
- self.__updatePreviewSelection(slideno)
+ slide_no = self.slideList[request]
+ self.__updatePreviewSelection(slide_no)
self.slideSelected()
def receiveSpinDelay(self, value):
@@ -663,7 +663,7 @@
Updates the Slide Limits variable from the settings.
"""
self.slide_limits = QtCore.QSettings().value(
- self.parent().advancedlSettingsSection + u'/slide limits',
+ self.parent().advancedSettingsSection + u'/slide limits',
QtCore.QVariant(SlideLimits.End)).toInt()[0]
def enableToolBar(self, item):
=== modified file 'openlp/core/ui/themestab.py'
--- openlp/core/ui/themestab.py 2012-04-03 17:59:34 +0000
+++ openlp/core/ui/themestab.py 2012-04-23 19:30:30 +0000
@@ -39,7 +39,7 @@
self.mainwindow = mainwindow
generalTranslated = translate('OpenLP.ThemesTab', 'Themes')
SettingsTab.__init__(self, parent, u'Themes', generalTranslated)
- self.icon_path = u':/themes/theme_new.png'
+ self.iconPath = u':/themes/theme_new.png'
def setupUi(self):
self.setObjectName(u'ThemesTab')
=== modified file 'openlp/plugins/alerts/alertsplugin.py'
--- openlp/plugins/alerts/alertsplugin.py 2012-03-04 14:52:09 +0000
+++ openlp/plugins/alerts/alertsplugin.py 2012-04-23 19:30:30 +0000
@@ -117,8 +117,8 @@
Plugin.__init__(self, u'alerts', plugin_helpers,
settings_tab_class=AlertsTab)
self.weight = -3
- self.icon_path = u':/plugins/plugin_alerts.png'
- self.icon = build_icon(self.icon_path)
+ self.iconPath = u':/plugins/plugin_alerts.png'
+ self.icon = build_icon(self.iconPath)
self.alertsmanager = AlertsManager(self)
self.manager = Manager(u'alerts', init_schema)
self.alertForm = AlertForm(self)
@@ -197,10 +197,10 @@
"""
Add CSS to the main display.
"""
- align = VerticalType.Names[self.settings_tab.location]
- return CSS % (align, self.settings_tab.font_face,
- self.settings_tab.font_size, self.settings_tab.font_color,
- self.settings_tab.bg_color)
+ align = VerticalType.Names[self.settingsTab.location]
+ return CSS % (align, self.settingsTab.font_face,
+ self.settingsTab.font_size, self.settingsTab.font_color,
+ self.settingsTab.bg_color)
def getDisplayHtml(self):
"""
@@ -215,7 +215,7 @@
``frame``
The Web frame holding the page.
"""
- align = VerticalType.Names[self.settings_tab.location]
+ align = VerticalType.Names[self.settingsTab.location]
frame.evaluateJavaScript(u'update_css("%s", "%s", "%s", "%s", "%s")' %
- (align, self.settings_tab.font_face, self.settings_tab.font_size,
- self.settings_tab.font_color, self.settings_tab.bg_color))
+ (align, self.settingsTab.font_face, self.settingsTab.font_size,
+ self.settingsTab.font_color, self.settingsTab.bg_color))
=== modified file 'openlp/plugins/alerts/forms/alertform.py'
--- openlp/plugins/alerts/forms/alertform.py 2011-12-27 10:33:55 +0000
+++ openlp/plugins/alerts/forms/alertform.py 2012-04-23 19:30:30 +0000
@@ -43,7 +43,7 @@
self.manager = plugin.manager
self.plugin = plugin
self.item_id = None
- QtGui.QDialog.__init__(self, plugin.formparent)
+ QtGui.QDialog.__init__(self, plugin.formParent)
self.setupUi(self)
QtCore.QObject.connect(self.displayButton,
QtCore.SIGNAL(u'clicked()'), self.onDisplayClicked)
=== modified file 'openlp/plugins/alerts/lib/alertsmanager.py'
--- openlp/plugins/alerts/lib/alertsmanager.py 2011-12-27 10:33:55 +0000
+++ openlp/plugins/alerts/lib/alertsmanager.py 2012-04-23 19:30:30 +0000
@@ -84,7 +84,7 @@
if not self.alertList:
return
text = self.alertList.pop(0)
- alertTab = self.parent().settings_tab
+ alertTab = self.parent().settingsTab
self.parent().liveController.display.alert(text, alertTab.location)
# Check to see if we have a timer running.
if self.timer_id == 0:
@@ -100,7 +100,7 @@
"""
log.debug(u'timer event')
if event.timerId() == self.timer_id:
- alertTab = self.parent().settings_tab
+ alertTab = self.parent().settingsTab
self.parent().liveController.display.alert(u'', alertTab.location)
self.killTimer(self.timer_id)
self.timer_id = 0
=== modified file 'openlp/plugins/bibles/bibleplugin.py'
--- openlp/plugins/bibles/bibleplugin.py 2012-04-16 07:02:24 +0000
+++ openlp/plugins/bibles/bibleplugin.py 2012-04-23 19:30:30 +0000
@@ -27,7 +27,7 @@
import logging
-from PyQt4 import QtGui
+from PyQt4 import QtCore, QtGui
from openlp.core.lib import Plugin, StringContent, build_icon, translate
from openlp.core.lib.ui import create_action, UiStrings
@@ -44,8 +44,8 @@
Plugin.__init__(self, u'bibles', plugin_helpers,
BibleMediaItem, BiblesTab)
self.weight = -9
- self.icon_path = u':/plugins/plugin_bibles.png'
- self.icon = build_icon(self.icon_path)
+ self.iconPath = u':/plugins/plugin_bibles.png'
+ self.icon = build_icon(self.iconPath)
self.manager = None
def initialise(self):
@@ -81,16 +81,23 @@
def appStartup(self):
"""
- Perform tasks on application starup
+ Perform tasks on application startup
"""
if len(self.manager.old_bible_databases):
- if QtGui.QMessageBox.information(self.formparent,
+ if QtGui.QMessageBox.information(self.formParent,
translate('OpenLP', 'Information'), translate('OpenLP',
'Bible format has changed.\nYou have to upgrade your '
'existing Bibles.\nShould OpenLP upgrade now?'),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes |
QtGui.QMessageBox.No)) == QtGui.QMessageBox.Yes:
self.onToolsUpgradeItemTriggered()
+ settings = QtCore.QSettings()
+ settings.beginGroup(self.settingsSection)
+ if settings.contains(u'bookname language'):
+ settings.setValue(u'book name language', settings.value(
+ u'bookname language', QtCore.QVariant(0)).toInt()[0])
+ settings.remove(u'bookname language')
+ settings.endGroup()
def addImportMenuItem(self, import_menu):
self.importBibleItem = create_action(import_menu, u'importBibleItem',
@@ -126,7 +133,7 @@
Upgrade older bible databases.
"""
if not hasattr(self, u'upgrade_wizard'):
- self.upgrade_wizard = BibleUpgradeForm(self.formparent,
+ self.upgrade_wizard = BibleUpgradeForm(self.formParent,
self.manager, self)
# If the import was not cancelled then reload.
if self.upgrade_wizard.exec_():
@@ -148,7 +155,7 @@
Returns ``True`` if the theme is being used, otherwise returns
``False``.
"""
- return unicode(self.settings_tab.bible_theme) == theme
+ return unicode(self.settingsTab.bible_theme) == theme
def renameTheme(self, oldTheme, newTheme):
"""
@@ -162,8 +169,8 @@
``newTheme``
The new name the plugin should now use.
"""
- self.settings_tab.bible_theme = newTheme
- self.settings_tab.save()
+ self.settingsTab.bible_theme = newTheme
+ self.settingsTab.save()
def setPluginTextStrings(self):
"""
=== modified file 'openlp/plugins/bibles/forms/bibleupgradeform.py'
--- openlp/plugins/bibles/forms/bibleupgradeform.py 2012-03-21 20:57:07 +0000
+++ openlp/plugins/bibles/forms/bibleupgradeform.py 2012-04-23 19:30:30 +0000
@@ -371,7 +371,7 @@
"""
Perform the actual upgrade.
"""
- self.include_webbible = False
+ self.includeWebBible = False
proxy_server = None
if not self.files:
self.progressLabel.setText(
@@ -383,14 +383,14 @@
for number, file in enumerate(self.files):
if self.checkBox[number].checkState() == QtCore.Qt.Checked:
max_bibles += 1
- oldBible = None
+ old_bible = None
for number, filename in enumerate(self.files):
# Close the previous bible's connection.
- if oldBible is not None:
- oldBible.close_connection()
+ if old_bible is not None:
+ old_bible.close_connection()
# Set to None to make obvious that we have already closed the
# database.
- oldBible = None
+ old_bible = None
if self.stop_import_flag:
self.success[number] = False
break
@@ -398,7 +398,7 @@
self.success[number] = False
continue
self.progressBar.reset()
- oldBible = OldBibleDB(self.mediaItem, path=self.temp_dir,
+ old_bible = OldBibleDB(self.mediaItem, path=self.temp_dir,
file=filename[0])
name = filename[1]
self.progressLabel.setText(unicode(translate(
@@ -408,33 +408,39 @@
self.newbibles[number] = BibleDB(self.mediaItem, path=self.path,
name=name, file=filename[0])
self.newbibles[number].register(self.plugin.upgrade_wizard)
- metadata = oldBible.get_metadata()
- webbible = False
+ metadata = old_bible.get_metadata()
+ web_bible = False
meta_data = {}
for meta in metadata:
+ # Upgrade the names of the metadata keys
+ if meta[u'key'] == u'Version':
+ meta[u'key'] = u'name'
+ if meta[u'key'] == u'Bookname language':
+ meta[u'key'] = 'book_name_language'
+ meta[u'key'] = meta[u'key'].lower().replace(' ', '_')
+ # Copy the metadata
meta_data[meta[u'key']] = meta[u'value']
- if not meta[u'key'] == u'Version' and not meta[u'key'] == \
- u'dbversion':
+ if meta[u'key'] != u'name' and meta[u'key'] != u'dbversion':
self.newbibles[number].save_meta(meta[u'key'],
meta[u'value'])
- if meta[u'key'] == u'download source':
- webbible = True
- self.include_webbible = True
- if meta.has_key(u'proxy server'):
- proxy_server = meta[u'proxy server']
- if webbible:
- if meta_data[u'download source'].lower() == u'crosswalk':
+ if meta[u'key'] == u'download_source':
+ web_bible = True
+ self.includeWebBible = True
+ if meta.has_key(u'proxy_server'):
+ proxy_server = meta[u'proxy_server']
+ if web_bible:
+ if meta_data[u'download_source'].lower() == u'crosswalk':
handler = CWExtract(proxy_server)
- elif meta_data[u'download source'].lower() == u'biblegateway':
+ elif meta_data[u'download_source'].lower() == u'biblegateway':
handler = BGExtract(proxy_server)
- elif meta_data[u'download source'].lower() == u'bibleserver':
+ elif meta_data[u'download_source'].lower() == u'bibleserver':
handler = BSExtract(proxy_server)
- books = handler.get_books_from_http(meta_data[u'download name'])
+ books = handler.get_books_from_http(meta_data[u'download_name'])
if not books:
log.error(u'Upgrading books from %s - download '\
u'name: "%s" failed' % (
- meta_data[u'download source'],
- meta_data[u'download name']))
+ meta_data[u'download_source'],
+ meta_data[u'download_name']))
self.newbibles[number].session.close()
del self.newbibles[number]
critical_error_message_box(
@@ -451,8 +457,8 @@
self.success[number] = False
continue
bible = BiblesResourcesDB.get_webbible(
- meta_data[u'download name'],
- meta_data[u'download source'].lower())
+ meta_data[u'download_name'],
+ meta_data[u'download_source'].lower())
if bible and bible[u'language_id']:
language_id = bible[u'language_id']
self.newbibles[number].save_meta(u'language_id',
@@ -485,8 +491,8 @@
if not book_ref_id:
log.warn(u'Upgrading books from %s - download '\
u'name: "%s" aborted by user' % (
- meta_data[u'download source'],
- meta_data[u'download name']))
+ meta_data[u'download_source'],
+ meta_data[u'download_name']))
self.newbibles[number].session.close()
del self.newbibles[number]
self.success[number] = False
@@ -495,9 +501,9 @@
db_book = self.newbibles[number].create_book(book,
book_ref_id, book_details[u'testament_id'])
# Try to import already downloaded verses.
- oldbook = oldBible.get_book(book)
+ oldbook = old_bible.get_book(book)
if oldbook:
- verses = oldBible.get_verses(oldbook[u'id'])
+ verses = old_bible.get_verses(oldbook[u'id'])
if not verses:
log.warn(u'No verses found to import for book '
u'"%s"', book)
@@ -527,7 +533,7 @@
self.progressBar.maximum() - self.progressBar.value())
self.success[number] = False
continue
- books = oldBible.get_books()
+ books = old_bible.get_books()
self.progressBar.setMaximum(len(books))
for book in books:
if self.stop_import_flag:
@@ -551,7 +557,7 @@
book_details = BiblesResourcesDB.get_book_by_id(book_ref_id)
db_book = self.newbibles[number].create_book(book[u'name'],
book_ref_id, book_details[u'testament_id'])
- verses = oldBible.get_verses(book[u'id'])
+ verses = old_bible.get_verses(book[u'id'])
if not verses:
log.warn(u'No verses found to import for book '
u'"%s"', book[u'name'])
@@ -574,7 +580,7 @@
self.progressBar.maximum() - self.progressBar.value())
else:
self.success[number] = True
- self.newbibles[number].save_meta(u'Version', name)
+ self.newbibles[number].save_meta(u'name', name)
self.incrementProgressBar(unicode(translate(
'BiblesPlugin.UpgradeWizardForm',
'Upgrading Bible %s of %s: "%s"\n'
@@ -583,8 +589,8 @@
if self.newbibles.has_key(number):
self.newbibles[number].session.close()
# Close the last bible's connection if possible.
- if oldBible is not None:
- oldBible.close_connection()
+ if old_bible is not None:
+ old_bible.close_connection()
def postWizard(self):
"""
@@ -608,7 +614,7 @@
else:
failed_import_text = u''
if successful_import > 0:
- if self.include_webbible:
+ if self.includeWebBible:
self.progressLabel.setText(unicode(
translate('BiblesPlugin.UpgradeWizardForm', 'Upgrading '
'Bible(s): %s successful%s\nPlease note that verses from '
=== modified file 'openlp/plugins/bibles/forms/booknameform.py'
--- openlp/plugins/bibles/forms/booknameform.py 2012-04-20 19:14:23 +0000
+++ openlp/plugins/bibles/forms/booknameform.py 2012-04-23 19:30:30 +0000
@@ -56,7 +56,7 @@
QDialog.__init__(self, parent)
self.setupUi(self)
self.customSignals()
- self.booknames = BibleStrings().Booknames
+ self.book_names = BibleStrings().BookNames
self.book_id = False
def customSignals(self):
@@ -102,7 +102,7 @@
addBook = False
if addBook:
self.correspondingComboBox.addItem(
- self.booknames[item[u'abbreviation']])
+ self.book_names[item[u'abbreviation']])
def exec_(self, name, books, maxbooks):
self.books = books
@@ -129,8 +129,8 @@
for character in u'\\.^$*+?{}[]()':
cor_book = cor_book.replace(character, u'\\' + character)
books = filter(lambda key:
- re.match(cor_book, unicode(self.booknames[key]), re.UNICODE),
- self.booknames.keys())
+ re.match(cor_book, unicode(self.book_names[key]), re.UNICODE),
+ self.book_names.keys())
books = filter(None, map(BiblesResourcesDB.get_book, books))
if books:
self.book_id = books[0][u'id']
=== modified file 'openlp/plugins/bibles/forms/editbibledialog.py'
--- openlp/plugins/bibles/forms/editbibledialog.py 2012-04-11 17:39:15 +0000
+++ openlp/plugins/bibles/forms/editbibledialog.py 2012-04-23 19:30:30 +0000
@@ -141,7 +141,7 @@
QtCore.QMetaObject.connectSlotsByName(editBibleDialog)
def retranslateUi(self, editBibleDialog):
- self.booknames = BibleStrings().Booknames
+ self.book_names = BibleStrings().BookNames
editBibleDialog.setWindowTitle(
translate('BiblesPlugin.EditBibleForm', 'Bible Editor'))
# Meta tab
@@ -178,4 +178,4 @@
translate('SongsPlugin.EditBibleForm', 'Custom Book Names'))
for book in BiblesResourcesDB.get_books():
self.bookNameLabel[book[u'abbreviation']].setText(
- u'%s:' % unicode(self.booknames[book[u'abbreviation']]))
+ u'%s:' % unicode(self.book_names[book[u'abbreviation']]))
=== modified file 'openlp/plugins/bibles/forms/editbibleform.py'
--- openlp/plugins/bibles/forms/editbibleform.py 2012-04-12 20:58:11 +0000
+++ openlp/plugins/bibles/forms/editbibleform.py 2012-04-23 19:30:30 +0000
@@ -50,7 +50,7 @@
"""
QtGui.QDialog.__init__(self, parent)
self.mediaitem = mediaitem
- self.booknames = BibleStrings().Booknames
+ self.book_names = BibleStrings().BookNames
self.setupUi(self)
self.manager = manager
@@ -64,19 +64,19 @@
log.debug(u'Load Bible')
self.bible = bible
self.versionNameEdit.setText(
- self.manager.get_meta_data(self.bible, u'Version').value)
+ self.manager.get_meta_data(self.bible, u'name').value)
self.copyrightEdit.setText(
- self.manager.get_meta_data(self.bible, u'Copyright').value)
+ self.manager.get_meta_data(self.bible, u'copyright').value)
self.permissionsEdit.setText(
- self.manager.get_meta_data(self.bible, u'Permissions').value)
- bookname_language = self.manager.get_meta_data(self.bible,
- u'Bookname language')
- if bookname_language and bookname_language.value != u'None':
+ self.manager.get_meta_data(self.bible, u'permissions').value)
+ book_name_language = self.manager.get_meta_data(self.bible,
+ u'book_name_language')
+ if book_name_language and book_name_language.value != u'None':
self.languageSelectionComboBox.setCurrentIndex(
- int(bookname_language.value) + 1)
+ int(book_name_language.value) + 1)
self.books = {}
self.webbible = self.manager.get_meta_data(self.bible,
- u'download source')
+ u'download_source')
if self.webbible:
self.bookNameNotice.setText(translate('BiblesPlugin.EditBibleForm',
'This is a Web Download Bible.\nIt is not possible to '
@@ -119,9 +119,9 @@
version = unicode(self.versionNameEdit.text())
copyright = unicode(self.copyrightEdit.text())
permissions = unicode(self.permissionsEdit.text())
- bookname_language = self.languageSelectionComboBox.currentIndex() - 1
- if bookname_language == -1:
- bookname_language = None
+ book_name_language = self.languageSelectionComboBox.currentIndex() - 1
+ if book_name_language == -1:
+ book_name_language = None
if not self.validateMeta(version, copyright):
return
if not self.webbible:
@@ -135,7 +135,7 @@
Receiver.send_message(u'openlp_process_events')
Receiver.send_message(u'cursor_busy')
self.manager.save_meta_data(self.bible, version, copyright, permissions,
- bookname_language)
+ book_name_language)
if not self.webbible:
for abbr, book in self.books.iteritems():
if book:
@@ -146,11 +146,11 @@
Receiver.send_message(u'cursor_normal')
QtGui.QDialog.accept(self)
- def validateMeta(self, version, copyright):
+ def validateMeta(self, name, copyright):
"""
Validate the Meta before saving.
"""
- if not version:
+ if not name:
self.versionNameEdit.setFocus()
critical_error_message_box(UiStrings().EmptyField,
translate('BiblesPlugin.BibleEditForm',
@@ -163,9 +163,9 @@
'You need to set a copyright for your Bible. '
'Bibles in the Public Domain need to be marked as such.'))
return False
- elif self.manager.exists(version) and \
- self.manager.get_meta_data(self.bible, u'Version').value != \
- version:
+ elif self.manager.exists(name) and \
+ self.manager.get_meta_data(self.bible, u'name').value != \
+ name:
self.versionNameEdit.setFocus()
critical_error_message_box(
translate('BiblesPlugin.BibleEditForm', 'Bible Exists'),
@@ -175,37 +175,37 @@
return False
return True
- def validateBook(self, new_bookname, abbreviation):
+ def validateBook(self, new_book_name, abbreviation):
"""
Validate a book.
"""
book_regex = re.compile(u'[\d]*[^\d]+$')
- if not new_bookname:
+ if not new_book_name:
self.bookNameEdit[abbreviation].setFocus()
critical_error_message_box(UiStrings().EmptyField,
unicode(translate('BiblesPlugin.BibleEditForm',
'You need to specify a book name for "%s".')) %
- self.booknames[abbreviation])
+ self.book_names[abbreviation])
return False
- elif not book_regex.match(new_bookname):
+ elif not book_regex.match(new_book_name):
self.bookNameEdit[abbreviation].setFocus()
critical_error_message_box(UiStrings().EmptyField,
unicode(translate('BiblesPlugin.BibleEditForm',
'The book name "%s" is not correct.\nNumbers can only be used '
'at the beginning and must\nbe followed by one or more '
- 'non-numeric characters.')) % new_bookname)
+ 'non-numeric characters.')) % new_book_name)
return False
for abbr, book in self.books.iteritems():
if book:
if abbr == abbreviation:
continue
- if unicode(self.bookNameEdit[abbr].text()) == new_bookname:
+ if unicode(self.bookNameEdit[abbr].text()) == new_book_name:
self.bookNameEdit[abbreviation].setFocus()
critical_error_message_box(
translate('BiblesPlugin.BibleEditForm',
'Duplicate Book Name'),
unicode(translate('BiblesPlugin.BibleEditForm',
'The Book Name "%s" has been entered more than once.'))
- % new_bookname)
+ % new_book_name)
return False
return True
=== modified file 'openlp/plugins/bibles/lib/__init__.py'
--- openlp/plugins/bibles/lib/__init__.py 2012-04-12 20:59:16 +0000
+++ openlp/plugins/bibles/lib/__init__.py 2012-04-23 19:30:30 +0000
@@ -88,7 +88,7 @@
"""
These strings should need a good reason to be retranslated elsewhere.
"""
- self.Booknames = {
+ self.BookNames = {
u'Gen': translate('BiblesPlugin', 'Genesis'),
u'Exod': translate('BiblesPlugin', 'Exodus'),
u'Lev': translate('BiblesPlugin', 'Leviticus'),
@@ -355,7 +355,7 @@
log.debug(u'Matched reference %s' % reference)
book = match.group(u'book')
if not book_ref_id:
- booknames = BibleStrings().Booknames
+ book_names = BibleStrings().BookNames
# escape reserved characters
book_escaped = book
for character in u'\\.^$*+?{}[]()':
@@ -369,7 +369,7 @@
book_ref_id = db_book.book_reference_id
elif language_selection == LanguageSelection.Application:
books = filter(lambda key:
- regex_book.match(unicode(booknames[key])), booknames.keys())
+ regex_book.match(unicode(book_names[key])), book_names.keys())
books = filter(None, map(BiblesResourcesDB.get_book, books))
for value in books:
if bible.get_book_by_book_ref_id(value[u'id']):
=== modified file 'openlp/plugins/bibles/lib/biblestab.py'
--- openlp/plugins/bibles/lib/biblestab.py 2012-04-11 17:39:15 +0000
+++ openlp/plugins/bibles/lib/biblestab.py 2012-04-23 19:30:30 +0000
@@ -483,7 +483,7 @@
self.getGreyTextPalette(False))
self.endSeparatorCheckBox.setChecked(True)
self.language_selection = settings.value(
- u'bookname language', QtCore.QVariant(0)).toInt()[0]
+ u'book name language', QtCore.QVariant(0)).toInt()[0]
self.languageSelectionComboBox.setCurrentIndex(self.language_selection)
settings.endGroup()
@@ -496,7 +496,7 @@
QtCore.QVariant(self.display_style))
settings.setValue(u'verse layout style',
QtCore.QVariant(self.layout_style))
- settings.setValue(u'bookname language',
+ settings.setValue(u'book name language',
QtCore.QVariant(self.language_selection))
settings.setValue(u'second bibles', QtCore.QVariant(self.second_bibles))
settings.setValue(u'bible theme', QtCore.QVariant(self.bible_theme))
=== modified file 'openlp/plugins/bibles/lib/db.py'
--- openlp/plugins/bibles/lib/db.py 2012-04-20 19:14:23 +0000
+++ openlp/plugins/bibles/lib/db.py 2012-04-23 19:30:30 +0000
@@ -39,6 +39,7 @@
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 AppLocation, clean_filename
+import upgrade
log = logging.getLogger(__name__)
@@ -147,7 +148,7 @@
self.file = clean_filename(self.name) + u'.sqlite'
if u'file' in kwargs:
self.file = kwargs[u'file']
- Manager.__init__(self, u'bibles', init_schema, self.file)
+ Manager.__init__(self, u'bibles', init_schema, self.file, upgrade)
if u'file' in kwargs:
self.get_name()
if u'path' in kwargs:
@@ -167,7 +168,7 @@
"""
Returns the version name of the Bible.
"""
- version_name = self.get_object(BibleMeta, u'Version')
+ version_name = self.get_object(BibleMeta, u'name')
self.name = version_name.value if version_name else None
return self.name
@@ -182,7 +183,6 @@
The actual Qt wizard form.
"""
self.wizard = wizard
- self.save_meta(u'dbversion', u'2')
return self.name
def create_book(self, name, bk_ref_id, testament=1):
@@ -483,7 +483,7 @@
prior to 1.9.6.
"""
try:
- columns = self.session.query(Book).all()
+ self.session.query(Book).all()
except:
return True
return False
@@ -550,16 +550,13 @@
log.debug(u'BiblesResourcesDB.get_books()')
books = BiblesResourcesDB.run_sql(u'SELECT id, testament_id, name, '
u'abbreviation, chapters FROM book_reference ORDER BY id')
- return [
- {
- u'id': book[0],
- u'testament_id': book[1],
- u'name': unicode(book[2]),
- u'abbreviation': unicode(book[3]),
- u'chapters': book[4]
- }
- for book in books
- ]
+ return [{
+ u'id': book[0],
+ u'testament_id': book[1],
+ u'name': unicode(book[2]),
+ u'abbreviation': unicode(book[3]),
+ u'chapters': book[4]
+ } for book in books]
@staticmethod
def get_book(name, lower=False):
@@ -601,7 +598,7 @@
Return the books which include string.
``string``
- The string to search for in the booknames or abbreviations.
+ The string to search for in the book names or abbreviations.
"""
log.debug(u'BiblesResourcesDB.get_book_like("%s")', string)
if not isinstance(string, unicode):
@@ -611,16 +608,13 @@
u'LOWER(name) LIKE ? OR LOWER(abbreviation) LIKE ?',
(u'%' + string.lower() + u'%', u'%' + string.lower() + u'%'))
if books:
- return [
- {
+ return [{
u'id': book[0],
u'testament_id': book[1],
u'name': unicode(book[2]),
u'abbreviation': unicode(book[3]),
u'chapters': book[4]
- }
- for book in books
- ]
+ } for book in books]
else:
return None
@@ -747,16 +741,13 @@
u'language_id, download_source_id FROM webbibles WHERE '
u'download_source_id = ?', (source[u'id'],))
if bibles:
- return [
- {
+ return [{
u'id': bible[0],
u'name': bible[1],
u'abbreviation': bible[2],
u'language_id': bible[3],
u'download_source_id': bible[4]
- }
- for bible in bibles
- ]
+ } for bible in bibles]
else:
return None
@@ -789,7 +780,7 @@
u'abbreviation': bible[0][2],
u'language_id': bible[0][3],
u'download_source_id': bible[0][4]
- }
+ }
except (IndexError, TypeError):
return None
@@ -850,14 +841,11 @@
languages = BiblesResourcesDB.run_sql(u'SELECT id, name, code FROM '
u'language ORDER by name')
if languages:
- return [
- {
+ return [{
u'id': language[0],
u'name': unicode(language[1]),
u'code': unicode(language[2])
- }
- for language in languages
- ]
+ } for language in languages]
else:
return None
@@ -1036,7 +1024,7 @@
Returns the version name of the Bible.
"""
version_name = self.run_sql(u'SELECT value FROM '
- u'metadata WHERE key = "Version"')
+ u'metadata WHERE key = "name"')
if version_name:
self.name = version_name[0][0]
else:
@@ -1050,13 +1038,10 @@
metadata = self.run_sql(u'SELECT key, value FROM metadata '
u'ORDER BY rowid')
if metadata:
- return [
- {
+ return [{
u'key': unicode(meta[0]),
u'value': unicode(meta[1])
- }
- for meta in metadata
- ]
+ } for meta in metadata]
else:
return None
@@ -1088,13 +1073,10 @@
"""
books = self.run_sql(u'SELECT name, id FROM book ORDER BY id')
if books:
- return [
- {
+ return [{
u'name': unicode(book[0]),
u'id':int(book[1])
- }
- for book in books
- ]
+ } for book in books]
else:
return None
@@ -1105,15 +1087,12 @@
verses = self.run_sql(u'SELECT book_id, chapter, verse, text FROM '
u'verse WHERE book_id = ? ORDER BY id', (book_id, ))
if verses:
- return [
- {
+ return [{
u'book_id': int(verse[0]),
u'chapter': int(verse[1]),
u'verse': int(verse[2]),
u'text': unicode(verse[3])
- }
- for verse in verses
- ]
+ } for verse in verses]
else:
return None
=== modified file 'openlp/plugins/bibles/lib/http.py'
--- openlp/plugins/bibles/lib/http.py 2012-04-03 19:30:30 +0000
+++ openlp/plugins/bibles/lib/http.py 2012-04-23 19:30:30 +0000
@@ -49,28 +49,28 @@
"""
Extract verses from BibleGateway
"""
- def __init__(self, proxyurl=None):
- log.debug(u'BGExtract.init("%s")', proxyurl)
- self.proxyurl = proxyurl
+ def __init__(self, proxy_url=None):
+ log.debug(u'BGExtract.init("%s")', proxy_url)
+ self.proxy_url = proxy_url
socket.setdefaulttimeout(30)
- def get_bible_chapter(self, version, bookname, chapter):
+ def get_bible_chapter(self, version, book_name, chapter):
"""
Access and decode Bibles via the BibleGateway website.
``version``
The version of the Bible like 31 for New International version.
- ``bookname``
+ ``book_name``
Name of the Book.
``chapter``
Chapter number.
"""
log.debug(u'BGExtract.get_bible_chapter("%s", "%s", "%s")', version,
- bookname, chapter)
- urlbookname = urllib.quote(bookname.encode("utf-8"))
- url_params = u'search=%s+%s&version=%s' % (urlbookname, chapter,
+ book_name, chapter)
+ url_book_name = urllib.quote(book_name.encode("utf-8"))
+ url_params = u'search=%s+%s&version=%s' % (url_book_name, chapter,
version)
cleaner = [(re.compile(' |<br />|\'\+\''), lambda match: '')]
soup = get_soup_for_bible_ref(
@@ -120,7 +120,7 @@
clean_verse_num = int(str(raw_verse_num))
except ValueError:
log.warn(u'Illegal verse number in %s %s %s:%s',
- version, bookname, chapter, unicode(raw_verse_num))
+ version, book_name, chapter, unicode(raw_verse_num))
if clean_verse_num:
verse_text = raw_verse_num.next
part = raw_verse_num.next.next
@@ -138,7 +138,7 @@
log.debug(u'No content found in the BibleGateway response.')
send_error_message(u'parse')
return None
- return SearchResults(bookname, chapter, verse_list)
+ return SearchResults(book_name, chapter, verse_list)
def get_books_from_http(self, version):
"""
@@ -195,30 +195,30 @@
"""
Extract verses from Bibleserver.com
"""
- def __init__(self, proxyurl=None):
- log.debug(u'BSExtract.init("%s")', proxyurl)
- self.proxyurl = proxyurl
+ def __init__(self, proxy_url=None):
+ log.debug(u'BSExtract.init("%s")', proxy_url)
+ self.proxy_url = proxy_url
socket.setdefaulttimeout(30)
- def get_bible_chapter(self, version, bookname, chapter):
+ def get_bible_chapter(self, version, book_name, chapter):
"""
Access and decode bibles via Bibleserver mobile website
``version``
The version of the bible like NIV for New International Version
- ``bookname``
+ ``book_name``
Text name of bible book e.g. Genesis, 1. John, 1John or Offenbarung
``chapter``
Chapter number
"""
log.debug(u'BSExtract.get_bible_chapter("%s", "%s", "%s")', version,
- bookname, chapter)
- urlversion = urllib.quote(version.encode("utf-8"))
- urlbookname = urllib.quote(bookname.encode("utf-8"))
+ book_name, chapter)
+ url_version = urllib.quote(version.encode("utf-8"))
+ url_book_name = urllib.quote(book_name.encode("utf-8"))
chapter_url = u'http://m.bibleserver.com/text/%s/%s%d' % \
- (urlversion, urlbookname, chapter)
+ (url_version, url_book_name, chapter)
header = (u'Accept-Language', u'en')
soup = get_soup_for_bible_ref(chapter_url, header)
if not soup:
@@ -236,7 +236,7 @@
Receiver.send_message(u'openlp_process_events')
versenumber = int(verse_number.sub(r'\3', verse[u'class']))
verses[versenumber] = verse.contents[1].rstrip(u'\n')
- return SearchResults(bookname, chapter, verses)
+ return SearchResults(book_name, chapter, verses)
def get_books_from_http(self, version):
"""
@@ -268,72 +268,72 @@
"""
Extract verses from CrossWalk/BibleStudyTools
"""
- def __init__(self, proxyurl=None):
- log.debug(u'CWExtract.init("%s")', proxyurl)
- self.proxyurl = proxyurl
+ def __init__(self, proxy_url=None):
+ log.debug(u'CWExtract.init("%s")', proxy_url)
+ self.proxy_url = proxy_url
socket.setdefaulttimeout(30)
- def get_bible_chapter(self, version, bookname, chapter):
+ def get_bible_chapter(self, version, book_name, chapter):
"""
Access and decode bibles via the Crosswalk website
``version``
The version of the Bible like niv for New International Version
- ``bookname``
+ ``book_name``
Text name of in english e.g. 'gen' for Genesis
``chapter``
Chapter number
"""
log.debug(u'CWExtract.get_bible_chapter("%s", "%s", "%s")', version,
- bookname, chapter)
- urlbookname = bookname.replace(u' ', u'-')
- urlbookname = urlbookname.lower()
- urlbookname = urllib.quote(urlbookname.encode("utf-8"))
+ book_name, chapter)
+ url_book_name = book_name.replace(u' ', u'-')
+ url_book_name = url_book_name.lower()
+ url_book_name = urllib.quote(url_book_name.encode("utf-8"))
chapter_url = u'http://www.biblestudytools.com/%s/%s/%s.html' % \
- (version, urlbookname, chapter)
+ (version, url_book_name, chapter)
soup = get_soup_for_bible_ref(chapter_url)
if not soup:
return None
Receiver.send_message(u'openlp_process_events')
- htmlverses = soup.findAll(u'span', u'versetext')
- if not htmlverses:
+ html_verses = soup.findAll(u'span', u'versetext')
+ if not html_verses:
log.error(u'No verses found in the CrossWalk response.')
send_error_message(u'parse')
return None
verses = {}
reduce_spaces = re.compile(r'[ ]{2,}')
fix_punctuation = re.compile(r'[ ]+([.,;])')
- for verse in htmlverses:
+ for verse in html_verses:
Receiver.send_message(u'openlp_process_events')
- versenumber = int(verse.contents[0].contents[0])
- versetext = u''
+ verse_number = int(verse.contents[0].contents[0])
+ verse_text = u''
for part in verse.contents:
Receiver.send_message(u'openlp_process_events')
if isinstance(part, NavigableString):
- versetext = versetext + part
+ verse_text = verse_text + part
elif part and part.attrMap and \
(part.attrMap[u'class'] == u'WordsOfChrist' or \
part.attrMap[u'class'] == u'strongs'):
for subpart in part.contents:
Receiver.send_message(u'openlp_process_events')
if isinstance(subpart, NavigableString):
- versetext = versetext + subpart
+ verse_text = verse_text + subpart
elif subpart and subpart.attrMap and \
subpart.attrMap[u'class'] == u'strongs':
for subsub in subpart.contents:
Receiver.send_message(u'openlp_process_events')
if isinstance(subsub, NavigableString):
- versetext = versetext + subsub
+ verse_text = verse_text + subsub
Receiver.send_message(u'openlp_process_events')
# Fix up leading and trailing spaces, multiple spaces, and spaces
# between text and , and .
- versetext = versetext.strip(u'\n\r\t ')
- versetext = reduce_spaces.sub(u' ', versetext)
- versetext = fix_punctuation.sub(r'\1', versetext)
- verses[versenumber] = versetext
- return SearchResults(bookname, chapter, verses)
+ verse_text = verse_text.strip(u'\n\r\t ')
+ verse_text = reduce_spaces.sub(u' ', verse_text)
+ verse_text = fix_punctuation.sub(r'\1', verse_text)
+ verses[verse_number] = verse_text
+ return SearchResults(book_name, chapter, verses)
def get_books_from_http(self, version):
"""
@@ -401,16 +401,16 @@
self.wizard.incrementProgressBar(unicode(translate(
'BiblesPlugin.HTTPBible',
'Registering Bible and loading books...')))
- self.save_meta(u'download source', self.download_source)
- self.save_meta(u'download name', self.download_name)
+ self.save_meta(u'download_source', self.download_source)
+ self.save_meta(u'download_name', self.download_name)
if self.proxy_server:
- self.save_meta(u'proxy server', self.proxy_server)
+ self.save_meta(u'proxy_server', self.proxy_server)
if self.proxy_username:
# Store the proxy userid.
- self.save_meta(u'proxy username', self.proxy_username)
+ self.save_meta(u'proxy_username', self.proxy_username)
if self.proxy_password:
# Store the proxy password.
- self.save_meta(u'proxy password', self.proxy_password)
+ self.save_meta(u'proxy_password', self.proxy_password)
if self.download_source.lower() == u'crosswalk':
handler = CWExtract(self.proxy_server)
elif self.download_source.lower() == u'biblegateway':
@@ -499,10 +499,10 @@
## if it was there. By reusing the returned book name
## we get a correct book. For example it is possible
## to request ac and get Acts back.
- bookname = search_results.book
+ book_name = search_results.book
Receiver.send_message(u'openlp_process_events')
# Check to see if book/chapter exists.
- db_book = self.get_book(bookname)
+ db_book = self.get_book(book_name)
self.create_chapter(db_book.id, search_results.chapter,
search_results.verselist)
Receiver.send_message(u'openlp_process_events')
=== modified file 'openlp/plugins/bibles/lib/manager.py'
--- openlp/plugins/bibles/lib/manager.py 2012-04-12 20:58:11 +0000
+++ openlp/plugins/bibles/lib/manager.py 2012-04-23 19:30:30 +0000
@@ -164,12 +164,12 @@
self.db_cache[name] = bible
# Look to see if lazy load bible exists and get create getter.
source = self.db_cache[name].get_object(BibleMeta,
- u'download source')
+ u'download_source')
if source:
download_name = self.db_cache[name].get_object(BibleMeta,
- u'download name').value
+ u'download_name').value
meta_proxy = self.db_cache[name].get_object(BibleMeta,
- u'proxy url')
+ u'proxy_server')
web_bible = HTTPBible(self.parent, path=self.path,
file=filename, download_source=source.value,
download_name=download_name)
@@ -330,7 +330,7 @@
'Import Wizard to install one or more Bibles.')
})
return None
- language_selection = self.get_meta_data(bible, u'Bookname language')
+ language_selection = self.get_meta_data(bible, u'book_name_language')
if language_selection:
language_selection = int(language_selection.value)
if language_selection is None or language_selection == -1:
@@ -377,7 +377,7 @@
Unicode. The Bible to get the language selection from.
"""
log.debug(u'BibleManager.get_language_selection("%s")', bible)
- language_selection = self.get_meta_data(bible, u'Bookname language')
+ language_selection = self.get_meta_data(bible, u'book_name_language')
if language_selection and language_selection.value != u'None':
return int(language_selection.value)
if language_selection is None or language_selection.value == u'None':
@@ -410,17 +410,17 @@
return None
# Check if the bible or second_bible is a web bible.
webbible = self.db_cache[bible].get_object(BibleMeta,
- u'download source')
+ u'download_source')
second_webbible = u''
if second_bible:
second_webbible = self.db_cache[second_bible].get_object(BibleMeta,
- u'download source')
+ u'download_source')
if webbible or second_webbible:
Receiver.send_message(u'openlp_information_message', {
u'title': translate('BiblesPlugin.BibleManager',
- 'Web Bible cannot be used'),
+ 'Web Bible cannot be used'),
u'message': translate('BiblesPlugin.BibleManager',
- 'Text Search is not available with Web Bibles.')
+ 'Text Search is not available with Web Bibles.')
})
return None
if text:
@@ -428,27 +428,27 @@
else:
Receiver.send_message(u'openlp_information_message', {
u'title': translate('BiblesPlugin.BibleManager',
- 'Scripture Reference Error'),
+ 'Scripture Reference Error'),
u'message': translate('BiblesPlugin.BibleManager',
- 'You did not enter a search keyword.\n'
- 'You can separate different keywords by a space to search for '
- 'all of your keywords and you can separate them by a comma to '
- 'search for one of them.')
+ 'You did not enter a search keyword.\n'
+ 'You can separate different keywords by a space to '
+ 'search for all of your keywords and you can separate '
+ 'them by a comma to search for one of them.')
})
return None
def save_meta_data(self, bible, version, copyright, permissions,
- bookname_language=None):
+ book_name_language=None):
"""
Saves the bibles meta data.
"""
log.debug(u'save_meta data %s, %s, %s, %s',
bible, version, copyright, permissions)
- self.db_cache[bible].save_meta(u'Version', version)
- self.db_cache[bible].save_meta(u'Copyright', copyright)
- self.db_cache[bible].save_meta(u'Permissions', permissions)
- self.db_cache[bible].save_meta(u'Bookname language',
- bookname_language)
+ self.db_cache[bible].save_meta(u'name', version)
+ self.db_cache[bible].save_meta(u'copyright', copyright)
+ self.db_cache[bible].save_meta(u'permissions', permissions)
+ self.db_cache[bible].save_meta(u'book_name_language',
+ book_name_language)
def get_meta_data(self, bible, key):
"""
=== modified file 'openlp/plugins/bibles/lib/mediaitem.py'
--- openlp/plugins/bibles/lib/mediaitem.py 2012-04-12 20:58:11 +0000
+++ openlp/plugins/bibles/lib/mediaitem.py 2012-04-23 19:30:30 +0000
@@ -64,7 +64,7 @@
self.unlockIcon = build_icon(u':/bibles/bibles_search_unlock.png')
MediaManagerItem.__init__(self, parent, plugin, icon)
# Place to store the search results for both bibles.
- self.settings = self.plugin.settings_tab
+ self.settings = self.plugin.settingsTab
self.quickPreviewAllowed = True
self.hasSearch = True
self.search_results = {}
@@ -433,7 +433,7 @@
self.advancedBookComboBox.clear()
first = True
language_selection = self.plugin.manager.get_language_selection(bible)
- booknames = BibleStrings().Booknames
+ book_names = BibleStrings().BookNames
for book in book_data:
row = self.advancedBookComboBox.count()
if language_selection == LanguageSelection.Bible:
@@ -442,7 +442,7 @@
data = BiblesResourcesDB.get_book_by_id(
book[u'book_reference_id'])
self.advancedBookComboBox.addItem(
- booknames[data[u'abbreviation']])
+ book_names[data[u'abbreviation']])
elif language_selection == LanguageSelection.English:
data = BiblesResourcesDB.get_book_by_id(
book[u'book_reference_id'])
@@ -509,12 +509,12 @@
if language_selection == LanguageSelection.Bible:
books = [book.name + u' ' for book in book_data]
elif language_selection == LanguageSelection.Application:
- booknames = BibleStrings().Booknames
+ book_names = BibleStrings().BookNames
for book in book_data:
data = BiblesResourcesDB.get_book_by_id(
book.book_reference_id)
books.append(unicode(
- booknames[data[u'abbreviation']]) + u' ')
+ book_names[data[u'abbreviation']]) + u' ')
elif language_selection == LanguageSelection.English:
for book in book_data:
data = BiblesResourcesDB.get_book_by_id(
@@ -537,7 +537,7 @@
elif self.advancedTab.isVisible():
bible = unicode(self.advancedVersionComboBox.currentText())
if bible:
- self.editBibleForm = EditBibleForm(self, self.plugin.formparent,
+ self.editBibleForm = EditBibleForm(self, self.plugin.formParent,
self.plugin.manager)
self.editBibleForm.loadBible(bible)
if self.editBibleForm.exec_():
@@ -806,30 +806,30 @@
further action is saved for/in each row.
"""
verse_separator = get_reference_separator(u'sep_v_display')
- version = self.plugin.manager.get_meta_data(bible, u'Version').value
- copyright = self.plugin.manager.get_meta_data(bible, u'Copyright').value
+ version = self.plugin.manager.get_meta_data(bible, u'name').value
+ copyright = self.plugin.manager.get_meta_data(bible, u'copyright').value
permissions = \
- self.plugin.manager.get_meta_data(bible, u'Permissions').value
+ self.plugin.manager.get_meta_data(bible, u'permissions').value
second_version = u''
second_copyright = u''
second_permissions = u''
if second_bible:
second_version = self.plugin.manager.get_meta_data(
- second_bible, u'Version').value
+ second_bible, u'name').value
second_copyright = self.plugin.manager.get_meta_data(
- second_bible, u'Copyright').value
+ second_bible, u'copyright').value
second_permissions = self.plugin.manager.get_meta_data(
- second_bible, u'Permissions').value
+ second_bible, u'permissions').value
items = []
language_selection = self.plugin.manager.get_language_selection(bible)
for count, verse in enumerate(search_results):
if language_selection == LanguageSelection.Bible:
book = verse.book.name
elif language_selection == LanguageSelection.Application:
- booknames = BibleStrings().Booknames
+ book_names = BibleStrings().Booknames
data = BiblesResourcesDB.get_book_by_id(
verse.book.book_reference_id)
- book = unicode(booknames[data[u'abbreviation']])
+ book = unicode(book_names[data[u'abbreviation']])
elif language_selection == LanguageSelection.English:
data = BiblesResourcesDB.get_book_by_id(
verse.book.book_reference_id)
=== added file 'openlp/plugins/bibles/lib/upgrade.py'
--- openlp/plugins/bibles/lib/upgrade.py 1970-01-01 00:00:00 +0000
+++ openlp/plugins/bibles/lib/upgrade.py 2012-04-23 19:30:30 +0000
@@ -0,0 +1,191 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2012 Raoul Snyman #
+# Portions copyright (c) 2008-2012 Tim Bentley, Gerald Britton, Jonathan #
+# Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, #
+# Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias #
+# Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
+# Maikel Stuivenberg, Martin Thompson, Jon Tibble, 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 #
+###############################################################################
+"""
+The :mod:`upgrade` module provides a way for the database and schema that is the
+backend for the Bibles plugin
+"""
+import logging
+
+from sqlalchemy import Table, func, select, insert
+
+__version__ = 1
+log = logging.getLogger(__name__)
+
+def upgrade_setup(metadata):
+ """
+ Set up the latest revision all tables, with reflection, needed for the
+ upgrade process. If you want to drop a table, you need to remove it from
+ here, and add it to your upgrade function.
+ """
+ # Don't define the "metadata" table, as the upgrade mechanism already
+ # defines it.
+ tables = {
+ u'book': Table(u'book', metadata, autoload=True),
+ u'verse': Table(u'verse', metadata, autoload=True)
+ }
+ return tables
+
+
+def upgrade_1(session, metadata, tables):
+ """
+ Version 1 upgrade.
+
+ This upgrade renames a number of keys to a single naming convention..
+ """
+ metadata_table = metadata.tables[u'metadata']
+ # Copy "Version" to "name" ("version" used by upgrade system)
+ # TODO: Clean up in a subsequent release of OpenLP (like 2.0 final)
+ session.execute(insert(metadata_table).values(
+ key=u'name',
+ value=select(
+ [metadata_table.c.value],
+ metadata_table.c.key == u'Version'
+ ).as_scalar()
+ ))
+ # Copy "Copyright" to "copyright"
+ # TODO: Clean up in a subsequent release of OpenLP (like 2.0 final)
+ session.execute(insert(metadata_table).values(
+ key=u'copyright',
+ value=select(
+ [metadata_table.c.value],
+ metadata_table.c.key == u'Copyright'
+ ).as_scalar()
+ ))
+ # Copy "Permissions" to "permissions"
+ # TODO: Clean up in a subsequent release of OpenLP (like 2.0 final)
+ session.execute(insert(metadata_table).values(
+ key=u'permissions',
+ value=select(
+ [metadata_table.c.value],
+ metadata_table.c.key == u'Permissions'
+ ).as_scalar()
+ ))
+ # Copy "Bookname language" to "book_name_language"
+ # TODO: Clean up in a subsequent release of OpenLP (like 2.0 final)
+ value_count = session.execute(
+ select(
+ [func.count(metadata_table.c.value)],
+ metadata_table.c.key == u'Bookname language'
+ )
+ ).scalar()
+ if value_count > 0:
+ session.execute(insert(metadata_table).values(
+ key=u'book_name_language',
+ value=select(
+ [metadata_table.c.value],
+ metadata_table.c.key == u'Bookname language'
+ ).as_scalar()
+ ))
+ # Copy "download source" to "download_source"
+ # TODO: Clean up in a subsequent release of OpenLP (like 2.0 final)
+ value_count = session.execute(
+ select(
+ [func.count(metadata_table.c.value)],
+ metadata_table.c.key == u'download source'
+ )
+ ).scalar()
+ log.debug(u'download source: %s', value_count)
+ if value_count > 0:
+ session.execute(insert(metadata_table).values(
+ key=u'download_source',
+ value=select(
+ [metadata_table.c.value],
+ metadata_table.c.key == u'download source'
+ ).as_scalar()
+ ))
+ # Copy "download name" to "download_name"
+ # TODO: Clean up in a subsequent release of OpenLP (like 2.0 final)
+ value_count = session.execute(
+ select(
+ [func.count(metadata_table.c.value)],
+ metadata_table.c.key == u'download name'
+ )
+ ).scalar()
+ log.debug(u'download name: %s', value_count)
+ if value_count > 0:
+ session.execute(insert(metadata_table).values(
+ key=u'download_name',
+ value=select(
+ [metadata_table.c.value],
+ metadata_table.c.key == u'download name'
+ ).as_scalar()
+ ))
+ # Copy "proxy server" to "proxy_server"
+ # TODO: Clean up in a subsequent release of OpenLP (like 2.0 final)
+ value_count = session.execute(
+ select(
+ [func.count(metadata_table.c.value)],
+ metadata_table.c.key == u'proxy server'
+ )
+ ).scalar()
+ log.debug(u'proxy server: %s', value_count)
+ if value_count > 0:
+ session.execute(insert(metadata_table).values(
+ key=u'proxy_server',
+ value=select(
+ [metadata_table.c.value],
+ metadata_table.c.key == u'proxy server'
+ ).as_scalar()
+ ))
+ # Copy "proxy username" to "proxy_username"
+ # TODO: Clean up in a subsequent release of OpenLP (like 2.0 final)
+ value_count = session.execute(
+ select(
+ [func.count(metadata_table.c.value)],
+ metadata_table.c.key == u'proxy username'
+ )
+ ).scalar()
+ log.debug(u'proxy username: %s', value_count)
+ if value_count > 0:
+ session.execute(insert(metadata_table).values(
+ key=u'proxy_username',
+ value=select(
+ [metadata_table.c.value],
+ metadata_table.c.key == u'proxy username'
+ ).as_scalar()
+ ))
+ # Copy "proxy password" to "proxy_password"
+ # TODO: Clean up in a subsequent release of OpenLP (like 2.0 final)
+ value_count = session.execute(
+ select(
+ [func.count(metadata_table.c.value)],
+ metadata_table.c.key == u'proxy password'
+ )
+ ).scalar()
+ log.debug(u'proxy password: %s', value_count)
+ if value_count > 0:
+ session.execute(insert(metadata_table).values(
+ key=u'proxy_password',
+ value=select(
+ [metadata_table.c.value],
+ metadata_table.c.key == u'proxy password'
+ ).as_scalar()
+ ))
+ # TODO: Clean up in a subsequent release of OpenLP (like 2.0 final)
+ #session.execute(delete(metadata_table)\
+ # .where(metadata_table.c.key == u'dbversion'))
+ session.commit()
=== modified file 'openlp/plugins/custom/customplugin.py'
--- openlp/plugins/custom/customplugin.py 2011-12-27 10:33:55 +0000
+++ openlp/plugins/custom/customplugin.py 2012-04-23 19:30:30 +0000
@@ -50,8 +50,8 @@
CustomMediaItem, CustomTab)
self.weight = -5
self.manager = Manager(u'custom', init_schema)
- self.icon_path = u':/plugins/plugin_custom.png'
- self.icon = build_icon(self.icon_path)
+ self.iconPath = u':/plugins/plugin_custom.png'
+ self.icon = build_icon(self.iconPath)
def about(self):
about_text = translate('CustomPlugin', '<strong>Custom Slide Plugin'
=== modified file 'openlp/plugins/custom/lib/mediaitem.py'
--- openlp/plugins/custom/lib/mediaitem.py 2012-04-02 00:19:16 +0000
+++ openlp/plugins/custom/lib/mediaitem.py 2012-04-23 19:30:30 +0000
@@ -57,7 +57,7 @@
def __init__(self, parent, plugin, icon):
self.IconPath = u'custom/custom'
MediaManagerItem.__init__(self, parent, plugin, icon)
- self.edit_custom_form = EditCustomForm(self, self.plugin.formparent,
+ self.edit_custom_form = EditCustomForm(self, self.plugin.formParent,
self.plugin.manager)
self.singleServiceItem = False
self.quickPreviewAllowed = True
=== modified file 'openlp/plugins/images/imageplugin.py'
--- openlp/plugins/images/imageplugin.py 2011-12-27 10:33:55 +0000
+++ openlp/plugins/images/imageplugin.py 2012-04-23 19:30:30 +0000
@@ -42,8 +42,8 @@
Plugin.__init__(self, u'images', plugin_helpers, ImageMediaItem,
ImageTab)
self.weight = -7
- self.icon_path = u':/plugins/plugin_images.png'
- self.icon = build_icon(self.icon_path)
+ self.iconPath = u':/plugins/plugin_images.png'
+ self.icon = build_icon(self.iconPath)
QtCore.QObject.connect(Receiver.get_receiver(),
QtCore.SIGNAL(u'image_updated'), self.image_updated)
=== modified file 'openlp/plugins/images/lib/mediaitem.py'
--- openlp/plugins/images/lib/mediaitem.py 2012-04-13 21:47:15 +0000
+++ openlp/plugins/images/lib/mediaitem.py 2012-04-23 19:30:30 +0000
@@ -106,24 +106,24 @@
row_list = [item.row() for item in self.listView.selectedIndexes()]
row_list.sort(reverse=True)
Receiver.send_message(u'cursor_busy')
- self.plugin.formparent.displayProgressBar(len(row_list))
+ self.plugin.formParent.displayProgressBar(len(row_list))
for row in row_list:
text = self.listView.item(row)
if text:
delete_file(os.path.join(self.servicePath,
unicode(text.text())))
self.listView.takeItem(row)
- self.plugin.formparent.incrementProgressBar()
+ self.plugin.formParent.incrementProgressBar()
SettingsManager.set_list(self.settingsSection,
u'images', self.getFileList())
- self.plugin.formparent.finishedProgressBar()
+ self.plugin.formParent.finishedProgressBar()
Receiver.send_message(u'cursor_normal')
self.listView.blockSignals(False)
def loadList(self, images, initialLoad=False):
if not initialLoad:
Receiver.send_message(u'cursor_busy')
- self.plugin.formparent.displayProgressBar(len(images))
+ self.plugin.formParent.displayProgressBar(len(images))
# Sort the themes by its filename considering language specific
# characters. lower() is needed for windows!
images.sort(cmp=locale.strcoll,
@@ -144,9 +144,9 @@
item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(imageFile))
self.listView.addItem(item_name)
if not initialLoad:
- self.plugin.formparent.incrementProgressBar()
+ self.plugin.formParent.incrementProgressBar()
if not initialLoad:
- self.plugin.formparent.finishedProgressBar()
+ self.plugin.formParent.finishedProgressBar()
Receiver.send_message(u'cursor_normal')
def generateSlideData(self, service_item, item=None, xmlVersion=False,
=== modified file 'openlp/plugins/media/mediaplugin.py'
--- openlp/plugins/media/mediaplugin.py 2011-12-27 10:33:55 +0000
+++ openlp/plugins/media/mediaplugin.py 2012-04-23 19:30:30 +0000
@@ -41,8 +41,8 @@
Plugin.__init__(self, u'media', plugin_helpers,
MediaMediaItem)
self.weight = -6
- self.icon_path = u':/plugins/plugin_media.png'
- self.icon = build_icon(self.icon_path)
+ self.iconPath = u':/plugins/plugin_media.png'
+ self.icon = build_icon(self.iconPath)
# passed with drag and drop messages
self.dnd_id = u'Media'
self.audio_extensions_list = \
@@ -59,8 +59,8 @@
Create the settings Tab
"""
visible_name = self.getString(StringContent.VisibleName)
- self.settings_tab = MediaTab(parent, self.name, visible_name[u'title'],
- self.mediaController.mediaPlayers, self.icon_path)
+ self.settingsTab = MediaTab(parent, self.name, visible_name[u'title'],
+ self.mediaController.mediaPlayers, self.iconPath)
def about(self):
about_text = translate('MediaPlugin', '<strong>Media Plugin</strong>'
@@ -142,6 +142,6 @@
self.mediaController.mediaPlayers[u'phonon'].isActive = True
settings.setValue(u'players', \
QtCore.QVariant(u','.join(new_players)))
- self.settings_tab.load()
+ self.settingsTab.load()
settings.remove(u'use phonon')
settings.endGroup()
=== modified file 'openlp/plugins/presentations/lib/mediaitem.py'
--- openlp/plugins/presentations/lib/mediaitem.py 2012-04-20 19:33:43 +0000
+++ openlp/plugins/presentations/lib/mediaitem.py 2012-04-23 19:30:30 +0000
@@ -166,14 +166,14 @@
Receiver.send_message(u'cursor_busy')
if not initialLoad:
Receiver.send_message(u'cursor_busy')
- self.plugin.formparent.displayProgressBar(len(files))
+ self.plugin.formParent.displayProgressBar(len(files))
# Sort the themes by its filename considering language specific
# characters. lower() is needed for windows!
files.sort(cmp=locale.strcoll,
key=lambda filename: os.path.split(unicode(filename))[1].lower())
for file in files:
if not initialLoad:
- self.plugin.formparent.incrementProgressBar()
+ self.plugin.formParent.incrementProgressBar()
if currlist.count(file) > 0:
continue
filename = os.path.split(unicode(file))[1]
@@ -217,7 +217,7 @@
self.listView.addItem(item_name)
Receiver.send_message(u'cursor_normal')
if not initialLoad:
- self.plugin.formparent.finishedProgressBar()
+ self.plugin.formParent.finishedProgressBar()
Receiver.send_message(u'cursor_normal')
def onDeleteClick(self):
@@ -229,7 +229,7 @@
row_list = [item.row() for item in items]
row_list.sort(reverse=True)
Receiver.send_message(u'cursor_busy')
- self.plugin.formparent.displayProgressBar(len(row_list))
+ self.plugin.formParent.displayProgressBar(len(row_list))
for item in items:
filepath = unicode(item.data(
QtCore.Qt.UserRole).toString())
@@ -237,8 +237,8 @@
doc = self.controllers[cidx].add_document(filepath)
doc.presentation_deleted()
doc.close_presentation()
- self.plugin.formparent.incrementProgressBar()
- self.plugin.formparent.finishedProgressBar()
+ self.plugin.formParent.incrementProgressBar()
+ self.plugin.formParent.finishedProgressBar()
Receiver.send_message(u'cursor_normal')
for row in row_list:
self.listView.takeItem(row)
=== modified file 'openlp/plugins/presentations/presentationplugin.py'
--- openlp/plugins/presentations/presentationplugin.py 2012-04-16 07:02:24 +0000
+++ openlp/plugins/presentations/presentationplugin.py 2012-04-23 19:30:30 +0000
@@ -54,16 +54,16 @@
self.controllers = {}
Plugin.__init__(self, u'presentations', plugin_helpers)
self.weight = -8
- self.icon_path = u':/plugins/plugin_presentations.png'
- self.icon = build_icon(self.icon_path)
+ self.iconPath = u':/plugins/plugin_presentations.png'
+ self.icon = build_icon(self.iconPath)
def createSettingsTab(self, parent):
"""
Create the settings Tab
"""
visible_name = self.getString(StringContent.VisibleName)
- self.settings_tab = PresentationTab(parent, self.name,
- visible_name[u'title'], self.controllers, self.icon_path)
+ self.settingsTab = PresentationTab(parent, self.name,
+ visible_name[u'title'], self.controllers, self.iconPath)
def initialise(self):
"""
@@ -99,7 +99,7 @@
Create the Media Manager List
"""
self.mediaItem = PresentationMediaItem(
- self.mediadock.media_dock, self, self.icon, self.controllers)
+ self.mediaDock.media_dock, self, self.icon, self.controllers)
def registerControllers(self, controller):
"""
=== modified file 'openlp/plugins/remotes/remoteplugin.py'
--- openlp/plugins/remotes/remoteplugin.py 2012-03-18 08:06:13 +0000
+++ openlp/plugins/remotes/remoteplugin.py 2012-04-23 19:30:30 +0000
@@ -41,8 +41,8 @@
"""
Plugin.__init__(self, u'remotes', plugin_helpers,
settings_tab_class=RemoteTab)
- self.icon_path = u':/plugins/plugin_remote.png'
- self.icon = build_icon(self.icon_path)
+ self.iconPath = u':/plugins/plugin_remote.png'
+ self.icon = build_icon(self.iconPath)
self.weight = -1
self.server = None
=== modified file 'openlp/plugins/songs/forms/songimportform.py'
--- openlp/plugins/songs/forms/songimportform.py 2012-03-29 19:03:01 +0000
+++ openlp/plugins/songs/forms/songimportform.py 2012-04-23 19:30:30 +0000
@@ -57,7 +57,7 @@
``plugin``
The songs plugin.
"""
- self.clipboard = plugin.formparent.clipboard
+ self.clipboard = plugin.formParent.clipboard
OpenLPWizard.__init__(self, parent, plugin, u'songImportWizard',
u':/wizards/wizard_importsong.bmp')
=== modified file 'openlp/plugins/songs/lib/foilpresenterimport.py'
--- openlp/plugins/songs/lib/foilpresenterimport.py 2011-12-27 10:33:55 +0000
+++ openlp/plugins/songs/lib/foilpresenterimport.py 2012-04-23 19:30:30 +0000
@@ -413,7 +413,7 @@
temp_verse_order_backup = []
temp_sortnr_backup = 1
temp_sortnr_liste = []
- versenumber = {
+ verse_count = {
VerseType.Tags[VerseType.Verse]: 1,
VerseType.Tags[VerseType.Chorus]: 1,
VerseType.Tags[VerseType.Bridge]: 1,
@@ -463,8 +463,8 @@
verse_number = re.compile(u'[a-zA-Z.+-_ ]*').sub(u'', verse_name)
# Foilpresenter allows e. g. "C", but we need "C1".
if not verse_number:
- verse_number = unicode(versenumber[verse_type])
- versenumber[verse_type] += 1
+ verse_number = unicode(verse_count[verse_type])
+ verse_count[verse_type] += 1
else:
# test if foilpresenter have the same versenumber two times with
# different parts raise the verse number
@@ -508,13 +508,13 @@
song.song_number = u''
try:
for bucheintrag in foilpresenterfolie.buch.bucheintrag:
- bookname = self._child(bucheintrag.name)
- if bookname:
+ book_name = self._child(bucheintrag.name)
+ if book_name:
book = self.manager.get_object_filtered(Book,
- Book.name == bookname)
+ Book.name == book_name)
if book is None:
# We need to create a book, because it does not exist.
- book = Book.populate(name=bookname, publisher=u'')
+ book = Book.populate(name=book_name, publisher=u'')
self.manager.save_object(book)
song.song_book_id = book.id
try:
@@ -537,12 +537,12 @@
``song``
The song object.
"""
- for titelstring in foilpresenterfolie.titel.titelstring:
+ for title_string in foilpresenterfolie.titel.titelstring:
if not song.title:
- song.title = self._child(titelstring)
+ song.title = self._child(title_string)
song.alternate_title = u''
else:
- song.alternate_title = self._child(titelstring)
+ song.alternate_title = self._child(title_string)
def _process_topics(self, foilpresenterfolie, song):
"""
@@ -556,13 +556,13 @@
"""
try:
for name in foilpresenterfolie.kategorien.name:
- topictext = self._child(name)
- if topictext:
+ topic_text = self._child(name)
+ if topic_text:
topic = self.manager.get_object_filtered(Topic,
- Topic.name == topictext)
+ Topic.name == topic_text)
if topic is None:
# We need to create a topic, because it does not exist.
- topic = Topic.populate(name=topictext)
+ topic = Topic.populate(name=topic_text)
self.manager.save_object(topic)
song.topics.append(topic)
except AttributeError:
=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
--- openlp/plugins/songs/lib/mediaitem.py 2012-04-13 21:47:15 +0000
+++ openlp/plugins/songs/lib/mediaitem.py 2012-04-23 19:30:30 +0000
@@ -68,7 +68,7 @@
def __init__(self, parent, plugin, icon):
self.IconPath = u'songs/song'
MediaManagerItem.__init__(self, parent, plugin, icon)
- self.editSongForm = EditSongForm(self, self.plugin.formparent,
+ self.editSongForm = EditSongForm(self, self.plugin.formParent,
self.plugin.manager)
self.openLyrics = OpenLyrics(self.plugin.manager)
self.singleServiceItem = False
@@ -409,7 +409,7 @@
QtGui.QMessageBox.Yes) == QtGui.QMessageBox.No:
return
Receiver.send_message(u'cursor_busy')
- self.plugin.formparent.displayProgressBar(len(items))
+ self.plugin.formParent.displayProgressBar(len(items))
for item in items:
item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0]
media_files = self.plugin.manager.get_all_objects(MediaFile,
@@ -428,8 +428,8 @@
except OSError:
log.exception(u'Could not remove directory: %s', save_path)
self.plugin.manager.delete_object(Song, item_id)
- self.plugin.formparent.incrementProgressBar()
- self.plugin.formparent.finishedProgressBar()
+ self.plugin.formParent.incrementProgressBar()
+ self.plugin.formParent.finishedProgressBar()
Receiver.send_message(u'cursor_normal')
self.onSearchTextButtonClicked()
=== modified file 'openlp/plugins/songs/lib/olp1import.py'
--- openlp/plugins/songs/lib/olp1import.py 2011-12-27 10:33:55 +0000
+++ openlp/plugins/songs/lib/olp1import.py 2012-04-23 19:30:30 +0000
@@ -60,7 +60,7 @@
"""
SongImport.__init__(self, manager, **kwargs)
self.availableThemes = \
- kwargs[u'plugin'].formparent.themeManagerContents.getThemes()
+ kwargs[u'plugin'].formParent.themeManagerContents.getThemes()
def doImport(self):
"""
=== modified file 'openlp/plugins/songs/lib/upgrade.py'
--- openlp/plugins/songs/lib/upgrade.py 2011-12-29 18:47:39 +0000
+++ openlp/plugins/songs/lib/upgrade.py 2012-04-23 19:30:30 +0000
@@ -75,6 +75,7 @@
ForeignKeyConstraint([u'song_id'], [u'songs.id'],
table=tables[u'media_files']).create()
+
def upgrade_2(session, metadata, tables):
"""
Version 2 upgrade.
@@ -86,6 +87,7 @@
Column(u'last_modified', types.DateTime(), default=func.now())\
.create(table=tables[u'songs'])
+
def upgrade_3(session, metadata, tables):
"""
Version 3 upgrade.
=== modified file 'openlp/plugins/songs/lib/xml.py'
--- openlp/plugins/songs/lib/xml.py 2012-04-18 21:55:44 +0000
+++ openlp/plugins/songs/lib/xml.py 2012-04-23 19:30:30 +0000
@@ -521,9 +521,9 @@
if hasattr(properties, u'comments'):
comments_list = []
for comment in properties.comments.comment:
- commenttext = self._text(comment)
- if commenttext:
- comments_list.append(commenttext)
+ comment_text = self._text(comment)
+ if comment_text:
+ comments_list.append(comment_text)
song.comments = u'\n'.join(comments_list)
def _process_copyright(self, properties, song):
@@ -746,13 +746,13 @@
song.song_number = u''
if hasattr(properties, u'songbooks'):
for songbook in properties.songbooks.songbook:
- bookname = songbook.get(u'name', u'')
- if bookname:
+ book_name = songbook.get(u'name', u'')
+ if book_name:
book = self.manager.get_object_filtered(Book,
- Book.name == bookname)
+ Book.name == book_name)
if book is None:
# We need to create a book, because it does not exist.
- book = Book.populate(name=bookname, publisher=u'')
+ book = Book.populate(name=book_name, publisher=u'')
self.manager.save_object(book)
song.song_book_id = book.id
song.song_number = songbook.get(u'entry', u'')
@@ -787,14 +787,14 @@
The song object.
"""
if hasattr(properties, u'themes'):
- for topictext in properties.themes.theme:
- topictext = self._text(topictext)
- if topictext:
+ for topic_text in properties.themes.theme:
+ topic_text = self._text(topic_text)
+ if topic_text:
topic = self.manager.get_object_filtered(Topic,
- Topic.name == topictext)
+ Topic.name == topic_text)
if topic is None:
# We need to create a topic, because it does not exist.
- topic = Topic.populate(name=topictext)
+ topic = Topic.populate(name=topic_text)
self.manager.save_object(topic)
song.topics.append(topic)
@@ -813,6 +813,7 @@
VerseError = 2
def __init__(self, type, log_message, display_message):
+ Exception.__init__(self)
self.type = type
self.log_message = log_message
self.display_message = display_message
=== modified file 'openlp/plugins/songs/songsplugin.py'
--- openlp/plugins/songs/songsplugin.py 2012-04-02 00:19:16 +0000
+++ openlp/plugins/songs/songsplugin.py 2012-04-23 19:30:30 +0000
@@ -61,8 +61,8 @@
Plugin.__init__(self, u'songs', plugin_helpers, SongMediaItem, SongsTab)
self.manager = Manager(u'songs', init_schema, upgrade_mod=upgrade)
self.weight = -10
- self.icon_path = u':/plugins/plugin_songs.png'
- self.icon = build_icon(self.icon_path)
+ self.iconPath = u':/plugins/plugin_songs.png'
+ self.icon = build_icon(self.iconPath)
def checkPreConditions(self):
return self.manager.session is not None
@@ -144,7 +144,7 @@
return
progressDialog = QtGui.QProgressDialog(
translate('SongsPlugin', 'Reindexing songs...'), UiStrings().Cancel,
- 0, maxSongs, self.formparent)
+ 0, maxSongs, self.formParent)
progressDialog.setWindowModality(QtCore.Qt.WindowModal)
songs = self.manager.get_all_objects(Song)
for number, song in enumerate(songs):
@@ -241,7 +241,7 @@
song_dbs.append(os.path.join(db_dir, sfile))
if len(song_dbs) == 0:
return
- progress = QtGui.QProgressDialog(self.formparent)
+ progress = QtGui.QProgressDialog(self.formParent)
progress.setWindowModality(QtCore.Qt.WindowModal)
progress.setLabelText(translate('OpenLP.Ui', 'Starting import...'))
progress.setCancelButton(None)
=== modified file 'openlp/plugins/songusage/songusageplugin.py'
--- openlp/plugins/songusage/songusageplugin.py 2012-02-27 23:44:35 +0000
+++ openlp/plugins/songusage/songusageplugin.py 2012-04-23 19:30:30 +0000
@@ -98,13 +98,13 @@
self.songUsageMenu.addAction(self.songUsageReport)
self.songUsageMenu.addAction(self.songUsageDelete)
self.songUsageActiveButton = QtGui.QToolButton(
- self.formparent.statusBar)
+ self.formParent.statusBar)
self.songUsageActiveButton.setCheckable(True)
self.songUsageActiveButton.setAutoRaise(True)
self.songUsageActiveButton.setStatusTip(translate('SongUsagePlugin',
'Toggle the tracking of song usage.'))
self.songUsageActiveButton.setObjectName(u'songUsageActiveButton')
- self.formparent.statusBar.insertPermanentWidget(1,
+ self.formParent.statusBar.insertPermanentWidget(1,
self.songUsageActiveButton)
self.songUsageActiveButton.hide()
# Signals and slots
@@ -138,8 +138,8 @@
action_list.add_action(self.songUsageReport,
unicode(translate('SongUsagePlugin', 'Song Usage')))
self.songUsageDeleteForm = SongUsageDeleteForm(self.manager,
- self.formparent)
- self.songUsageDetailForm = SongUsageDetailForm(self, self.formparent)
+ self.formParent)
+ self.songUsageDetailForm = SongUsageDetailForm(self, self.formParent)
self.songUsageMenu.menuAction().setVisible(True)
self.songUsageActiveButton.show()
Follow ups