← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~m2j/openlp/work into lp:openlp

 

m2j has proposed merging lp:~m2j/openlp/work into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~m2j/openlp/work/+merge/82668

Bug #875286
use VerseType.Other if it is not recogniced during OpenSong import.

-- 
https://code.launchpad.net/~m2j/openlp/work/+merge/82668
Your team OpenLP Core is requested to review the proposed merge of lp:~m2j/openlp/work into 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-18 11:01:59 +0000
@@ -278,7 +278,7 @@
                 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, True)
                     else:
                         verse_tags_translated = True
                 if index is None:

=== 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-18 11:01:59 +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, True)
             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, True)
             try:
                 verse_number = int(match.group(2))
             except ValueError:

=== 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-18 11:01:59 +0000
@@ -80,15 +80,12 @@
         ``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
+        if not strict:
+            return VerseType.TranslatedTags[VerseType.Other].upper()
 
     @staticmethod
     def translated_name(verse_tag, strict=False):
@@ -101,15 +98,12 @@
         ``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
+        if not strict:
+            return VerseType.TranslatedNames[VerseType.Other]
 
     @staticmethod
     def from_tag(verse_tag, strict=False):
@@ -122,15 +116,12 @@
         ``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
+        if not strict:
+            return VerseType.Other
 
     @staticmethod
     def from_translated_tag(verse_tag):
@@ -146,17 +137,22 @@
                 return num
 
     @staticmethod
-    def from_string(verse_name):
+    def from_string(verse_name, strict=False):
         """
         Return the VerseType for a given string
 
         ``verse_name``
             The string to return a VerseType for
+
+        ``strict``
+            Determines if the default Other or None should be returned
         """
         verse_name = verse_name.lower()
         for num, name in enumerate(VerseType.Names):
             if verse_name == name.lower():
                 return num
+        if not strict:
+            return VerseType.Other
 
     @staticmethod
     def from_translated_string(verse_name):
@@ -172,23 +168,27 @@
                 return num
 
     @staticmethod
-    def from_loose_input(verse_name):
+    def from_loose_input(verse_name, strict=False):
         """
         Return the VerseType for a given string, Other if not found
 
         ``verse_name``
             The string to return a VerseType for
+
+        ``strict``
+            Determines if the default Other or None should be returned
         """
         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, strict)
         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)
+            if verse_index is None:
+                verse_index = VerseType.from_tag(verse_name, strict)
+        elif not strict:
+            verse_index = VerseType.Other
         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-18 11:01:59 +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, True)
                     if verse_index is None:
                         verse_index = VerseType.from_tag(verse_tag)
                     verse_tag = VerseType.TranslatedTags[verse_index].upper()


Follow ups