This commit is contained in:
Samuel Mehrbrodt 2014-08-18 21:04:46 +02:00
parent 63f08f0c4a
commit 0bf256070a
5 changed files with 40 additions and 15 deletions

View File

@ -55,11 +55,11 @@ class ProPresenterImport(SongImport):
return return
self.import_wizard.increment_progress_bar(WizardStrings.ImportingType % os.path.basename(file_path)) self.import_wizard.increment_progress_bar(WizardStrings.ImportingType % os.path.basename(file_path))
root = objectify.parse(open(file_path, 'rb')).getroot() root = objectify.parse(open(file_path, 'rb')).getroot()
self.process_song(root) self.process_song(root, file_path)
def process_song(self, root): def process_song(self, root, filename):
self.set_defaults() self.set_defaults()
self.title = root.get('CCLISongTitle') self.title = os.path.basename(filename).rstrip('.pro4')
self.copyright = root.get('CCLICopyrightInfo') self.copyright = root.get('CCLICopyrightInfo')
self.comments = root.get('notes') self.comments = root.get('notes')
self.ccli_number = root.get('CCLILicenseNumber') self.ccli_number = root.get('CCLILicenseNumber')
@ -77,8 +77,5 @@ class ProPresenterImport(SongImport):
rtf = base64.standard_b64decode(RTFData) rtf = base64.standard_b64decode(RTFData)
words, encoding = strip_rtf(rtf.decode()) words, encoding = strip_rtf(rtf.decode())
self.add_verse(words, "v%d" % count) self.add_verse(words, "v%d" % count)
# Some songs don't have a title - use the first line as title
if not self.title:
self.title = self.guess_title()
if not self.finish(): if not self.finish():
self.log_error(self.import_source) self.log_error(self.import_source)

View File

@ -316,15 +316,6 @@ class SongImport(QtCore.QObject):
self.verse_order_list_generated.append(self.verse_order_list_generated[-1]) self.verse_order_list_generated.append(self.verse_order_list_generated[-1])
self.verse_order_list_generated_useful = True self.verse_order_list_generated_useful = True
def guess_title(self):
"""
Guess the title from the first verse (to be used when the song has no title information)
:return: The guessed title
"""
if not self.verses:
return ''
return self.verses[0][1].split('\n')[0].strip()
def check_complete(self): def check_complete(self):
""" """
Check the mandatory fields are entered (i.e. title and a verse) Check the mandatory fields are entered (i.e. title and a verse)

View File

@ -52,3 +52,5 @@ class TestProPresenterFileImport(SongImportTestHelper):
""" """
self.file_import([os.path.join(TEST_PATH, 'Amazing Grace.pro4')], self.file_import([os.path.join(TEST_PATH, 'Amazing Grace.pro4')],
self.load_external_result_data(os.path.join(TEST_PATH, 'Amazing Grace.json'))) self.load_external_result_data(os.path.join(TEST_PATH, 'Amazing Grace.json')))
self.file_import([os.path.join(TEST_PATH, 'Vaste Grond.pro4')],
self.load_external_result_data(os.path.join(TEST_PATH, 'Vaste Grond.json')))

View File

@ -0,0 +1,34 @@
{
"title": "Vaste Grond",
"verse_order_list": [],
"verses": [
[
"God voor U is niets onmogelijk\nHoe ongelofelijk\nU heeft alles in de hand",
"v1"
],
[
"U bent God en trekt Uw eigen plan\nU bent voor niemand bang\nVoor niets en niemand bang",
"v2"
],
[
"U houd me vast en geeft me moed\nOm door te gaan als ik niet durf\nIk wil van U zijn",
"v3"
],
[
"U geeft me kracht, en bent de vaste grond\nwaarop ik stevig sta\nik wil van U zijn, voor altijd van U zijn\nO God.",
"v4"
],
[
"Grote God, U bent uitzonderlijk\nen ondoorgrondelijk\nU biedt Uw liefde aan",
"v5"
],
[
"Wie ben ik, dat U mij ziet staan\nen met mij om wilt gaan?\nIk kan U niet weerstaan",
"v6"
],
[
"Onweerstaanbaar,\nonweerstaanbare God",
"v7"
]
]
}

File diff suppressed because one or more lines are too long