Tidy up auto verse order generation

This commit is contained in:
john 2019-06-27 13:01:11 +01:00
parent 66712873b4
commit 8a4c349f9e
2 changed files with 13 additions and 55 deletions

View File

@ -150,7 +150,7 @@ class SingingTheFaithImport(SongImport):
this_verse = self.verses[int(hintverse)-1] this_verse = self.verses[int(hintverse)-1]
this_verse_str = this_verse[1] this_verse_str = this_verse[1]
new_verse = this_verse_str new_verse = this_verse_str
# There might be multiple replace pairs separated by | # There might be multiple replace pairs separated by |
replaces=replace.split("|") replaces=replace.split("|")
for rep in replaces: for rep in replaces:
(source_str,dest_str)=rep.split("/") (source_str,dest_str)=rep.split("/")
@ -189,7 +189,6 @@ class SingingTheFaithImport(SongImport):
else: else:
line = line.rstrip() line = line.rstrip()
## print("Read line",line_number,"(",indent,")",line) ## print("Read line",line_number,"(",indent,")",line)
# line_number += 1 # Now read earlier
if line_number == 2: if line_number == 2:
# note that songs seem to start with a blank line # note that songs seem to start with a blank line
song_title = line song_title = line
@ -214,14 +213,13 @@ class SingingTheFaithImport(SongImport):
elif (indent == 0) and (line.startswith('From Common ')): elif (indent == 0) and (line.startswith('From Common ')):
self.add_comment(line) self.add_comment(line)
continue continue
# If indent is 0 it may well be the author (but not if it was the Reproduced line) # If indent is 0 it may be the author, unless it was one of the cases covered above
elif (indent == 0) and len(line)>0 : elif (indent == 0) and len(line)>0 :
## print ("Possible author ",line) ## print ("Possible author ",line)
# May have more than one author, separated by ' and ' # May have more than one author, separated by ' and '
authors = line.split(' and ') authors = line.split(' and ')
for a in authors: for a in authors:
self.parse_author(a) self.parse_author(a)
# author = line
continue continue
if line == '': if line == '':
## print("Starting a new verse") ## print("Starting a new verse")
@ -271,11 +269,12 @@ class SingingTheFaithImport(SongImport):
self.title = check_flag+"STF"+song_number.zfill(3)+" - "+song_title self.title = check_flag+"STF"+song_number.zfill(3)+" - "+song_title
self.song_book_name="Singing The Faith" self.song_book_name="Singing The Faith"
self.song_number = song_number self.song_number = song_number
# self.parse_author(author)
self.ccli_number = ccli self.ccli_number = ccli
self.add_copyright(copyright) self.add_copyright(copyright)
# If we have a chorus then the generated Verse order will not be useful, so clear the verse_order_list # If we have a chorus then the generated Verse order can not be used directly, but we can generate
if has_chorus: # one for two special cases - Verse followed by one chorus (to be repeated after every verse)
# of Chorus, followed by verses. If hints for ManualCheck or VerseOrder are supplied ignore this
if has_chorus and not self.hint_verseOrder and not self.checks_needed:
## print ("Has chorus - verse order list is ",self.verse_order_list) ## print ("Has chorus - verse order list is ",self.verse_order_list)
auto_verse_order_ok = False auto_verse_order_ok = False
# Popular case V1 C2 V2 ... # Popular case V1 C2 V2 ...
@ -284,35 +283,24 @@ class SingingTheFaithImport(SongImport):
new_verse_order_list = ['v1','c1'] new_verse_order_list = ['v1','c1']
i = 2 i = 2
auto_verse_order_ok = True auto_verse_order_ok = True
while i < len(self.verse_order_list):
# Should maybe check for vn
if self.verse_order_list[i].startswith('v'):
new_verse_order_list.append(self.verse_order_list[i])
new_verse_order_list.append("c1")
else:
### Fix this
### self.log_error(translate('SongsPlugin.SingingTheFaithImport', 'File %s' % file.name),
### translate('SongsPlugin.SingingTheFaithImport', 'Error: %s'",self.verse_order_list[i]," in ",str(self.song_number))
## Should be a logged error
## print("Found strange verseorder entry ",self.verse_order_list[i]," in ",file.name)
auto_verse_order_ok = False
i += 1
## print(" new verse_order_list is ",new_verse_order_list)
self.verse_order_list = new_verse_order_list
elif (self.verse_order_list[0] == "c1") and (self.verse_order_list[1] == "v1"): elif (self.verse_order_list[0] == "c1") and (self.verse_order_list[1] == "v1"):
new_verse_order_list = ['c1','v1','c1'] new_verse_order_list = ['c1','v1','c1']
i = 2 i = 2
while i < len(self.verse_order_list): auto_verse_order_ok = True
# Should maybe check for vn # if we are in a case we can deal with
if auto_verse_order_ok:
while i < len(self.verse_order_list):
if self.verse_order_list[i].startswith('v'): if self.verse_order_list[i].startswith('v'):
new_verse_order_list.append(self.verse_order_list[i]) new_verse_order_list.append(self.verse_order_list[i])
new_verse_order_list.append("c1") new_verse_order_list.append("c1")
else: else:
self.log_error(translate('SongsPlugin.SingingTheFaithImport', 'File %s' % file.name),
'Error: Strange verse order entry '+self.verse_order_list[i])
## print("Found strange verseorder entry ",self.verse_order_list[i]," in ",file.name) ## print("Found strange verseorder entry ",self.verse_order_list[i]," in ",file.name)
auto_verse_order_ok = False auto_verse_order_ok = False
i += 1 i += 1
## print(" new verse_order_list (Chorus first is ",new_verse_order_list) ## print(" new verse_order_list (Chorus first is ",new_verse_order_list)
self.verse_order_list = new_verse_order_list self.verse_order_list = new_verse_order_list
else: else:
if not auto_verse_order_ok: if not auto_verse_order_ok:
print ("setting verse_order_list to empty") print ("setting verse_order_list to empty")

View File

@ -1,30 +0,0 @@
1 All people that on earth do dwell,
sing to the Lord with cheerful voice:
him serve with mirth, his praise forth tell;
come ye before him and rejoice.
2 The Lord, ye know, is God indeed;
without our aid he did us make:
we are his folk, he doth us feed;
and for his sheep he doth us take.
3 O enter then his gates with praise;
approach with joy his courts unto;
praise, laud, and bless his name always,
for it is seemly so to do.
4 For why, the Lord our God is good;
his mercy is for ever sure;
his truth at all times firmly stood,
and shall from age to age endure.
5 To Father, Son and Holy Ghost,
the God whom heaven and earth adore,
from earth and from the angel host
be praise and glory evermore.
John Newton (d. 1807)
Reproduced from Singing the Faith Electronic Words Edition, number 1 - or not as this is a hand made test file