forked from openlp/openlp
fix #99
This commit is contained in:
parent
f6cc197e19
commit
7d7f9a7d98
@ -78,7 +78,20 @@ class CCLIFileImport(SongImport):
|
|||||||
details = chardet.detect(detect_content)
|
details = chardet.detect(detect_content)
|
||||||
detect_file.close()
|
detect_file.close()
|
||||||
infile = codecs.open(filename, u'r', details['encoding'])
|
infile = codecs.open(filename, u'r', details['encoding'])
|
||||||
|
try:
|
||||||
lines = infile.readlines()
|
lines = infile.readlines()
|
||||||
|
infile.close()
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
# First 2kB were not sufficient to detect file encoding.
|
||||||
|
# This time we read entire file.
|
||||||
|
detect_file = open(filename, u'r')
|
||||||
|
detect_content = detect_file.read()
|
||||||
|
details = chardet.detect(detect_content)
|
||||||
|
detect_file.close()
|
||||||
|
# We read the contents again. Should it be a try as well?
|
||||||
|
infile = codecs.open(filename, u'r', details['encoding'])
|
||||||
|
lines = infile.readlines()
|
||||||
|
infile.close()
|
||||||
ext = os.path.splitext(filename)[1]
|
ext = os.path.splitext(filename)[1]
|
||||||
if ext.lower() == u'.usr':
|
if ext.lower() == u'.usr':
|
||||||
log.info(u'SongSelect .usr format file found %s: ',
|
log.info(u'SongSelect .usr format file found %s: ',
|
||||||
|
Loading…
Reference in New Issue
Block a user