openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #03839
[Merge] lp:~whydoubt/openlp/easyworship into lp:openlp
Jeffrey Smith has proposed merging lp:~whydoubt/openlp/easyworship into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
I tried the EW database from my church as a test case,
and it revealed a bug with handling memo files larger
than 16MiB. Also, handle blank fields more intelligently.
--
https://code.launchpad.net/~whydoubt/openlp/easyworship/+merge/36616
Your team OpenLP Core is requested to review the proposed merge of lp:~whydoubt/openlp/easyworship into lp:openlp.
=== modified file 'openlp/plugins/songs/lib/ewimport.py'
--- openlp/plugins/songs/lib/ewimport.py 2010-09-20 20:58:55 +0000
+++ openlp/plugins/songs/lib/ewimport.py 2010-09-25 04:14:40 +0000
@@ -146,27 +146,41 @@
raw_record = db_file.read(record_size)
self.fields = self.record_struct.unpack(raw_record)
self.set_defaults()
- self.title = self.get_field(fi_title)
- self.import_wizard.incrementProgressBar(
- u'Importing "%s"...' % self.title, 0)
- self.copyright = self.get_field(fi_copy) + \
- u', Administered by ' + self.get_field(fi_admin)
- self.ccli_number = self.get_field(fi_ccli)
- # Format the lyrics
- if self.stop_import_flag:
- success = False
- break
+ # Get title and update progress bar message
+ title = self.get_field(fi_title)
+ if title:
+ self.import_wizard.incrementProgressBar(
+ u'Importing "%s"...' % title, 0)
+ self.title = title
+ # Get remaining fields
+ copy = self.get_field(fi_copy)
+ admin = self.get_field(fi_admin)
+ ccli = self.get_field(fi_ccli)
+ authors = self.get_field(fi_author)
words = self.get_field(fi_words)
- words = strip_rtf(words)
- for verse in words.split(u'\n\n'):
- self.add_verse(verse.strip(), u'V')
- # Split up the authors
- authors = self.get_field(fi_author)
- author_list = authors.split(u'/')
- if len(author_list) < 2:
- author_list = authors.split(u',')
- for author_name in author_list:
- self.add_author(author_name.strip())
+ # Set the SongImport object members
+ if copy:
+ self.copyright = copy
+ if admin:
+ if copy:
+ self.copyright += u', '
+ self.copyright += u'Administered by ' + admin
+ if ccli:
+ self.ccli_number = ccli
+ if authors:
+ # Split up the authors
+ author_list = authors.split(u'/')
+ if len(author_list) < 2:
+ author_list = authors.split(u';')
+ if len(author_list) < 2:
+ author_list = authors.split(u',')
+ for author_name in author_list:
+ self.add_author(author_name.strip())
+ if words:
+ # Format the lyrics
+ words = strip_rtf(words)
+ for verse in words.split(u'\n\n'):
+ self.add_verse(verse.strip(), u'V')
if self.stop_import_flag:
success = False
break
@@ -214,12 +228,12 @@
def get_field(self, field_desc_index):
field = self.fields[field_desc_index]
field_desc = self.field_descs[field_desc_index]
- # Check for 'blank' entries
+ # Return None in case of 'blank' entries
if isinstance(field, str):
if len(field.rstrip('\0')) == 0:
- return u''
+ return None
elif field == 0:
- return 0
+ return None
# Format the field depending on the field type
if field_desc.type == 1:
# string
@@ -235,19 +249,20 @@
return (field ^ 0x80 == 1)
elif field_desc.type == 0x0c or field_desc.type == 0x0d:
# Memo or Blob
- sub_block, block_start, blob_size = \
- struct.unpack_from('<bhxi', field, len(field)-10)
- self.memo_file.seek(block_start * 256)
+ block_start, blob_size = \
+ struct.unpack_from('<II', field, len(field)-10)
+ sub_block = block_start & 0xff;
+ block_start &= ~0xff
+ self.memo_file.seek(block_start)
memo_block_type, = struct.unpack('b', self.memo_file.read(1))
if memo_block_type == 2:
self.memo_file.seek(8, os.SEEK_CUR)
elif memo_block_type == 3:
- if sub_block < 0 or sub_block > 63:
+ if sub_block > 63:
return u'';
self.memo_file.seek(11 + (5 * sub_block), os.SEEK_CUR)
sub_block_start, = struct.unpack('B', self.memo_file.read(1))
- self.memo_file.seek((block_start * 256) +
- (sub_block_start * 16))
+ self.memo_file.seek(block_start + (sub_block_start * 16))
else:
return u'';
return self.memo_file.read(blob_size)
Follow ups