openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #16032
[Merge] lp:~googol/openlp/trivial into lp:openlp
Andreas Preikschat has proposed merging lp:~googol/openlp/trivial into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
For more details, see:
https://code.launchpad.net/~googol/openlp/trivial/+merge/110663
Hello,
Various clean ups:
- refactor method argument
- some variable name fixes
- converted dict to list
- added missing lines
--
https://code.launchpad.net/~googol/openlp/trivial/+merge/110663
Your team OpenLP Core is requested to review the proposed merge of lp:~googol/openlp/trivial into lp:openlp.
=== modified file 'openlp/core/lib/renderer.py'
--- openlp/core/lib/renderer.py 2012-06-09 15:46:01 +0000
+++ openlp/core/lib/renderer.py 2012-06-16 16:14:20 +0000
@@ -234,10 +234,10 @@
serviceItem = ServiceItem()
if self.force_page:
# make big page for theme edit dialog to get line count
- serviceItem.add_from_text(u'', VERSE_FOR_LINE_COUNT)
+ serviceItem.add_from_text(VERSE_FOR_LINE_COUNT)
else:
self.image_manager.deleteImage(theme_data.theme_name)
- serviceItem.add_from_text(u'', VERSE)
+ serviceItem.add_from_text(VERSE)
serviceItem.renderer = self
serviceItem.raw_footer = FOOTER
# if No file do not update cache
=== modified file 'openlp/core/lib/serviceitem.py'
--- openlp/core/lib/serviceitem.py 2012-06-04 10:51:50 +0000
+++ openlp/core/lib/serviceitem.py 2012-06-16 16:14:20 +0000
@@ -220,20 +220,17 @@
self.image_border)
self._new_item()
- def add_from_text(self, title, raw_slide, verse_tag=None):
+ def add_from_text(self, raw_slide, verse_tag=None):
"""
Add a text slide to the service item.
- ``frame_title``
- The title of the slide in the service item.
-
``raw_slide``
The raw text of the slide.
"""
if verse_tag:
verse_tag = verse_tag.upper()
self.service_item_type = ServiceItemType.Text
- title = title.split(u'\n')[0]
+ title = raw_slide[:30].split(u'\n')[0]
self._raw_frames.append(
{u'title': title, u'raw_slide': raw_slide, u'verseTag': verse_tag})
self._new_item()
=== modified file 'openlp/plugins/bibles/bibleplugin.py'
--- openlp/plugins/bibles/bibleplugin.py 2012-05-11 12:22:34 +0000
+++ openlp/plugins/bibles/bibleplugin.py 2012-06-16 16:14:20 +0000
@@ -63,8 +63,7 @@
# unicode(UiStrings().Export))
# Set to invisible until we can export bibles
self.exportBibleItem.setVisible(False)
- if self.manager.old_bible_databases:
- self.toolsUpgradeItem.setVisible(True)
+ self.toolsUpgradeItem.setVisible(bool(self.manager.old_bible_databases))
def finalise(self):
"""
=== modified file 'openlp/plugins/bibles/lib/db.py'
--- openlp/plugins/bibles/lib/db.py 2012-04-22 18:19:36 +0000
+++ openlp/plugins/bibles/lib/db.py 2012-06-16 16:14:20 +0000
@@ -63,6 +63,7 @@
"""
pass
+
def init_schema(url):
"""
Setup a bible database connection and initialise the database schema.
=== modified file 'openlp/plugins/bibles/lib/mediaitem.py'
--- openlp/plugins/bibles/lib/mediaitem.py 2012-05-21 03:06:17 +0000
+++ openlp/plugins/bibles/lib/mediaitem.py 2012-06-16 16:14:20 +0000
@@ -418,7 +418,7 @@
``bible``
The bible to initialise (unicode).
-
+
``last_book_id``
The "book reference id" of the book which is choosen at the moment.
(int)
@@ -976,7 +976,7 @@
else:
service_item.theme = self.settings.bible_theme
for slide in raw_slides:
- service_item.add_from_text(slide[:30], slide)
+ service_item.add_from_text(slide)
return True
def formatTitle(self, start_bitem, old_bitem):
=== modified file 'openlp/plugins/custom/lib/mediaitem.py'
--- openlp/plugins/custom/lib/mediaitem.py 2012-06-09 23:14:28 +0000
+++ openlp/plugins/custom/lib/mediaitem.py 2012-06-16 16:14:20 +0000
@@ -210,12 +210,12 @@
theme = customSlide.theme_name
if theme:
service_item.theme = theme
- customXML = CustomXMLParser(customSlide.text)
- verseList = customXML.get_verses()
- raw_slides = [verse[1] for verse in verseList]
+ custom_xml = CustomXMLParser(customSlide.text)
+ verse_list = custom_xml.get_verses()
+ raw_slides = [verse[1] for verse in verse_list]
service_item.title = title
for slide in raw_slides:
- service_item.add_from_text(slide[:30], slide)
+ service_item.add_from_text(slide)
if Settings().value(self.settingsSection + u'/display footer',
QtCore.QVariant(True)).toBool() or credit:
service_item.raw_footer.append(u' '.join([title, credit]))
=== modified file 'openlp/plugins/songs/forms/authorsform.py'
--- openlp/plugins/songs/forms/authorsform.py 2011-12-27 10:33:55 +0000
+++ openlp/plugins/songs/forms/authorsform.py 2012-06-16 16:14:20 +0000
@@ -57,19 +57,17 @@
self.firstNameEdit.setFocus()
return QtGui.QDialog.exec_(self)
- def onFirstNameEditTextEdited(self, text):
+ def onFirstNameEditTextEdited(self, display_name):
if not self._autoDisplayName:
return
- display_name = text
- if self.lastNameEdit.text() != u'':
+ if not self.lastNameEdit.text():
display_name = display_name + u' ' + self.lastNameEdit.text()
self.displayEdit.setText(display_name)
- def onLastNameEditTextEdited(self, text):
+ def onLastNameEditTextEdited(self, display_name):
if not self._autoDisplayName:
return
- display_name = text
- if self.firstNameEdit.text() != u'':
+ if not self.firstNameEdit.text():
display_name = self.firstNameEdit.text() + u' ' + display_name
self.displayEdit.setText(display_name)
=== modified file 'openlp/plugins/songs/forms/editsongform.py'
--- openlp/plugins/songs/forms/editsongform.py 2012-06-09 15:46:01 +0000
+++ openlp/plugins/songs/forms/editsongform.py 2012-06-16 16:14:20 +0000
@@ -256,8 +256,8 @@
verse_tags_translated = False
if self.song.lyrics.startswith(u'<?xml version='):
songXML = SongXML()
- verseList = songXML.get_verses(self.song.lyrics)
- for count, verse in enumerate(verseList):
+ verse_list = songXML.get_verses(self.song.lyrics)
+ for count, verse in enumerate(verse_list):
self.verseListWidget.setRowCount(
self.verseListWidget.rowCount() + 1)
# This silently migrates from localized verse type markup.
@@ -479,27 +479,26 @@
def onVerseEditButtonClicked(self):
item = self.verseListWidget.currentItem()
if item:
- tempText = item.text()
- verseId = unicode(item.data(QtCore.Qt.UserRole).toString())
- self.verseForm.setVerse(tempText, True, verseId)
+ temp_text = item.text()
+ verse_id = unicode(item.data(QtCore.Qt.UserRole).toString())
+ self.verseForm.setVerse(temp_text, True, verse_id)
if self.verseForm.exec_():
after_text, verse_tag, verse_num = self.verseForm.getVerse()
verse_def = u'%s%s' % (verse_tag, verse_num)
item.setData(QtCore.Qt.UserRole, QtCore.QVariant(verse_def))
item.setText(after_text)
# number of lines has changed, repaint the list moving the data
- if len(tempText.split(u'\n')) != len(after_text.split(u'\n')):
- tempList = {}
- tempId = {}
+ if len(temp_text.split(u'\n')) != len(after_text.split(u'\n')):
+ temp_list = []
+ temp_ids = []
for row in range(self.verseListWidget.rowCount()):
- tempList[row] = self.verseListWidget.item(row, 0)\
- .text()
- tempId[row] = self.verseListWidget.item(row, 0)\
- .data(QtCore.Qt.UserRole)
+ item = self.verseListWidget.item(row, 0)
+ temp_list.append(item.text())
+ temp_ids.append(item.data(QtCore.Qt.UserRole))
self.verseListWidget.clear()
- for row in range (0, len(tempList)):
- item = QtGui.QTableWidgetItem(tempList[row], 0)
- item.setData(QtCore.Qt.UserRole, tempId[row])
+ for row, entry in enumerate(temp_list):
+ item = QtGui.QTableWidgetItem(entry, 0)
+ item.setData(QtCore.Qt.UserRole, temp_ids[row])
self.verseListWidget.setItem(row, 0, item)
self.tagRows()
# Check if all verse tags are used.
@@ -923,9 +922,9 @@
multiple = []
for i in range(self.verseListWidget.rowCount()):
item = self.verseListWidget.item(i, 0)
- verseId = unicode(item.data(QtCore.Qt.UserRole).toString())
- verse_tag = verseId[0]
- verse_num = verseId[1:]
+ verse_id = unicode(item.data(QtCore.Qt.UserRole).toString())
+ verse_tag = verse_id[0]
+ verse_num = verse_id[1:]
sxml.add_verse_to_lyrics(verse_tag, verse_num,
unicode(item.text()))
if verse_num > u'1' and verse_tag not in multiple:
=== modified file 'openlp/plugins/songs/lib/__init__.py'
--- openlp/plugins/songs/lib/__init__.py 2012-04-29 15:31:56 +0000
+++ openlp/plugins/songs/lib/__init__.py 2012-06-16 16:14:20 +0000
@@ -193,6 +193,7 @@
return default
return verse_index
+
def retrieve_windows_encoding(recommendation=None):
"""
Determines which encoding to use on an information source. The process uses
@@ -252,12 +253,14 @@
return None
return filter(lambda item: item[1] == choice[0], encodings)[0][0]
+
def clean_string(string):
"""
Strips punctuation from the passed string to assist searching
"""
return WHITESPACE.sub(u' ', APOSTROPHE.sub(u'', string)).lower()
+
def clean_title(title):
"""
Cleans the song title by removing Unicode control chars groups C0 & C1,
@@ -265,6 +268,7 @@
"""
return CONTROL_CHARS.sub(u'', title).rstrip()
+
def clean_song(manager, song):
"""
Cleans the search title, rebuilds the search lyrics, adds a default author
=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
--- openlp/plugins/songs/lib/mediaitem.py 2012-05-11 12:22:34 +0000
+++ openlp/plugins/songs/lib/mediaitem.py 2012-06-16 16:14:20 +0000
@@ -465,14 +465,14 @@
service_item.theme = song.theme_name
service_item.edit_id = item_id
if song.lyrics.startswith(u'<?xml version='):
- verseList = SongXML().get_verses(song.lyrics)
+ verse_list = SongXML().get_verses(song.lyrics)
# no verse list or only 1 space (in error)
verse_tags_translated = False
if VerseType.from_translated_string(unicode(
- verseList[0][0][u'type'])) is not None:
+ verse_list[0][0][u'type'])) is not None:
verse_tags_translated = True
if not song.verse_order.strip():
- for verse in verseList:
+ for verse in verse_list:
# We cannot use from_loose_input() here, because database
# is supposed to contain English lowercase singlechar tags.
verse_tag = verse[0][u'type']
@@ -486,14 +486,13 @@
verse_index = VerseType.from_tag(verse_tag)
verse_tag = VerseType.TranslatedTags[verse_index].upper()
verse_def = u'%s%s' % (verse_tag, verse[0][u'label'])
- service_item.add_from_text(
- verse[1][:30], unicode(verse[1]), verse_def)
+ service_item.add_from_text(unicode(verse[1]), verse_def)
else:
# Loop through the verse list and expand the song accordingly.
for order in song.verse_order.lower().split():
if not order:
break
- for verse in verseList:
+ for verse in verse_list:
if verse[0][u'type'][0].lower() == order[0] and \
(verse[0][u'label'].lower() == order[1:] or \
not order[1:]):
@@ -506,12 +505,11 @@
verse_tag = VerseType.TranslatedTags[verse_index]
verse_def = u'%s%s' % (verse_tag,
verse[0][u'label'])
- service_item.add_from_text(
- verse[1][:30], verse[1], verse_def)
+ service_item.add_from_text(verse[1], verse_def)
else:
verses = song.lyrics.split(u'\n\n')
for slide in verses:
- service_item.add_from_text(slide[:30], unicode(slide))
+ service_item.add_from_text(unicode(slide))
service_item.title = song.title
author_list = [unicode(author.display_name) for author in song.authors]
service_item.raw_footer.append(song.title)