← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~phill-ridout/openlp/1194610_2.0 into lp:openlp/2.0

 

Phill has proposed merging lp:~phill-ridout/openlp/1194610_2.0 into lp:openlp/2.0.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #1194610 in OpenLP: "[support-system] SongShowPlus traceback"
  https://bugs.launchpad.net/openlp/+bug/1194610

For more details, see:
https://code.launchpad.net/~phill-ridout/openlp/1194610_2.0/+merge/178373

Fixes bug 1194610 by detecting the encoding rather than assuming that it set (because its not)
-- 
https://code.launchpad.net/~phill-ridout/openlp/1194610_2.0/+merge/178373
Your team OpenLP Core is requested to review the proposed merge of lp:~phill-ridout/openlp/1194610_2.0 into lp:openlp/2.0.
=== modified file 'openlp/plugins/songs/lib/songshowplusimport.py'
--- openlp/plugins/songs/lib/songshowplusimport.py	2013-02-18 17:15:44 +0000
+++ openlp/plugins/songs/lib/songshowplusimport.py	2013-08-02 19:53:25 +0000
@@ -30,6 +30,7 @@
 The :mod:`songshowplusimport` module provides the functionality for importing 
 SongShow Plus songs into the OpenLP database.
 """
+import chardet
 import os
 import logging
 import re
@@ -142,44 +143,44 @@
                 log.debug(length_descriptor_size)
                 data = song_data.read(length_descriptor)
                 if block_key == TITLE:
-                    self.title = unicode(data, u'cp1252')
+                    self.title = unicode(data, chardet.detect(data)['encoding'])
                 elif block_key == AUTHOR:
                     authors = data.split(" / ")
                     for author in authors:
                         if author.find(",") !=-1:
                             authorParts = author.split(", ")
                             author = authorParts[1] + " " + authorParts[0]
-                        self.parseAuthor(unicode(author, u'cp1252'))
+                        self.parseAuthor(unicode(author, chardet.detect(data)['encoding']))
                 elif block_key == COPYRIGHT:
-                    self.addCopyright(unicode(data, u'cp1252'))
+                    self.addCopyright(unicode(data, chardet.detect(data)['encoding']))
                 elif block_key == CCLI_NO:
                     self.ccliNumber = int(data)
                 elif block_key == VERSE:
-                    self.addVerse(unicode(data, u'cp1252'),
+                    self.addVerse(unicode(data, chardet.detect(data)['encoding']),
                         "%s%s" % (VerseType.Tags[VerseType.Verse], verse_no))
                 elif block_key == CHORUS:
-                    self.addVerse(unicode(data, u'cp1252'),
+                    self.addVerse(unicode(data, chardet.detect(data)['encoding']),
                         "%s%s" % (VerseType.Tags[VerseType.Chorus], verse_no))
                 elif block_key == BRIDGE:
-                    self.addVerse(unicode(data, u'cp1252'),
+                    self.addVerse(unicode(data, chardet.detect(data)['encoding']),
                         "%s%s" % (VerseType.Tags[VerseType.Bridge], verse_no))
                 elif block_key == TOPIC:
-                    self.topics.append(unicode(data, u'cp1252'))
+                    self.topics.append(unicode(data, chardet.detect(data)['encoding']))
                 elif block_key == COMMENTS:
-                    self.comments = unicode(data, u'cp1252')
+                    self.comments = unicode(data, chardet.detect(data)['encoding'])
                 elif block_key == VERSE_ORDER:
                     verse_tag = self.toOpenLPVerseTag(data, True)
                     if verse_tag:
                         if not isinstance(verse_tag, unicode):
-                            verse_tag = unicode(verse_tag, u'cp1252')
+                            verse_tag = unicode(verse_tag, chardet.detect(data)['encoding'])
                         self.sspVerseOrderList.append(verse_tag)
                 elif block_key == SONG_BOOK:
-                    self.songBookName = unicode(data, u'cp1252')
+                    self.songBookName = unicode(data, chardet.detect(data)['encoding'])
                 elif block_key == SONG_NUMBER:
                     self.songNumber = ord(data)
                 elif block_key == CUSTOM_VERSE:
                     verse_tag = self.toOpenLPVerseTag(verse_name)
-                    self.addVerse(unicode(data, u'cp1252'), verse_tag)
+                    self.addVerse(unicode(data, chardet.detect(data)['encoding']), verse_tag)
                 else:
                     log.debug("Unrecognised blockKey: %s, data: %s"
                         % (block_key, data))


Follow ups