← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~phill-ridout/openlp/opensongbibles into lp:openlp

 

phill has proposed merging lp:~phill-ridout/openlp/opensongbibles into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #1074727 in OpenLP: "OpenSong Bibles cause OpenLP to crash due to missing attriburte"
  https://bugs.launchpad.net/openlp/+bug/1074727

For more details, see:
https://code.launchpad.net/~phill-ridout/openlp/opensongbibles/+merge/132793

Fixed bug #1074727 "OpenSong Bibles cause OpenLP to crash due to missing attriburte"

Counts the chapter and verse numbers and uses these when no number is in the attribute
-- 
https://code.launchpad.net/~phill-ridout/openlp/opensongbibles/+merge/132793
Your team OpenLP Core is requested to review the proposed merge of lp:~phill-ridout/openlp/opensongbibles into lp:openlp.
=== modified file 'openlp/plugins/bibles/lib/opensong.py'
--- openlp/plugins/bibles/lib/opensong.py	2012-10-21 14:07:57 +0000
+++ openlp/plugins/bibles/lib/opensong.py	2012-11-03 23:01:22 +0000
@@ -98,31 +98,42 @@
                 book_details = BiblesResourcesDB.get_book_by_id(book_ref_id)
                 db_book = self.create_book(unicode(book.attrib[u'n']),
                     book_ref_id, book_details[u'testament_id'])
+                chapter_number = 0
                 for chapter in book.c:
                     if self.stop_import_flag:
                         break
+                    number = chapter.attrib[u'n']
+                    if number:
+                        chapter_number = int(number.split()[-1])
+                    else:
+                        chapter_number += 1
+                    verse_number = 0
                     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']))
+                        number = verse.attrib[u'n']
+                        if number:
+                            try:
+                                number = int(number)
+                            except ValueError:
+                                verse_parts = number.split(u'-')
+                                if len(verse_parts) > 1:
+                                    number = int(verse_parts[0])
+                            except TypeError:
+                                log.warn(u'Illegal verse number: %s',
+                                    unicode(verse.attrib[u'n']))
+                            verse_number = number
+                        else:
+                            verse_number += 1
                         self.create_verse(
                             db_book.id,
-                            int(chapter.attrib[u'n'].split()[-1]),
+                            chapter_number,
                             verse_number,
                             unicode(self.get_text(verse)))
                     self.wizard.incrementProgressBar(unicode(translate(
                         'BiblesPlugin.Opensong', 'Importing %s %s...',
                         'Importing <book name> <chapter>...')) %
-                        (db_book.name, int(chapter.attrib[u'n'].split()[-1])))
+                        (db_book.name, chapter_number))
                 self.session.commit()
             Receiver.send_message(u'openlp_process_events')
         except etree.XMLSyntaxError as inst:


Follow ups