forked from openlp/openlp
Use new strip_rtf routine and error trap
This commit is contained in:
parent
577be9a9c1
commit
614dc2648b
@ -476,7 +476,7 @@ def get_encoding(font, font_table, default_encoding, failed=False):
|
|||||||
Dictionary of fonts and respective encodings.
|
Dictionary of fonts and respective encodings.
|
||||||
|
|
||||||
``default_encoding``
|
``default_encoding``
|
||||||
The defaul encoding to use when font_table is empty or no font is used.
|
The default encoding to use when font_table is empty or no font is used.
|
||||||
|
|
||||||
``failed``
|
``failed``
|
||||||
A boolean indicating whether the previous encoding didn't work.
|
A boolean indicating whether the previous encoding didn't work.
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
"""
|
"""
|
||||||
The :mod:`importer` modules provides the general song import functionality.
|
The :mod:`importer` modules provides the general song import functionality.
|
||||||
"""
|
"""
|
||||||
|
import os
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from openlp.core.lib import translate
|
from openlp.core.lib import translate
|
||||||
|
@ -56,8 +56,14 @@ class MediaShoutImport(SongImport):
|
|||||||
"""
|
"""
|
||||||
Receive a single file to import.
|
Receive a single file to import.
|
||||||
"""
|
"""
|
||||||
conn = pyodbc.connect(u'DRIVER={Microsoft Access Driver (*.mdb)};'
|
try:
|
||||||
|
conn = pyodbc.connect(u'DRIVER={Microsoft Access Driver (*.mdb)};'
|
||||||
u'DBQ=%s;PWD=6NOZ4eHK7k' % self.importSource)
|
u'DBQ=%s;PWD=6NOZ4eHK7k' % self.importSource)
|
||||||
|
except: # Unfortunately no specific exception type
|
||||||
|
self.logError(self.importSource,
|
||||||
|
translate('SongsPlugin.MediaShoutImport',
|
||||||
|
'Unable to open the MediaShout database.'))
|
||||||
|
return
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
cursor.execute(u'SELECT Record, Title, Author, Copyright, '
|
cursor.execute(u'SELECT Record, Title, Author, Copyright, '
|
||||||
u'SongID, CCLI, Notes FROM Songs ORDER BY Title')
|
u'SongID, CCLI, Notes FROM Songs ORDER BY Title')
|
||||||
|
@ -81,6 +81,7 @@ class SongProImport(SongImport):
|
|||||||
"""
|
"""
|
||||||
Receive a single file or a list of files to import.
|
Receive a single file or a list of files to import.
|
||||||
"""
|
"""
|
||||||
|
self.encoding = None
|
||||||
with open(self.importSource, 'r') as songs_file:
|
with open(self.importSource, 'r') as songs_file:
|
||||||
self.importWizard.progressBar.setMaximum(0)
|
self.importWizard.progressBar.setMaximum(0)
|
||||||
tag = u''
|
tag = u''
|
||||||
@ -112,7 +113,8 @@ class SongProImport(SongImport):
|
|||||||
self.finish()
|
self.finish()
|
||||||
return
|
return
|
||||||
if u'rtf1' in text:
|
if u'rtf1' in text:
|
||||||
text = strip_rtf(text, u'cp1252').rstrip()
|
text, self.encoding = strip_rtf(text, self.encoding)
|
||||||
|
text = text.rstrip()
|
||||||
if not text:
|
if not text:
|
||||||
return
|
return
|
||||||
if tag == u'A':
|
if tag == u'A':
|
||||||
|
Loading…
Reference in New Issue
Block a user