← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~meths/openlp/trivialfixes into lp:openlp

 

Jon Tibble has proposed merging lp:~meths/openlp/trivialfixes into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)


Various fixes:

* Fix bible runtime data location - when the application is running we don't write to areas we may not have permission to write to.

* Various variable naming fixes

* addToServiceItem is not an Icon

* Fix db settings location

-- 
https://code.launchpad.net/~meths/openlp/trivialfixes/+merge/27467
Your team OpenLP Core is requested to review the proposed merge of lp:~meths/openlp/trivialfixes into lp:openlp.
=== modified file 'openlp/core/lib/__init__.py'
--- openlp/core/lib/__init__.py	2010-06-05 13:28:53 +0000
+++ openlp/core/lib/__init__.py	2010-06-14 02:51:27 +0000
@@ -95,24 +95,24 @@
         The icon to build. This can be a QIcon, a resource string in the form
         ``:/resource/file.png``, or a file location like ``/path/to/file.png``.
     """
-    ButtonIcon = None
+    button_icon = None
     if isinstance(icon, QtGui.QIcon):
-        ButtonIcon = icon
+        button_icon = icon
     elif isinstance(icon, basestring):
-        ButtonIcon = QtGui.QIcon()
+        button_icon = QtGui.QIcon()
         if icon.startswith(u':/'):
-            ButtonIcon.addPixmap(
-                QtGui.QPixmap(icon), QtGui.QIcon.Normal, QtGui.QIcon.Off)
+            button_icon.addPixmap(QtGui.QPixmap(icon), QtGui.QIcon.Normal,
+                QtGui.QIcon.Off)
         else:
-            ButtonIcon.addPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(icon)),
+            button_icon.addPixmap(QtGui.QPixmap.fromImage(QtGui.QImage(icon)),
                 QtGui.QIcon.Normal, QtGui.QIcon.Off)
     elif isinstance(icon, QtGui.QImage):
-        ButtonIcon = QtGui.QIcon()
-        ButtonIcon.addPixmap(
-            QtGui.QPixmap.fromImage(icon), QtGui.QIcon.Normal, QtGui.QIcon.Off)
-    return ButtonIcon
+        button_icon = QtGui.QIcon()
+        button_icon.addPixmap(QtGui.QPixmap.fromImage(icon),
+            QtGui.QIcon.Normal, QtGui.QIcon.Off)
+    return button_icon
 
-def contextMenuAction(base, icon, text, slot):
+def context_menu_action(base, icon, text, slot):
     """
     Utility method to help build context menus for plugins
     """
@@ -122,7 +122,7 @@
     QtCore.QObject.connect(action, QtCore.SIGNAL(u'triggered()'), slot)
     return action
 
-def contextMenu(base, icon, text):
+def context_menu(base, icon, text):
     """
     Utility method to help build context menus for plugins
     """
@@ -130,7 +130,7 @@
     action.setIcon(build_icon(icon))
     return action
 
-def contextMenuSeparator(base):
+def context_menu_separator(base):
     """
     Add a separator to a context menu
     """
@@ -152,12 +152,12 @@
     realw = preview.width()
     realh = preview.height()
     # and move it to the centre of the preview space
-    newImage = QtGui.QImage(width, height,
+    new_image = QtGui.QImage(width, height,
         QtGui.QImage.Format_ARGB32_Premultiplied)
-    newImage.fill(QtCore.Qt.black)
-    painter = QtGui.QPainter(newImage)
+    new_image.fill(QtCore.Qt.black)
+    painter = QtGui.QPainter(new_image)
     painter.drawImage((width - realw) / 2, (height - realh) / 2, preview)
-    return newImage
+    return new_image
 
 
 class ThemeLevel(object):

=== modified file 'openlp/core/lib/mediamanageritem.py'
--- openlp/core/lib/mediamanageritem.py	2010-06-10 16:36:49 +0000
+++ openlp/core/lib/mediamanageritem.py	2010-06-14 02:51:27 +0000
@@ -28,7 +28,7 @@
 
 from PyQt4 import QtCore, QtGui
 
-from openlp.core.lib import contextMenuAction, contextMenuSeparator, \
+from openlp.core.lib import context_menu_action, context_menu_separator, \
     SettingsManager, OpenLPToolbar, ServiceItem, build_icon
 
 log = logging.getLogger(__name__)
@@ -271,34 +271,34 @@
         self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
         if self.hasEditIcon:
             self.ListView.addAction(
-                contextMenuAction(
+                context_menu_action(
                     self.ListView, u':/general/general_edit.png',
                     u'%s %s' % (self.trUtf8('&Edit'), self.PluginNameVisible),
                     self.onEditClick))
-            self.ListView.addAction(contextMenuSeparator(self.ListView))
+            self.ListView.addAction(context_menu_separator(self.ListView))
         if self.hasDeleteIcon:
             self.ListView.addAction(
-                contextMenuAction(
+                context_menu_action(
                     self.ListView, u':/general/general_delete.png',
                     u'%s %s' % (self.trUtf8('&Delete'), self.PluginNameVisible),
                     self.onDeleteClick))
-            self.ListView.addAction(contextMenuSeparator(self.ListView))
+            self.ListView.addAction(context_menu_separator(self.ListView))
         self.ListView.addAction(
-            contextMenuAction(
+            context_menu_action(
                 self.ListView, u':/general/general_preview.png',
                 u'%s %s' % (self.trUtf8('&Preview'), self.PluginNameVisible),
                 self.onPreviewClick))
         self.ListView.addAction(
-            contextMenuAction(
+            context_menu_action(
                 self.ListView, u':/general/general_live.png',
                 self.trUtf8('&Show Live'), self.onLiveClick))
         self.ListView.addAction(
-            contextMenuAction(
+            context_menu_action(
                 self.ListView, u':/general/general_add.png',
                 self.trUtf8('&Add to Service'), self.onAddClick))
         if self.addToServiceItem:
             self.ListView.addAction(
-                contextMenuAction(
+                context_menu_action(
                     self.ListView, u':/general/general_add.png',
                     self.trUtf8('&Add to selected Service Item'),
                     self.onAddEditClick))
@@ -465,9 +465,9 @@
         """
         service_item = ServiceItem(self.parent)
         if self.ServiceItemIconName:
