openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #21913
[Merge] lp:~sam92/openlp/fix-songbeamer-import into lp:openlp
Samuel Mehrbrodt has proposed merging lp:~sam92/openlp/fix-songbeamer-import into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
For more details, see:
https://code.launchpad.net/~sam92/openlp/fix-songbeamer-import/+merge/187815
Fix SongBeamer Import
chardet failed to guess the right encoding, so I removed the autodetect. Now they are always opened with "Latin-1" encoding.
I tested this with ~800 SongBeamer files.
--
https://code.launchpad.net/~sam92/openlp/fix-songbeamer-import/+merge/187815
Your team OpenLP Core is requested to review the proposed merge of lp:~sam92/openlp/fix-songbeamer-import into lp:openlp.
=== modified file 'openlp/plugins/songs/lib/songbeamerimport.py'
--- openlp/plugins/songs/lib/songbeamerimport.py 2013-08-31 18:17:38 +0000
+++ openlp/plugins/songs/lib/songbeamerimport.py 2013-09-26 15:12:26 +0000
@@ -29,10 +29,9 @@
"""
The :mod:`songbeamerimport` module provides the functionality for importing SongBeamer songs into the OpenLP database.
"""
-import chardet
-import codecs
import logging
import os
+import io
import re
from openlp.plugins.songs.lib import VerseType
@@ -105,7 +104,7 @@
self.import_wizard.progress_bar.setMaximum(len(self.import_source))
if not isinstance(self.import_source, list):
return
- for file in self.import_source:
+ for _file in self.import_source:
# TODO: check that it is a valid SongBeamer file
if self.stop_import_flag:
return
@@ -113,12 +112,9 @@
self.currentVerse = ''
self.currentVerseType = VerseType.tags[VerseType.Verse]
read_verses = False
- file_name = os.path.split(file)[1]
- if os.path.isfile(file):
- detect_file = open(file, 'r')
- details = chardet.detect(detect_file.read())
- detect_file.close()
- infile = codecs.open(file, 'r', details['encoding'])
+ file_name = os.path.split(_file)[1]
+ if os.path.isfile(_file):
+ infile = io.open(_file, 'r', encoding="Latin-1")
song_data = infile.readlines()
infile.close()
else:
@@ -149,7 +145,7 @@
self.replaceHtmlTags()
self.addVerse(self.currentVerse, self.currentVerseType)
if not self.finish():
- self.logError(file)
+ self.logError(_file)
def replaceHtmlTags(self):
"""
References