forked from openlp/openlp
Fix parsing of partly broken presentation manager files on windows.
This commit is contained in:
parent
46ee502ad6
commit
cf9c91f171
@ -178,7 +178,7 @@ def update_reference_separators():
|
|||||||
default_separators = [
|
default_separators = [
|
||||||
'|'.join([
|
'|'.join([
|
||||||
translate('BiblesPlugin', ':', 'Verse identifier e.g. Genesis 1 : 1 = Genesis Chapter 1 Verse 1'),
|
translate('BiblesPlugin', ':', 'Verse identifier e.g. Genesis 1 : 1 = Genesis Chapter 1 Verse 1'),
|
||||||
translate('BiblesPlugin', 'v','Verse identifier e.g. Genesis 1 v 1 = Genesis Chapter 1 Verse 1'),
|
translate('BiblesPlugin', 'v', 'Verse identifier e.g. Genesis 1 v 1 = Genesis Chapter 1 Verse 1'),
|
||||||
translate('BiblesPlugin', 'V', 'Verse identifier e.g. Genesis 1 V 1 = Genesis Chapter 1 Verse 1'),
|
translate('BiblesPlugin', 'V', 'Verse identifier e.g. Genesis 1 V 1 = Genesis Chapter 1 Verse 1'),
|
||||||
translate('BiblesPlugin', 'verse', 'Verse identifier e.g. Genesis 1 verse 1 = Genesis Chapter 1 Verse 1'),
|
translate('BiblesPlugin', 'verse', 'Verse identifier e.g. Genesis 1 verse 1 = Genesis Chapter 1 Verse 1'),
|
||||||
translate('BiblesPlugin', 'verses',
|
translate('BiblesPlugin', 'verses',
|
||||||
|
@ -25,6 +25,7 @@ Presentationmanager song files into the current database.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import chardet
|
import chardet
|
||||||
from lxml import objectify, etree
|
from lxml import objectify, etree
|
||||||
|
|
||||||
@ -49,7 +50,11 @@ class PresentationManagerImport(SongImport):
|
|||||||
# Try to detect encoding and use it
|
# Try to detect encoding and use it
|
||||||
file = open(file_path, mode='rb')
|
file = open(file_path, mode='rb')
|
||||||
encoding = chardet.detect(file.read())['encoding']
|
encoding = chardet.detect(file.read())['encoding']
|
||||||
tree = etree.parse(file_path, parser=etree.XMLParser(recover=True, encoding=encoding))
|
file.close()
|
||||||
|
# Open file with detected encoding and remove encoding declaration
|
||||||
|
text = open(file_path, mode='r', encoding=encoding).read()
|
||||||
|
text = re.sub('.+\?>\n', '', text)
|
||||||
|
tree = etree.fromstring(text, parser=etree.XMLParser(recover=True))
|
||||||
root = objectify.fromstring(etree.tostring(tree))
|
root = objectify.fromstring(etree.tostring(tree))
|
||||||
self.process_song(root)
|
self.process_song(root)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user