-            service_item.addIcon(self.ServiceItemIconName)
+            service_item.add_icon(self.ServiceItemIconName)
         else:
-            service_item.addIcon(
+            service_item.add_icon(
                 u':/media/media_' + self.PluginNameShort.lower() + u'.png')
         if self.generateSlideData(service_item, item):
             return service_item

=== modified file 'openlp/core/lib/serviceitem.py'
--- openlp/core/lib/serviceitem.py	2010-06-10 21:30:50 +0000
+++ openlp/core/lib/serviceitem.py	2010-06-14 02:51:27 +0000
@@ -73,9 +73,10 @@
             The plugin that this service item belongs to.
         """
         if plugin:
-            self.RenderManager = plugin.render_manager
+            self.render_manager = plugin.render_manager
             self.name = plugin.name
         self.title = u''
+        self.shortname = u''
         self.audit = u''
         self.items = []
         self.iconic_representation = None
@@ -90,6 +91,7 @@
         self.capabilities = []
         self.is_valid = True
         self.cache = []
+        self.icon = None
 
     def add_capability(self, capability):
         """
@@ -109,7 +111,7 @@
         """
         return capability in self.capabilities
 
-    def addIcon(self, icon):
+    def add_icon(self, icon):
         """
         Add an icon to the service item. This is used when displaying the
         service item in the service manager.
@@ -131,12 +133,12 @@
         if self.service_item_type == ServiceItemType.Text:
             log.debug(u'Formatting slides')
             if self.theme is None:
-                self.RenderManager.set_override_theme(None)
+                self.render_manager.set_override_theme(None)
             else:
-                self.RenderManager.set_override_theme(self.theme)
+                self.render_manager.set_override_theme(self.theme)
             for slide in self._raw_frames:
                 before = time.time()
-                formated = self.RenderManager.format_slide(slide[u'raw_slide'])
+                formated = self.render_manager.format_slide(slide[u'raw_slide'])
                 for format in formated:
                     lines = u''
                     title = u''
@@ -151,9 +153,8 @@
                 log.log(15, u'Formatting took %4s' % (time.time() - before))
         elif self.service_item_type == ServiceItemType.Image:
             for slide in self._raw_frames:
-                slide[u'image'] = \
-                    resize_image(slide[u'image'], self.RenderManager.width,
-                                 self.RenderManager.height)
+                slide[u'image'] = resize_image(slide[u'image'],
+                    self.render_manager.width, self.render_manager.height)
         elif self.service_item_type == ServiceItemType.Command:
             pass
         else:
@@ -167,19 +168,19 @@
         """
         log.debug(u'render individual')
         if self.theme is None:
-            self.RenderManager.set_override_theme(None)
+            self.render_manager.set_override_theme(None)
         else:
-            self.RenderManager.set_override_theme(self.theme)
+            self.render_manager.set_override_theme(self.theme)
         format = self._display_frames[row][u'text'].split(u'\n')
         #if screen blank then do not display footer
         if self.cache[row] is not None:
             frame = self.cache[row]
         else:
             if format[0]:
-                frame = self.RenderManager.generate_slide(format,
-                                self.raw_footer)
+                frame = self.render_manager.generate_slide(format,
+                    self.raw_footer)
             else:
-                frame = self.RenderManager.generate_slide(format, u'')
+                frame = self.render_manager.generate_slide(format, u'')
             self.cache[row] = frame
         return frame
 
@@ -200,7 +201,7 @@
         self._raw_frames.append(
             {u'title': title, u'image': image, u'path': path})
 
-    def add_from_text(self, title, raw_slide, verseTag=None):
+    def add_from_text(self, title, raw_slide, verse_tag=None):
         """
         Add a text slide to the service item.
 
@@ -213,7 +214,7 @@
         self.service_item_type = ServiceItemType.Text
         title = title.split(u'\n')[0]
         self._raw_frames.append(
-            {u'title': title, u'raw_slide': raw_slide, u'verseTag':verseTag})
+            {u'title': title, u'raw_slide': raw_slide, u'verseTag':verse_tag})
 
     def add_from_command(self, path, file_name, image):
         """
@@ -280,7 +281,7 @@
         self.service_item_type = header[u'type']
         self.shortname = header[u'plugin']
         self.theme = header[u'theme']
-        self.addIcon(header[u'icon'])
+        self.add_icon(header[u'icon'])
         self.raw_footer = header[u'footer']
         self.audit = header[u'audit']
         self.notes = header[u'notes']

=== modified file 'openlp/core/lib/xmlrootclass.py'
--- openlp/core/lib/xmlrootclass.py	2010-06-09 17:09:32 +0000
+++ openlp/core/lib/xmlrootclass.py	2010-06-14 02:51:27 +0000
@@ -41,7 +41,7 @@
 
         (element.tag, val) = self.post_tag_hook(element.tag, val)
     """
