better variable names, fixed translation issues for verse sequences

This commit is contained in:
Mattias Põldaru 2011-02-18 02:48:58 +02:00
parent dff393b6a4
commit aac40357ae
6 changed files with 230 additions and 177 deletions

View File

@ -604,14 +604,14 @@ class SlideController(QtGui.QWidget):
if self.serviceItem.is_text():
if frame[u'verseTag']:
# These tags are already translated.
versetag = frame[u'verseTag']
versetag = u'%s%s' % (versetag[0].upper(), versetag[1:])
twolineTag = u'%s\n%s' % (versetag[0], versetag[1:] )
row = twolineTag
verse_def = frame[u'verseTag']
verse_def = u'%s%s' % (verse_def[0].upper(), verse_def[1:])
two_line_def = u'%s\n%s' % (verse_def[0], verse_def[1:] )
row = two_line_def
if self.isLive:
if versetag not in self.slideList:
self.slideList[versetag] = framenumber
self.songMenu.menu().addAction(versetag,
if verse_def not in self.slideList:
self.slideList[verse_def] = framenumber
self.songMenu.menu().addAction(verse_def,
self.onSongBarHandler)
else:
row += 1

View File

@ -227,17 +227,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.copyrightEdit.setText(u'')
self.verseListWidget.clear()
self.verseListWidget.setRowCount(0)
if self.song.verse_order:
# we translate verse order
translated = []
for versetag in self.song.verse_order.split():
verseindex = VerseType.from_tag(versetag[0])
versetype = VerseType.TranslatedTags[verseindex]
versenum = versetag[1:]
translated.append(u'%s%s' % (versetype.upper(), versenum))
self.verseOrderEdit.setText(u' '.join(translated))
else:
self.verseOrderEdit.setText(u'')
if self.song.comments:
self.commentsEdit.setPlainText(self.song.comments)
else:
@ -257,6 +246,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
# This is just because occasionally the lyrics come back as a "buffer"
if isinstance(self.song.lyrics, buffer):
self.song.lyrics = unicode(self.song.lyrics)
verse_tags_translated = False
if self.song.lyrics.startswith(u'<?xml version='):
songXML = SongXML()
verseList = songXML.get_verses(self.song.lyrics)
@ -265,20 +255,22 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.verseListWidget.rowCount() + 1)
# This silently migrates from localized verse type markup.
# If we trusted the database, this would be unnecessary.
vtype = verse[0][u'type']
verse_tag = verse[0][u'type']
index = None
if len(vtype) > 1:
index = VerseType.from_translated_string(vtype)
if len(verse_tag) > 1:
index = VerseType.from_translated_string(verse_tag)
if index is None:
index = VerseType.from_string(vtype)
index = VerseType.from_string(verse_tag)
else:
verse_tags_translated = True
if index is None:
index = VerseType.from_tag(vtype)
index = VerseType.from_tag(verse_tag)
if index is None:
index = VerseType.Other
verse[0][u'type'] = VerseType.Tags[index]
variant = u'%s%s' % (verse[0][u'type'], verse[0][u'label'])
verse_def = u'%s%s' % (verse[0][u'type'], verse[0][u'label'])
item = QtGui.QTableWidgetItem(verse[1])
item.setData(QtCore.Qt.UserRole, QtCore.QVariant(variant))
item.setData(QtCore.Qt.UserRole, QtCore.QVariant(verse_def))
self.verseListWidget.setItem(count, 0, item)
else:
verses = self.song.lyrics.split(u'\n\n')
@ -286,10 +278,24 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
self.verseListWidget.setRowCount(
self.verseListWidget.rowCount() + 1)
item = QtGui.QTableWidgetItem(verse)
variant = u'%s:%s' % \
verse_def = u'%s%s' % \
(VerseType.Tags[VerseType.Verse], unicode(count + 1))
item.setData(QtCore.Qt.UserRole, QtCore.QVariant(variant))
item.setData(QtCore.Qt.UserRole, QtCore.QVariant(verse_def))
self.verseListWidget.setItem(count, 0, item)
if self.song.verse_order:
# we translate verse order
translated = []
for verse_def in self.song.verse_order.split():
verse_index = None
if verse_tags_translated:
verse_index = VerseType.from_translated_tag(verse_def[0])
if verse_index is None:
verse_index = VerseType.from_tag(verse_def[0])
verse_tag = VerseType.TranslatedTags[verse_index].upper()
translated.append(u'%s%s' % (verse_tag, verse_def[1:]))
self.verseOrderEdit.setText(u' '.join(translated))
else:
self.verseOrderEdit.setText(u'')
self.verseListWidget.resizeRowsToContents()
self.tagRows()
# clear the results
@ -314,15 +320,14 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
"""
Tag the Song List rows based on the verse list
"""
rowLabel = []
row_label = []
for row in range(0, self.verseListWidget.rowCount()):
item = self.verseListWidget.item(row, 0)
versetag = unicode(item.data(QtCore.Qt.UserRole).toString())
versetype = VerseType.TranslatedTags[
VerseType.from_tag(versetag[0])].upper()
rowTag = u'%s%s' % (versetype, versetag[1:])
rowLabel.append(rowTag)
self.verseListWidget.setVerticalHeaderLabels(rowLabel)
verse_def = unicode(item.data(QtCore.Qt.UserRole).toString())
verse_tag = VerseType.translated_tag(verse_def[0])
row_def = u'%s%s' % (verse_tag, verse_def[1:])
row_label.append(row_def)
self.verseListWidget.setVerticalHeaderLabels(row_label)
def onAuthorAddButtonClicked(self):
item = int(self.authorsComboBox.currentIndex())
@ -441,11 +446,11 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
def onVerseAddButtonClicked(self):
self.verse_form.setVerse(u'', True)
if self.verse_form.exec_():
afterText, versetype, versenum = self.verse_form.getVerse()
versetag = u'%s%s' % (versetype, versenum)
after_text, verse_tag, verse_num = self.verse_form.getVerse()
verse_def = u'%s%s' % (verse_tag, verse_num)
item = QtGui.QTableWidgetItem(afterText)
item.setData(QtCore.Qt.UserRole, QtCore.QVariant(versetag))
item.setText(afterText)
item.setData(QtCore.Qt.UserRole, QtCore.QVariant(verse_def))
item.setText(after_text)
self.verseListWidget.setRowCount(
self.verseListWidget.rowCount() + 1)
self.verseListWidget.setItem(
@ -461,12 +466,12 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
verseId = unicode(item.data(QtCore.Qt.UserRole).toString())
self.verse_form.setVerse(tempText, True, verseId)
if self.verse_form.exec_():
afterText, versetype, versenum = self.verse_form.getVerse()
versetag = u'%s%s' % (versetype, versenum)
item.setData(QtCore.Qt.UserRole, QtCore.QVariant(versetag))
item.setText(afterText)
after_text, verse_tag, verse_num = self.verse_form.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 change so repaint the list moving the data
if len(tempText.split(u'\n')) != len(afterText.split(u'\n')):
if len(tempText.split(u'\n')) != len(after_text.split(u'\n')):
tempList = {}
tempId = {}
for row in range(0, self.verseListWidget.rowCount()):
@ -488,10 +493,9 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
for row in range(0, self.verseListWidget.rowCount()):
item = self.verseListWidget.item(row, 0)
field = unicode(item.data(QtCore.Qt.UserRole).toString())
versetypeindex = VerseType.from_tag(field[0])
versetype = VerseType.TranslatedNames[versetypeindex]
versenum = field[1:]
verse_list += u'---[%s:%s]---\n' % (versetype, versenum)
verse_tag = VerseType.translated_name(field[0])
verse_num = field[1:]
verse_list += u'---[%s:%s]---\n' % (verse_tag, verse_num)
verse_list += item.text()
verse_list += u'\n'
self.verse_form.setVerse(verse_list)
@ -510,31 +514,29 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
# handling carefully user inputted versetags
separator = parts.find(u':')
if separator >= 0:
versetype = parts[0:separator].strip()
versenum = parts[separator+1:].strip()
verse_name = parts[0:separator].strip()
verse_num = parts[separator+1:].strip()
else:
versetype = parts
versenum = u'1'
verseindex = \
VerseType.from_loose_input(versetype)
if verseindex is None:
verseindex = VerseType.Verse
versetype = VerseType.Tags[verseindex]
verse_name = parts
verse_num = u'1'
verse_index = \
VerseType.from_loose_input(verse_name)
verse_tag = VerseType.Tags[verse_index]
# Later we need to handle v1a as well.
#regex = re.compile(r'(\d+\w.)')
regex = re.compile(r'\D*(\d+)\D*')
match = regex.match(versenum)
match = regex.match(verse_num)
if match:
versenum = match.group(1)
verse_num = match.group(1)
else:
versenum = u'1'
variant = u'%s%s' % (versetype, versenum)
verse_num = u'1'
verse_def = u'%s%s' % (verse_tag, verse_num)
else:
if parts.endswith(u'\n'):
parts = parts.rstrip(u'\n')
item = QtGui.QTableWidgetItem(parts)
item.setData(QtCore.Qt.UserRole,
QtCore.QVariant(variant))
QtCore.QVariant(verse_def))
self.verseListWidget.setRowCount(
self.verseListWidget.rowCount() + 1)
self.verseListWidget.setItem(
@ -586,29 +588,31 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
order_names = unicode(self.verseOrderEdit.text()).split()
for item in order_names:
if len(item) == 1:
order.append(VerseType.Tags[VerseType.from_translated_tag(
item)] + u'1')
verse_index = VerseType.from_translated_tag(item)
if verse_index is not None:
order.append(VerseType.Tags[verse_index] + u'1')
else:
versetag = VerseType.Tags[
VerseType.from_translated_tag(item[0])]
versenum = item[1:].lower()
order.append(u'%s%s' % (versetag, versenum))
order.append(u'') # it matches no verses anyway
else:
verse_index = VerseType.from_translated_tag(item[0])
if verse_index is None:
order.append(u'') # same as above
else:
verse_tag = VerseType.Tags[verse_index]
verse_num = item[1:].lower()
order.append(verse_tag + verse_num)
verses = []
verse_names = []
for index in range(0, self.verseListWidget.rowCount()):
verse = self.verseListWidget.item(index, 0)
verse = unicode(verse.data(QtCore.Qt.UserRole).toString())
if verse not in verse_names:
verses.append(
re.sub(r'(.)[^:]*:(.*)', r'\1\2', verse.lower()))
verse_names.append(verse)
verses.append(verse)
verse_names.append(u'%s%s' % (
VerseType.translated_tag(verse[0]), verse[1:]))
for count, item in enumerate(order):
if item not in verses:
self.songTabWidget.setCurrentIndex(0)
self.verseOrderEdit.setFocus()
valid = verses.pop(0)
for verse in verses:
valid = valid + u', ' + verse.upper()
valid = u', '.join(verse_names)
critical_error_message_box(
message=unicode(translate('SongsPlugin.EditSongForm',
'The verse order is invalid. There is no verse '
@ -619,17 +623,12 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
if verse not in order:
self.songTabWidget.setCurrentIndex(0)
self.verseOrderEdit.setFocus()
versetype = verse_names[count][0]
versenum = verse_names[count][1:]
verseindex = VerseType.from_tag(versetype)
versetype = VerseType.TranslatedTags[verseindex].upper()
versename = u'%s%s' % (versetype, versenum)
answer = QtGui.QMessageBox.warning(self,
translate('SongsPlugin.EditSongForm', 'Warning'),
unicode(translate('SongsPlugin.EditSongForm',
'You have not used %s anywhere in the verse '
'order. Are you sure you want to save the song '
'like this?')) % versename,
'like this?')) % verse_names[count],
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
if answer == QtGui.QMessageBox.No:
return False
@ -739,10 +738,10 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
ordertext = unicode(self.verseOrderEdit.text())
order = []
for item in ordertext.split():
versetag = VerseType.Tags[
verse_tag = VerseType.Tags[
VerseType.from_translated_tag(item[0])]
versenum = item[1:].lower()
order.append(u'%s%s' % (versetag, versenum))
verse_num = item[1:].lower()
order.append(u'%s%s' % (verse_tag, verse_num))
self.song.verse_order = u' '.join(order)
self.song.ccli_number = unicode(self.CCLNumberEdit.text())
self.song.song_number = unicode(self.songBookNumberEdit.text())
@ -786,14 +785,14 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog):
for i in range(0, self.verseListWidget.rowCount()):
item = self.verseListWidget.item(i, 0)
verseId = unicode(item.data(QtCore.Qt.UserRole).toString())
versetype = verseId[0]
versenum = verseId[1:]
sxml.add_verse_to_lyrics(versetype, versenum,
verse_tag = verseId[0]
verse_num = verseId[1:]
sxml.add_verse_to_lyrics(verse_type, verse_num,
unicode(item.text()))
text = text + self.whitespace.sub(u' ',
unicode(self.verseListWidget.item(i, 0).text())) + u' '
if (versenum > u'1') and (versetype not in multiple):
multiple.append(versetype)
if (verse_num > u'1') and (verse_tag not in multiple):
multiple.append(verse_tag)
self.song.search_lyrics = text.lower()
self.song.lyrics = unicode(sxml.extract_xml(), u'utf-8')
for verse in multiple:

View File

@ -57,22 +57,22 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
QtCore.QObject.connect(self.verseTypeComboBox,
QtCore.SIGNAL(u'currentIndexChanged(int)'),
self.onVerseTypeComboBoxChanged)
self.verse_regex = re.compile(r'---\[(.+):\D*(\d+)\D*\]---')
self.verse_regex = re.compile(r'---\[(.+):\D*(\d.)\D*\]---')
def contextMenu(self, point):
item = self.serviceManagerList.itemAt(point)
def insertVerse(self, versetype, num=1):
def insertVerse(self, verse_tag, verse_num=1):
if self.verseTextEdit.textCursor().columnNumber() != 0:
self.verseTextEdit.insertPlainText(u'\n')
versetype = VerseType.TranslatedNames[VerseTag.from_tag(versetype)]
self.verseTextEdit.insertPlainText(u'---[%s:%s]---\n' % \
(versetype, num))
verse_tag = VerseType.translated_name(verse_tag)
self.verseTextEdit.insertPlainText(u'---[%s:%s]---\n' %
(verse_tag, verse_num))
self.verseTextEdit.setFocus()
def onInsertButtonClicked(self):
vtypeindex = self.verseTypeComboBox.currentIndex()
self.insertVerse(VerseType.Tags[vtypeindex],
verse_type_index = self.verseTypeComboBox.currentIndex()
self.insertVerse(VerseType.Tags[verse_type_index],
self.verseNumberBox.value())
def onVerseTypeComboBoxChanged(self):
@ -82,11 +82,11 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
"""
position = self.verseTextEdit.textCursor().position()
text = unicode(self.verseTextEdit.toPlainText())
verse_type = VerseType.TranslatedNames[
verse_name = VerseType.TranslatedNames[
self.verseTypeComboBox.currentIndex()]
if not text:
return
position = text.rfind(u'---[%s' % verse_type, 0, position)
position = text.rfind(u'---[%s' % verse_name, 0, position)
if position == -1:
self.verseNumberBox.setValue(1)
return
@ -97,11 +97,11 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
text = text[:position + 4]
match = self.verse_regex.match(text)
if match:
verse_type = match.group(1)
verse_number = int(match.group(2))
verse_type_index = VerseType.from_loose_input(verse_type)
verse_tag = match.group(1)
verse_num = int(match.group(2))
verse_type_index = VerseType.from_loose_input(verse_tag)
if verse_type_index is not None:
self.verseNumberBox.setValue(verse_number)
self.verseNumberBox.setValue(verse_num)
def onCursorPositionChanged(self):
"""
@ -125,13 +125,13 @@ class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
text = text[:position + 4]
match = self.verse_regex.match(text)
if match:
versetype = match.group(1)
vtypeindex = VerseType.from_loose_input(versetype)
verse_type = match.group(1)
verse_type_index = VerseType.from_loose_input(verse_type)
regex = re.compile(r'(\d+)')
versenum = int(match.group(2))
if vtypeindex is not None:
self.verseTypeComboBox.setCurrentIndex(vtypeindex)
self.verseNumberBox.setValue(versenum)
verse_num = int(match.group(2))
if verse_type_index is not None:
self.verseTypeComboBox.setCurrentIndex(verse_type_index)
self.verseNumberBox.setValue(verse_num)
def setVerse(self, text, single=False,
tag=u'%s1' % VerseType.Tags[VerseType.Verse]):

View File

@ -48,9 +48,7 @@ class VerseType(object):
u'Intro',
u'Ending',
u'Other']
Tags = []
for name in Names:
Tags.append(name[0].lower())
Tags = [name[0].lower() for name in Names]
TranslatedNames = [
unicode(translate('SongsPlugin.VerseType', 'Verse')),
@ -60,80 +58,129 @@ class VerseType(object):
unicode(translate('SongsPlugin.VerseType', 'Intro')),
unicode(translate('SongsPlugin.VerseType', 'Ending')),
unicode(translate('SongsPlugin.VerseType', 'Other'))]
TranslatedTags = []
for name in TranslatedNames:
TranslatedTags.append(name[0].lower())
TranslatedTags = [name[0].lower() for name in TranslatedNames]
@staticmethod
def from_tag(verse_type):
def translated_tag(verse_tag, strict=False):
"""
Return the translated UPPERCASE tag for a given tag,
used to show translated verse tags in UI
``verse_tag``
The string to return a VerseType for
``strict``
Determines if the default Other or None should be returned
"""
if strict:
not_found_value = None
else:
not_found_value = VerseType.TranslatedTags[VerseType.Other].upper()
verse_tag = verse_tag[0].lower()
for num, tag in enumerate(VerseType.Tags):
if verse_tag == tag:
return VerseType.TranslatedTags[num].upper()
return not_found_value
@staticmethod
def translated_name(verse_tag, strict=False):
"""
Return the translated name for a given tag
``verse_tag``
The string to return a VerseType for
``strict``
Determines if the default Other or None should be returned
"""
if strict:
not_found_value = None
else:
not_found_value = VerseType.TranslatedNames[VerseType.Other]
verse_tag = verse_tag[0].lower()
for num, tag in enumerate(VerseType.Tags):
if verse_tag == tag:
return VerseType.TranslatedNames[num]
return not_found_value
@staticmethod
def from_tag(verse_tag, strict=False):
"""
Return the VerseType for a given tag
``verse_type``
``verse_tag``
The string to return a VerseType for
``strict``
Determines if the default Other or None should be returned
"""
if strict:
no_return_value = None
else:
no_return_value = VerseType.Other
verse_tag = verse_tag[0].lower()
for num, tag in enumerate(VerseType.Tags):
if verse_tag == tag:
return num
return no_return_value
@staticmethod
def from_translated_tag(verse_tag):
"""
Return the VerseType for a given tag
``verse_tag``
The string to return a VerseType for
"""
verse_type = verse_type[0].lower()
for num, string in enumerate(VerseType.Tags):
if verse_type == string:
verse_tag = verse_tag[0].lower()
for num, tag in enumerate(VerseType.TranslatedTags):
if verse_tag == tag:
return num
@staticmethod
def from_translated_tag(verse_type):
"""
Return the VerseType for a given tag
``verse_type``
The string to return a VerseType for
"""
verse_type = verse_type[0].lower()
for vtypeIndex, vtypeTag in enumerate(VerseType.TranslatedTags):
if verse_type == vtypeTag:
return vtypeIndex
@staticmethod
def from_string(verse_type):
def from_string(verse_name):
"""
Return the VerseType for a given string
``verse_type``
``verse_name``
The string to return a VerseType for
"""
verse_type = verse_type.lower()
for vtypeIndex, vtypeName in enumerate(VerseType.Names):
if verse_type == vtypeName.lower():
return vtypeIndex
verse_name = verse_name.lower()
for num, name in enumerate(VerseType.Names):
if verse_name == name.lower():
return num
@staticmethod
def from_translated_string(verse_type):
def from_translated_string(verse_name):
"""
Return the VerseType for a given string
``verse_type``
``verse_name``
The string to return a VerseType for
"""
verse_type = verse_type.lower()
verse_name = verse_name.lower()
for num, translation in enumerate(VerseType.TranslatedNames):
if verse_type == translation.lower():
if verse_name == translation.lower():
return num
@staticmethod
def from_loose_input(verse_type):
def from_loose_input(verse_name):
"""
Return the VerseType for a given string, Other if not found
``verse_type``
``verse_name``
The string to return a VerseType for
"""
verseIndex = None
if len(verse_type) > 1:
verseIndex = VerseType.from_translated_string(verse_type)
if verseIndex is None:
verseIndex = VerseType.from_string(verse_type)
if verseIndex is None:
verseIndex = VerseType.from_translated_tag(verse_type)
elif verseIndex is None:
verseIndex = VerseType.from_tag(verse_type)
return verseIndex
verse_index = None
if len(verse_name) > 1:
verse_index = VerseType.from_translated_string(verse_name)
if verse_index is None:
verseIndex = VerseType.from_string(verse_name)
if verse_index is None:
verse_index = VerseType.from_translated_tag(verse_name)
elif verse_index is None:
verse_index = VerseType.from_tag(verse_name)
return verse_index
def retrieve_windows_encoding(recommendation=None):
"""

View File

@ -344,40 +344,49 @@ class SongMediaItem(MediaManagerItem):
if song.lyrics.startswith(u'<?xml version='):
verseList = 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_tags_translated = True
if not song.verse_order.strip():
for verse in verseList:
# We cannot use from_loose_input() here, because database
# is supposed to contain English lowercase singlechar tags.
verse_type = verse[0][u'type']
verseIndex = None
if len(verse_type) > 1:
verseIndex = \
VerseType.from_translated_string(verse_type)
if verseIndex is None:
verseIndex = VerseType.from_string(verse_type)
if verseIndex is None:
verseIndex = VerseType.from_tag(verse_type)
if verseIndex is None:
verseIndex = VerseType.Other
versetype = VerseType.TranslatedTags[verseIndex].upper()
verseTag = u'%s%s' % (versetype, verse[0][u'label'])
verse_tag = verse[0][u'type']
verse_index = None
if len(verse_tag) > 1:
verse_index = \
VerseType.from_translated_string(verse_tag)
if verse_index is None:
verse_index = VerseType.from_string(verse_tag)
if verse_index is None:
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]), verseTag)
verse[1][:30], 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 len(order) == 0:
break
for verse in verseList:
if verse[0][u'type'][0] == order[0] and \
(verse[0][u'label'] == order[1:] or not order[1:]):
verseindex = VerseType.from_tag(verse[0][u'type'])
versetype = VerseType.TranslatedTags[verseindex]\
.upper()
verseTag = u'%s%s' % (versetype,
if verse[0][u'type'][0].lower() == order[0] and \
(verse[0][u'label'].lower() == order[1:] or \
not order[1:]):
if verse_tags_translated:
verse_index = VerseType.from_translated_tag(
verse[0][u'type'])
else:
verse_index = VerseType.from_tag(
verse[0][u'type'])
if verse_index is None:
verse_index = VerseType.Other
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], verseTag)
verse[1][:30], verse[1], verse_def)
else:
verses = song.lyrics.split(u'\n\n')
for slide in verses:

View File

@ -465,8 +465,6 @@ class OpenLyrics(object):
text += u'\n'.join([unicode(line) for line in lines.line])
verse_name = self._get(verse, u'name')
verse_type_index = VerseType.from_tag(verse_name[0])
if verse_type_index is None:
verse_type_index = VerseType.Other
verse_type = VerseType.Names[verse_type_index]
verse_number = re.compile(u'[a-zA-Z]*').sub(u'', verse_name)
verse_part = re.compile(u'[0-9]*').sub(u'', verse_name[1:])