Added some more comments for songbeamer import and added support for author type.

This commit is contained in:
Tomas Groth 2017-05-11 21:53:47 +02:00
parent e00e8117a9
commit ad94e7c19f
5 changed files with 17 additions and 14 deletions

View File

@ -119,7 +119,6 @@ class SongBeamerImport(SongImport):
self.current_verse = '' self.current_verse = ''
self.current_verse_type = VerseType.tags[VerseType.Verse] self.current_verse_type = VerseType.tags[VerseType.Verse]
self.chord_table = None self.chord_table = None
self.editor_version = 0
file_name = os.path.split(import_file)[1] file_name = os.path.split(import_file)[1]
if os.path.isfile(import_file): if os.path.isfile(import_file):
# Detect the encoding # Detect the encoding
@ -181,12 +180,14 @@ class SongBeamerImport(SongImport):
verse_tags_mode = VerseTagMode.ContainsNoTags verse_tags_mode = VerseTagMode.ContainsNoTags
elif verse_tags_mode != VerseTagMode.ContainsNoTagsRestart: elif verse_tags_mode != VerseTagMode.ContainsNoTagsRestart:
if not verse_mark and verse_tags_mode == VerseTagMode.ContainsTags: if not verse_mark and verse_tags_mode == VerseTagMode.ContainsTags:
# Restart loop without counting tags as lines # A verse mark was expected but not found, which means that verse marks has not been
# inserted by songbeamer, but are manually added headings. So restart the loop, and
# count tags as lines.
self.set_defaults() self.set_defaults()
self.title = file_name.split('.sng')[0] self.title = file_name.split('.sng')[0]
verse_tags_mode = VerseTagMode.ContainsNoTagsRestart verse_tags_mode = VerseTagMode.ContainsNoTagsRestart
read_verses = False read_verses = False
# The first verse separator doesn't count, but the others does, so line count starts at -1 # The first verseseparator doesn't count, but the others does, so linecount starts at -1
line_number = -1 line_number = -1
first_verse = True first_verse = True
idx = -1 idx = -1
@ -257,7 +258,7 @@ class SongBeamerImport(SongImport):
elif tag_val[0] == '#AudioFile': elif tag_val[0] == '#AudioFile':
self.parse_audio_file(tag_val[1]) self.parse_audio_file(tag_val[1])
elif tag_val[0] == '#Author': elif tag_val[0] == '#Author':
self.parse_author(tag_val[1]) self.parse_author(tag_val[1], 'words')
elif tag_val[0] == '#BackgroundImage': elif tag_val[0] == '#BackgroundImage':
pass pass
elif tag_val[0] == '#Bible': elif tag_val[0] == '#Bible':
@ -278,10 +279,7 @@ class SongBeamerImport(SongImport):
except ValueError: except ValueError:
self.comments = tag_val[1] self.comments = tag_val[1]
elif tag_val[0] == '#Editor': elif tag_val[0] == '#Editor':
try: pass
self.editor_version = float(re.sub('[a-zA-Z ]', '', tag_val[1]))
except ValueError:
self.editor_version = 0
elif tag_val[0] == '#Font': elif tag_val[0] == '#Font':
pass pass
elif tag_val[0] == '#FontLang2': elif tag_val[0] == '#FontLang2':
@ -303,7 +301,7 @@ class SongBeamerImport(SongImport):
elif tag_val[0] == '#LangCount': elif tag_val[0] == '#LangCount':
pass pass
elif tag_val[0] == '#Melody': elif tag_val[0] == '#Melody':
self.parse_author(tag_val[1]) self.parse_author(tag_val[1], 'music')
elif tag_val[0] == '#NatCopyright': elif tag_val[0] == '#NatCopyright':
pass pass
elif tag_val[0] == '#OTitle': elif tag_val[0] == '#OTitle':

View File

@ -242,7 +242,7 @@ class SongImport(QtCore.QObject):
self.copyright += ' ' self.copyright += ' '
self.copyright += copyright self.copyright += copyright
def parse_author(self, text): def parse_author(self, text, type=None):
""" """
Add the author. OpenLP stores them individually so split by 'and', '&' and comma. However need to check Add the author. OpenLP stores them individually so split by 'and', '&' and comma. However need to check
for 'Mr and Mrs Smith' and turn it to 'Mr Smith' and 'Mrs Smith'. for 'Mr and Mrs Smith' and turn it to 'Mr Smith' and 'Mrs Smith'.
@ -256,7 +256,7 @@ class SongImport(QtCore.QObject):
if author2.endswith('.'): if author2.endswith('.'):
author2 = author2[:-1] author2 = author2[:-1]
if author2: if author2:
self.add_author(author2) self.add_author(author2, type)
def add_author(self, author, type=None): def add_author(self, author, type=None):
""" """

View File

@ -1,6 +1,6 @@
{ {
"authors": [ "authors": [
"John Newton" ["John Newton", "words"]
], ],
"title": "Amazing grace", "title": "Amazing grace",
"verse_order_list": ["v1", "v2", "v3", "v4", "v5"], "verse_order_list": ["v1", "v2", "v3", "v4", "v5"],

View File

@ -8,5 +8,8 @@
], ],
"song_book_name": "Glaubenslieder I", "song_book_name": "Glaubenslieder I",
"song_number": "1", "song_number": "1",
"authors": ["Carl Brockhaus", "Johann Jakob Vetter"] "authors": [
["Carl Brockhaus", "words"],
["Johann Jakob Vetter", "music"]
]
} }

View File

@ -1,6 +1,8 @@
{ {
"title": "Some Song", "title": "Some Song",
"authors": ["Author"], "authors": [
["Author", "words"]
],
"verses" : [ "verses" : [
["Here are a couple of \"weird\" chars.\n", "v"], ["Here are a couple of \"weird\" chars.\n", "v"],
["Here is another one….\n\n", "v"] ["Here is another one….\n\n", "v"]