-    def _setFromXml(self, xml, root_tag):
+    def _set_from_xml(self, xml, root_tag):
         """
         Set song properties from given xml content.
 

=== modified file 'openlp/core/theme/theme.py'
--- openlp/core/theme/theme.py	2010-06-10 16:36:49 +0000
+++ openlp/core/theme/theme.py	2010-06-14 02:51:27 +0000
@@ -153,8 +153,8 @@
             The data to initialise the theme with
         """
         # init to defaults
-        self._set_from_XML(BLANK_STYLE_XML)
-        self._set_from_XML(xml)
+        self._set_from_xml(BLANK_STYLE_XML)
+        self._set_from_xml(xml)
 
     def _get_as_string(self):
         """
@@ -176,9 +176,9 @@
             The data to apply to the theme
         """
         root = ElementTree(element=XML(xml))
-        iter = root.getiterator()
-        for element in iter:
-            delphiColorChange = False
+        xml_iter = root.getiterator()
+        for element in xml_iter:
+            delphi_color_change = False
             if element.tag != u'Theme':
                 element_text = element.text
                 val = 0
@@ -194,7 +194,7 @@
                             pass
                     elif DELPHI_COLORS.has_key(element_text):
                         val = DELPHI_COLORS[element_text]
-                        delphiColorChange = True
+                        delphi_color_change = True
                     else:
                         try:
                             val = int(element_text)
