forked from openlp/openlp
forgot to add a file and made some pep8 fixes
This commit is contained in:
parent
2937f39999
commit
dca65148c4
@ -53,7 +53,8 @@ class OpsProImport(SongImport):
|
||||
"""
|
||||
password = self.extract_mdb_password()
|
||||
try:
|
||||
conn = pyodbc.connect('DRIVER={Microsoft Access Driver (*.mdb)};DBQ=%s;PWD=%s' % (self.import_source, password))
|
||||
conn = pyodbc.connect('DRIVER={Microsoft Access Driver (*.mdb)};DBQ=%s;PWD=%s' % (self.import_source,
|
||||
password))
|
||||
except (pyodbc.DatabaseError, pyodbc.IntegrityError, pyodbc.InternalError, pyodbc.OperationalError) as e:
|
||||
log.warning('Unable to connect the OPS Pro database %s. %s', self.import_source, str(e))
|
||||
# Unfortunately no specific exception type
|
||||
@ -68,7 +69,8 @@ class OpsProImport(SongImport):
|
||||
for song in songs:
|
||||
if self.stop_import_flag:
|
||||
break
|
||||
cursor.execute('SELECT Lyrics, Type, IsDualLanguage FROM Lyrics WHERE SongID = %d AND Type < 2 ORDER BY Type DESC' % song.ID)
|
||||
cursor.execute('SELECT Lyrics, Type, IsDualLanguage FROM Lyrics WHERE SongID = %d AND Type < 2 '
|
||||
'ORDER BY Type DESC' % song.ID)
|
||||
lyrics = cursor.fetchone()
|
||||
cursor.execute('SELECT CategoryName FROM Category INNER JOIN SongCategory '
|
||||
'ON Category.ID = SongCategory.CategoryID WHERE SongCategory.SongID = %d '
|
||||
@ -225,7 +227,7 @@ class OpsProImport(SongImport):
|
||||
mdb.seek(0x62)
|
||||
EncrypFlag = struct.unpack('B', mdb.read(1))[0]
|
||||
# Get encrypted password
|
||||
mdb.seek(0x42);
|
||||
mdb.seek(0x42)
|
||||
encrypted_password = mdb.read(26)
|
||||
mdb.close()
|
||||
# "Decrypt" the password based on the version
|
||||
@ -245,8 +247,8 @@ class OpsProImport(SongImport):
|
||||
# Every byte with a different sign or encrypt. Encryption signs here for the 0x13
|
||||
t1 = chr(0x13 ^ EncrypFlag ^ encrypted_password[j * 2] ^ xor_pattern_2k[j])
|
||||
else:
|
||||
t1 = chr(encrypted_password[j * 2] ^ xor_pattern_2k[j]);
|
||||
decrypted_password = decrypted_password + t1;
|
||||
t1 = chr(encrypted_password[j * 2] ^ xor_pattern_2k[j])
|
||||
decrypted_password = decrypted_password + t1
|
||||
if ord(decrypted_password[1]) < 0x20 or ord(decrypted_password[1]) > 0x7e:
|
||||
decrypted_password = ''
|
||||
return decrypted_password
|
||||
|
@ -33,17 +33,6 @@ from openlp.plugins.songs.lib.importers.opspro import OpsProImport
|
||||
|
||||
TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'opsprosongs'))
|
||||
|
||||
class TestRecord(object):
|
||||
"""
|
||||
Microsoft Access Driver is not available on non Microsoft Systems for this reason the :class:`TestRecord` is used
|
||||
to simulate a recordset that would be returned by pyobdc.
|
||||
"""
|
||||
def __init__(self, id, field, value):
|
||||
# The case of the following instance variables is important as it needs to be the same as the ones in use in the
|
||||
# WorshipCenter Pro database.
|
||||
self.ID = id
|
||||
self.Field = field
|
||||
self.Value = value
|
||||
|
||||
class TestOpsProSongImport(TestCase):
|
||||
"""
|
||||
|
31
tests/resources/opsprosongs/amazing grace3.txt
Normal file
31
tests/resources/opsprosongs/amazing grace3.txt
Normal file
@ -0,0 +1,31 @@
|
||||
Amazing grace! How sweet the sound!
|
||||
That saved a wretch like me!
|
||||
I once was lost, but now am found;
|
||||
Was blind, but now I see.
|
||||
|
||||
[taal a]
|
||||
'Twas grace that taught my heart to fear,
|
||||
And grace my fears relieved.
|
||||
[taal b]
|
||||
How precious did that grace appear,
|
||||
The hour I first believed.
|
||||
|
||||
[trans off]
|
||||
The Lord has promised good to me,
|
||||
His Word my hope secures.
|
||||
[trans on]
|
||||
He will my shield and portion be
|
||||
As long as life endures.
|
||||
|
||||
[vertaal uit]
|
||||
Thro' many dangers, toils and snares
|
||||
I have already come.
|
||||
[vertaal aan]
|
||||
'Tis grace that brought me safe thus far,
|
||||
And grace will lead me home.
|
||||
|
||||
[end]
|
||||
When we've been there ten thousand years,
|
||||
Bright shining as the sun,
|
||||
We've no less days to sing God's praise,
|
||||
Than when we first begun.
|
Loading…
Reference in New Issue
Block a user