forked from openlp/openlp
Return None for blank fields in the database
This commit is contained in:
parent
70f8795d61
commit
4f11181bfa
@ -146,27 +146,41 @@ class EasyWorshipSongImport(SongImport):
|
|||||||
raw_record = db_file.read(record_size)
|
raw_record = db_file.read(record_size)
|
||||||
self.fields = self.record_struct.unpack(raw_record)
|
self.fields = self.record_struct.unpack(raw_record)
|
||||||
self.set_defaults()
|
self.set_defaults()
|
||||||
self.title = self.get_field(fi_title)
|
# Get title and update progress bar message
|
||||||
self.import_wizard.incrementProgressBar(
|
title = self.get_field(fi_title)
|
||||||
u'Importing "%s"...' % self.title, 0)
|
if title:
|
||||||
self.copyright = self.get_field(fi_copy) + \
|
self.import_wizard.incrementProgressBar(
|
||||||
u', Administered by ' + self.get_field(fi_admin)
|
u'Importing "%s"...' % title, 0)
|
||||||
self.ccli_number = self.get_field(fi_ccli)
|
self.title = title
|
||||||
# Format the lyrics
|
# Get remaining fields
|
||||||
if self.stop_import_flag:
|
copy = self.get_field(fi_copy)
|
||||||
success = False
|
admin = self.get_field(fi_admin)
|
||||||
break
|
ccli = self.get_field(fi_ccli)
|
||||||
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)
|
authors = self.get_field(fi_author)
|
||||||
author_list = authors.split(u'/')
|
words = self.get_field(fi_words)
|
||||||
if len(author_list) < 2:
|
# Set the SongImport object members
|
||||||
author_list = authors.split(u',')
|
if copy:
|
||||||
for author_name in author_list:
|
self.copyright = copy
|
||||||
self.add_author(author_name.strip())
|
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:
|
if self.stop_import_flag:
|
||||||
success = False
|
success = False
|
||||||
break
|
break
|
||||||
@ -214,12 +228,12 @@ class EasyWorshipSongImport(SongImport):
|
|||||||
def get_field(self, field_desc_index):
|
def get_field(self, field_desc_index):
|
||||||
field = self.fields[field_desc_index]
|
field = self.fields[field_desc_index]
|
||||||
field_desc = self.field_descs[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 isinstance(field, str):
|
||||||
if len(field.rstrip('\0')) == 0:
|
if len(field.rstrip('\0')) == 0:
|
||||||
return u''
|
return None
|
||||||
elif field == 0:
|
elif field == 0:
|
||||||
return 0
|
return None
|
||||||
# Format the field depending on the field type
|
# Format the field depending on the field type
|
||||||
if field_desc.type == 1:
|
if field_desc.type == 1:
|
||||||
# string
|
# string
|
||||||
|
Loading…
Reference in New Issue
Block a user