@@ -204,7 +204,7 @@
                     (element.tag.find(u'BackgroundParameter') == 0 and
                     type(val) == type(0))):
                     # convert to a wx.Colour
-                    if not delphiColorChange:
+                    if not delphi_color_change:
                         val = QtGui.QColor(
                             val&0xFF, (val>>8)&0xFF, (val>>16)&0xFF)
                     else:

=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py	2010-06-10 16:36:49 +0000
+++ openlp/core/ui/servicemanager.py	2010-06-14 02:51:27 +0000
@@ -32,7 +32,7 @@
 
 from PyQt4 import QtCore, QtGui
 
-from openlp.core.lib import OpenLPToolbar, ServiceItem, contextMenuAction, \
+from openlp.core.lib import OpenLPToolbar, ServiceItem, context_menu_action, \
     Receiver, build_icon, ItemCapabilities, SettingsManager, translate
 from openlp.core.ui import ServiceNoteForm, ServiceItemEditForm
 from openlp.core.utils import AppLocation
@@ -954,7 +954,7 @@
         self.ThemeComboBox.addItem(u'')
         for theme in theme_list:
             self.ThemeComboBox.addItem(theme)
-            action = contextMenuAction(
+            action = context_menu_action(
                 self.ServiceManagerList,
                 None,
                 theme , self.onThemeChangeAction)

=== modified file 'openlp/core/ui/thememanager.py'
--- openlp/core/ui/thememanager.py	2010-06-10 19:45:02 +0000
+++ openlp/core/ui/thememanager.py	2010-06-14 02:51:27 +0000
@@ -33,9 +33,9 @@
 
 from openlp.core.ui import AmendThemeForm
 from openlp.core.theme import Theme
-from openlp.core.lib import OpenLPToolbar, contextMenuAction, \
+from openlp.core.lib import OpenLPToolbar, context_menu_action, \
     ThemeXML, str_to_bool, get_text_file_string, build_icon, Receiver, \
-    contextMenuSeparator, SettingsManager, translate
+    context_menu_separator, SettingsManager, translate
 from openlp.core.utils import AppLocation
 
 log = logging.getLogger(__name__)
@@ -81,27 +81,28 @@
         self.Layout.addWidget(self.ThemeListWidget)
         self.ThemeListWidget.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
         self.ThemeListWidget.addAction(
-            contextMenuAction(self.ThemeListWidget, u':/themes/theme_edit.png',
+            context_menu_action(self.ThemeListWidget,
+            u':/themes/theme_edit.png',
             translate(u'ThemeManager', u'Edit a theme'), self.onEditTheme))
         self.ThemeListWidget.addAction(
-            contextMenuSeparator(self.ThemeListWidget))
+            context_menu_separator(self.ThemeListWidget))
         self.ThemeListWidget.addAction(
-            contextMenuAction(self.ThemeListWidget,
+            context_menu_action(self.ThemeListWidget,
                 u':/general/general_delete.png',
                 translate(u'ThemeManager', u'Delete theme'),
             self.onDeleteTheme))
         self.ThemeListWidget.addAction(
-            contextMenuAction(self.ThemeListWidget,
+            context_menu_action(self.ThemeListWidget,
                 u':/general/general_export.png',
                 translate(u'ThemeManager', u'Make Global'),
             self.changeGlobalFromScreen))
         self.ThemeListWidget.addAction(
-            contextMenuAction(self.ThemeListWidget,
+            context_menu_action(self.ThemeListWidget,
                 u':/general/general_export.png',
                 translate(u'ThemeManager', u'Export theme'),
                 self.onExportTheme))
         self.ThemeListWidget.addAction(
-            contextMenuSeparator(self.ThemeListWidget))
+            context_menu_separator(self.ThemeListWidget))
         #Signals
         QtCore.QObject.connect(self.ThemeListWidget,
             QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),

=== modified file 'openlp/plugins/bibles/forms/importwizardform.py'
--- openlp/plugins/bibles/forms/importwizardform.py	2010-06-08 15:38:09 +0000
+++ openlp/plugins/bibles/forms/importwizardform.py	2010-06-14 02:51:27 +0000
@@ -322,8 +322,8 @@
         Load the list of Crosswalk and BibleGateway bibles.
         """
         #Load and store Crosswalk Bibles
-        filepath = AppLocation.get_directory(AppLocation.PluginsDir)
-        filepath = os.path.join(filepath, u'bibles', u'resources')
+        filepath = os.path.join(AppLocation.get_section_data_path(
+            self.bibleplugin.settingsSection), u'resources')
         try:
             self.web_bible_list[WebDownload.Crosswalk] = {}
             books_file = open(

=== modified file 'openlp/plugins/bibles/lib/db.py'
--- openlp/plugins/bibles/lib/db.py	2010-06-10 13:28:41 +0000
+++ openlp/plugins/bibles/lib/db.py	2010-06-14 02:51:27 +0000
@@ -59,6 +59,7 @@
         """
         log.info(u'BibleDB loaded')
         QtCore.QObject.__init__(self)
+        self.bible_plugin = parent
         if u'path' not in kwargs:
             raise KeyError(u'Missing keyword argument "path".')
         if u'name' not in kwargs and u'file' not in kwargs:

=== modified file 'openlp/plugins/bibles/lib/http.py'
--- openlp/plugins/bibles/lib/http.py	2010-06-09 17:09:32 +0000
+++ openlp/plugins/bibles/lib/http.py	2010-06-14 02:51:27 +0000
@@ -56,8 +56,8 @@
         """
         if HTTPBooks.cursor is None:
             filepath = os.path.join(
-                AppLocation.get_directory(AppLocation.PluginsDir), u'bibles',
-                u'resources', u'httpbooks.sqlite')
+                AppLocation.get_section_data_path(u'bibles'), u'resources',
+                u'httpbooks.sqlite')
             conn = sqlite3.connect(filepath)
             HTTPBooks.cursor = conn.cursor()
         return HTTPBooks.cursor
@@ -288,8 +288,7 @@
         ``chapter``
             Chapter number
         """
-        log.debug(u'get_bible_chapter %s,%s,%s',
-            version, bookname, chapter)
+        log.debug(u'get_bible_chapter %s,%s,%s', version, bookname, chapter)
         urlbookname = bookname.replace(u' ', u'-')
         chapter_url = u'http://www.biblestudytools.com/%s/%s/%s.html' % \
             (version, urlbookname.lower(), chapter)

=== modified file 'openlp/plugins/bibles/lib/osis.py'
--- openlp/plugins/bibles/lib/osis.py	2010-06-10 13:28:41 +0000
+++ openlp/plugins/bibles/lib/osis.py	2010-06-14 02:51:27 +0000
@@ -68,9 +68,8 @@
         self.trans_regex = re.compile(r'<transChange(.*?)>(.*?)</transChange>')
         self.spaces_regex = re.compile(r'([ ]{2,})')
         self.books = {}
-        filepath = os.path.join(
-            AppLocation.get_directory(AppLocation.PluginsDir), u'bibles',
-            u'resources', u'osisbooks.csv')
+        filepath = os.path.join(AppLocation.get_section_data_path(
+            self.bible_plugin.settingsSection), u'resources', u'osisbooks.csv')
         fbibles = None
         try:
             fbibles = open(filepath, u'r')

=== modified file 'openlp/plugins/images/lib/mediaitem.py'
--- openlp/plugins/images/lib/mediaitem.py	2010-06-08 15:38:09 +0000
+++ openlp/plugins/images/lib/mediaitem.py	2010-06-14 02:51:27 +0000
@@ -29,7 +29,7 @@
 from PyQt4 import QtCore, QtGui
 
 from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \
-    contextMenuAction, ItemCapabilities, SettingsManager, translate
+    context_menu_action, ItemCapabilities, SettingsManager, translate
 from openlp.core.utils import AppLocation
 
 log = logging.getLogger(__name__)
@@ -54,6 +54,7 @@
         # be instanced by the base MediaManagerItem
         self.ListViewWithDnD_class = ImageListView
         MediaManagerItem.__init__(self, parent, icon, title)
+        self.addToServiceItem = True
 
     def initPluginNameVisible(self):
         self.PluginNameVisible = translate(u'ImagePlugin.MediaItem', u'Image')
@@ -73,7 +74,6 @@
         self.hasFileIcon = True
         self.hasNewIcon = False
         self.hasEditIcon = False
-        self.addToServiceItem = True
 
     def initialise(self):
         log.debug(u'initialise')
@@ -93,7 +93,7 @@
         MediaManagerItem.addListViewToToolBar(self)
         self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
         self.ListView.addAction(
-            contextMenuAction(
+            context_menu_action(
                 self.ListView, u':/slides/slide_blank.png',
                 translate(u'ImagePlugin.MediaItem', u'Replace Live Background'),
                 self.onReplaceClick))

=== modified file 'openlp/plugins/media/lib/mediaitem.py'
--- openlp/plugins/media/lib/mediaitem.py	2010-06-08 15:38:09 +0000
+++ openlp/plugins/media/lib/mediaitem.py	2010-06-14 02:51:27 +0000
@@ -29,7 +29,7 @@
 from PyQt4 import QtCore, QtGui
 
 from openlp.core.lib import MediaManagerItem, BaseListWithDnD, build_icon, \
-    ItemCapabilities, SettingsManager, contextMenuAction, Receiver, translate
+    ItemCapabilities, SettingsManager, context_menu_action, Receiver, translate
 
 log = logging.getLogger(__name__)
 
@@ -77,7 +77,7 @@
         MediaManagerItem.addListViewToToolBar(self)
         self.ListView.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
         self.ListView.addAction(
-            contextMenuAction(self.ListView, u':/slides/slide_blank.png',
+            context_menu_action(self.ListView, u':/slides/slide_blank.png',
                 translate(u'MediaPlugin.MediaItem', u'Replace Live Background'),
                 self.onReplaceClick))
 

=== modified file 'openlp/plugins/songs/lib/manager.py'
--- openlp/plugins/songs/lib/manager.py	2010-06-08 15:38:09 +0000
+++ openlp/plugins/songs/lib/manager.py	2010-06-14 02:51:27 +0000
@@ -96,7 +96,7 @@
         settings = QtCore.QSettings()
         settings.beginGroup(u'songs')
         self.db_url = u''
-        db_type = unicode(settings.value(u'songs/db type',
+        db_type = unicode(settings.value(u'db type',
             QtCore.QVariant(u'sqlite')).toString())
         if db_type == u'sqlite':
             self.db_url = u'sqlite:///%s/songs.sqlite' % \

=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
--- openlp/plugins/songs/lib/mediaitem.py	2010-06-08 15:38:09 +0000
+++ openlp/plugins/songs/lib/mediaitem.py	2010-06-14 02:51:27 +0000
@@ -333,7 +333,7 @@
                 for verse in verseList:
                     verseTag = u'%s:%s' % (
                         verse[0][u'type'], verse[0][u'label'])
-                    service_item.add_from_text(\
+                    service_item.add_from_text(
                         verse[1][:30], unicode(verse[1]), verseTag)
             else:
                 #Loop through the verse list and expand the song accordingly.
@@ -345,8 +345,8 @@
                             verse[0][u'type'][0] == order[0]:
                             verseTag = u'%s:%s' % \
                                 (verse[0][u'type'], verse[0][u'label'])
-                            service_item.add_from_text\
-                                (verse[1][:30], verse[1], verseTag)
+                            service_item.add_from_text(
+                                verse[1][:30], verse[1], verseTag)
         else:
             verses = song.lyrics.split(u'\n\n')
             for slide in verses:


Follow ups