openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #04386
[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)
The openlp.org 1.x importer evaluates also song title and copyright for recognices the character encoding.
The CCLI import uses utf-8 encoding, if the file is valid. This resolves the problem I mentioned on devs mail list. As false positive is below 6% (wrong number on my email) for a single character, there should be no false positive. Also SongSelect offers its files in this encoding.
--
https://code.launchpad.net/~m2j/openlp/work/+merge/39788
Your team OpenLP Core is requested to review the proposed merge of lp:~m2j/openlp/work into lp:openlp.
=== modified file 'openlp/plugins/songs/lib/cclifileimport.py' (properties changed: +x to -x)
--- openlp/plugins/songs/lib/cclifileimport.py 2010-10-10 21:13:10 +0000
+++ openlp/plugins/songs/lib/cclifileimport.py 2010-11-01 21:34:40 +0000
@@ -76,7 +76,12 @@
lines = []
if os.path.isfile(filename):
detect_file = open(filename, u'r')
- details = chardet.detect(detect_file.read(2048))
+ detect_content = detect_file.read(2048)
+ try:
+ unicode(detect_content, u'utf-8')
+ details = {'confidence': 1, 'encoding': 'utf-8'}
+ except UnicodeDecodeError:
+ details = chardet.detect(detect_content)
detect_file.close()
infile = codecs.open(filename, u'r', details['encoding'])
lines = infile.readlines()
=== modified file 'openlp/plugins/songs/lib/olp1import.py'
--- openlp/plugins/songs/lib/olp1import.py 2010-09-19 08:47:00 +0000
+++ openlp/plugins/songs/lib/olp1import.py 2010-11-01 21:34:40 +0000
@@ -118,7 +118,7 @@
success = False
break
song_id = song[0]
- guess = chardet.detect(song[2])
+ guess = chardet.detect(song[1] + song[2] + song[3])
title = self.decode_string(song[1], guess)
lyrics = self.decode_string(song[2], guess).replace(u'\r', u'')
copyright = self.decode_string(song[3], guess)
Follow ups