openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #12856
[Merge] lp:~m2j/openlp/work into lp:openlp
m2j has proposed merging lp:~m2j/openlp/work into lp:openlp.
Requested reviews:
Tim Bentley (trb143)
For more details, see:
https://code.launchpad.net/~m2j/openlp/work/+merge/83350
Bug #875286
use VerseType.Other if it is not recogniced during OpenSong import.
--
https://code.launchpad.net/~m2j/openlp/work/+merge/83350
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/plugins/songs/forms/editsongform.py'
--- openlp/plugins/songs/forms/editsongform.py 2011-09-22 20:07:31 +0000
+++ openlp/plugins/songs/forms/editsongform.py 2011-11-24 22:44:26 +0000
@@ -278,13 +278,11 @@
if len(verse_tag) > 1:
index = VerseType.from_translated_string(verse_tag)
if index is None:
- index = VerseType.from_string(verse_tag)
+ index = VerseType.from_string(verse_tag, None)
else:
verse_tags_translated = True
if index is None:
index = VerseType.from_tag(verse_tag)
- if index is None:
- index = VerseType.Other
verse[0][u'type'] = VerseType.Tags[index]
if verse[0][u'label'] == u'':
verse[0][u'label'] = u'1'
@@ -308,7 +306,8 @@
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])
+ verse_index = VerseType.from_translated_tag(verse_def[0],
+ None)
if verse_index is None:
verse_index = VerseType.from_tag(verse_def[0])
verse_tag = VerseType.TranslatedTags[verse_index].upper()
@@ -606,14 +605,14 @@
order_names = unicode(self.verseOrderEdit.text()).split()
for item in order_names:
if len(item) == 1:
- verse_index = VerseType.from_translated_tag(item)
+ verse_index = VerseType.from_translated_tag(item, None)
if verse_index is not None:
order.append(VerseType.Tags[verse_index] + u'1')
else:
# it matches no verses anyway
order.append(u'')
else:
- verse_index = VerseType.from_translated_tag(item[0])
+ verse_index = VerseType.from_translated_tag(item[0], None)
if verse_index is None:
# it matches no verses anyway
order.append(u'')
=== modified file 'openlp/plugins/songs/forms/editverseform.py'
--- openlp/plugins/songs/forms/editverseform.py 2011-07-13 13:32:19 +0000
+++ openlp/plugins/songs/forms/editverseform.py 2011-11-24 22:44:26 +0000
@@ -113,7 +113,7 @@
verse_num = int(match.group(2))
except ValueError:
verse_num = 1
- verse_type_index = VerseType.from_loose_input(verse_tag)
+ verse_type_index = VerseType.from_loose_input(verse_tag, None)
if verse_type_index is not None:
self.verseNumberBox.setValue(verse_num)
@@ -140,7 +140,7 @@
match = VERSE_REGEX.match(text)
if match:
verse_type = match.group(1)
- verse_type_index = VerseType.from_loose_input(verse_type)
+ verse_type_index = VerseType.from_loose_input(verse_type, None)
try:
verse_number = int(match.group(2))
except ValueError:
@@ -153,7 +153,7 @@
tag=u'%s1' % VerseType.Tags[VerseType.Verse]):
self.hasSingleVerse = single
if single:
- verse_type_index = VerseType.from_tag(tag[0])
+ verse_type_index = VerseType.from_tag(tag[0], None)
verse_number = tag[1:]
if verse_type_index is not None:
self.verseTypeComboBox.setCurrentIndex(verse_type_index)
=== modified file 'openlp/plugins/songs/lib/__init__.py'
--- openlp/plugins/songs/lib/__init__.py 2011-08-16 00:08:16 +0000
+++ openlp/plugins/songs/lib/__init__.py 2011-11-24 22:44:26 +0000
@@ -69,7 +69,7 @@
TranslatedTags = [name[0].lower() for name in TranslatedNames]
@staticmethod
- def translated_tag(verse_tag, strict=False):
+ def translated_tag(verse_tag, default=Other):
"""
Return the translated UPPERCASE tag for a given tag,
used to show translated verse tags in UI
@@ -77,86 +77,84 @@
``verse_tag``
The string to return a VerseType for
- ``strict``
- Determines if the default Other or None should be returned
+ ``default``
+ Default return value if no matching tag is found
"""
- 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
+ if default in VerseType.TranslatedTags:
+ return VerseType.TranslatedTags[default].upper()
@staticmethod
- def translated_name(verse_tag, strict=False):
+ def translated_name(verse_tag, default=Other):
"""
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
+ ``default``
+ Default return value if no matching tag is found
"""
- 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
+ if default in VerseType.TranslatedNames:
+ return VerseType.TranslatedNames[default]
@staticmethod
- def from_tag(verse_tag, strict=False):
+ def from_tag(verse_tag, default=Other):
"""
Return the VerseType for a given tag
``verse_tag``
The string to return a VerseType for
- ``strict``
- Determines if the default Other or None should be returned
+ ``default``
+ Default return value if no matching tag is found
"""
- 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
+ return default
@staticmethod
- def from_translated_tag(verse_tag):
+ def from_translated_tag(verse_tag, default=Other):
"""
Return the VerseType for a given tag
``verse_tag``
The string to return a VerseType for
+
+ ``default``
+ Default return value if no matching tag is found
"""
verse_tag = verse_tag[0].lower()
for num, tag in enumerate(VerseType.TranslatedTags):
if verse_tag == tag:
return num
+ return default
@staticmethod
- def from_string(verse_name):
+ def from_string(verse_name, default=Other):
"""
Return the VerseType for a given string
``verse_name``
The string to return a VerseType for
+
+ ``default``
+ Default return value if no matching tag is found
"""
verse_name = verse_name.lower()
for num, name in enumerate(VerseType.Names):
if verse_name == name.lower():
return num
+ return default
@staticmethod
def from_translated_string(verse_name):
@@ -172,23 +170,26 @@
return num
@staticmethod
- def from_loose_input(verse_name):
+ def from_loose_input(verse_name, default=Other):
"""
Return the VerseType for a given string, Other if not found
``verse_name``
The string to return a VerseType for
+
+ ``default``
+ Default return value if no matching tag is found
"""
- verse_index = None
if len(verse_name) > 1:
verse_index = VerseType.from_translated_string(verse_name)
if verse_index is None:
- verse_index = VerseType.from_string(verse_name)
+ verse_index = VerseType.from_string(verse_name, default)
elif len(verse_name) == 1:
- if verse_index is None:
- verse_index = VerseType.from_translated_tag(verse_name)
- if verse_index is None:
- verse_index = VerseType.from_tag(verse_name)
+ verse_index = VerseType.from_translated_tag(verse_name, None)
+ if verse_index is None:
+ verse_index = VerseType.from_tag(verse_name, default)
+ else:
+ return default
return verse_index
def retrieve_windows_encoding(recommendation=None):
=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
--- openlp/plugins/songs/lib/mediaitem.py 2011-11-01 17:32:31 +0000
+++ openlp/plugins/songs/lib/mediaitem.py 2011-11-24 22:44:26 +0000
@@ -457,7 +457,7 @@
verse_index = \
VerseType.from_translated_string(verse_tag)
if verse_index is None:
- verse_index = VerseType.from_string(verse_tag)
+ verse_index = VerseType.from_string(verse_tag, None)
if verse_index is None:
verse_index = VerseType.from_tag(verse_tag)
verse_tag = VerseType.TranslatedTags[verse_index].upper()
@@ -479,8 +479,6 @@
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'])
Follow ups