← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~raoul-snyman/openlp/bug-993445 into lp:openlp

 

Raoul Snyman has proposed merging lp:~raoul-snyman/openlp/bug-993445 into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #993445 in OpenLP: "OpenSong bible importer does not handle multiple verses in one tag"
  https://bugs.launchpad.net/openlp/+bug/993445

For more details, see:
https://code.launchpad.net/~raoul-snyman/openlp/bug-993445/+merge/125859

Fixed bug #993445 and cleaned up the logic a little in some other places.
-- 
https://code.launchpad.net/~raoul-snyman/openlp/bug-993445/+merge/125859
Your team OpenLP Core is requested to review the proposed merge of lp:~raoul-snyman/openlp/bug-993445 into lp:openlp.
=== modified file 'openlp/plugins/bibles/lib/http.py'
--- openlp/plugins/bibles/lib/http.py	2012-09-15 08:39:30 +0000
+++ openlp/plugins/bibles/lib/http.py	2012-09-22 19:06:20 +0000
@@ -160,10 +160,12 @@
                 verse = verse.strip()
                 try:
                     verse = int(verse)
-                except (TypeError, ValueError):
+                except ValueError:
                     verse_parts = verse.split(u'-')
                     if len(verse_parts) > 1:
                         verse = int(verse_parts[0])
+                except TypeError:
+                    log.warn(u'Illegal verse number: %s', unicode(raw_verse_num))
                 verses.append((verse, text))
         verse_list = {}
         for verse, text in verses[::-1]:
@@ -194,6 +196,10 @@
             try:
                 clean_verse_num = int(str(raw_verse_num))
             except ValueError:
+                verse_parts = str(raw_verse_num).split(u'-')
+                if len(verse_parts) > 1:
+                    clean_verse_num = int(verse_parts[0])
+            except TypeError:
                 log.warn(u'Illegal verse number: %s', unicode(raw_verse_num))
             if clean_verse_num:
                 verse_text = raw_verse_num.next

=== modified file 'openlp/plugins/bibles/lib/opensong.py'
--- openlp/plugins/bibles/lib/opensong.py	2012-07-21 21:32:04 +0000
+++ openlp/plugins/bibles/lib/opensong.py	2012-09-22 19:06:20 +0000
@@ -103,10 +103,20 @@
                     for verse in chapter.v:
                         if self.stop_import_flag:
                             break
+                        verse_number = 0
+                        try:
+                            verse_number = int(verse.attrib[u'n'])
+                        except ValueError:
+                            verse_parts = verse.attrib[u'n'].split(u'-')
+                            if len(verse_parts) > 1:
+                                verse_number = int(verse_parts[0])
+                        except TypeError:
+                            log.warn(u'Illegal verse number: %s',
+                                unicode(verse.attrib[u'n']))
                         self.create_verse(
                             db_book.id,
                             int(chapter.attrib[u'n'].split()[-1]),
-                            int(verse.attrib[u'n']),
+                            verse_number,
                             unicode(self.get_text(verse)))
                     self.wizard.incrementProgressBar(unicode(translate(
                         'BiblesPlugin.Opensong', 'Importing %s %s...',


Follow ups