diff --git a/openlp/core/widgets/dialogs.py b/openlp/core/widgets/dialogs.py index 464875a37..f038c3af6 100644 --- a/openlp/core/widgets/dialogs.py +++ b/openlp/core/widgets/dialogs.py @@ -102,7 +102,6 @@ class FileDialog(QtWidgets.QFileDialog): :rtype: tuple[pathlib.Path | None, str] """ args, kwargs = replace_params(args, kwargs, ((2, 'directory', path_to_str),)) - file_name, selected_filter = super().getSaveFileName(*args, **kwargs) # getSaveFileName returns a tuple. The first item represents the path as a str. The string is empty if the user diff --git a/openlp/plugins/songs/forms/songimportform.py b/openlp/plugins/songs/forms/songimportform.py index 96542e0f1..ac6d7cee1 100644 --- a/openlp/plugins/songs/forms/songimportform.py +++ b/openlp/plugins/songs/forms/songimportform.py @@ -348,8 +348,9 @@ class SongImportForm(OpenLPWizard, RegistryProperties): :rtype: None """ - file_path, filter_used = FileDialog.getSaveFileName( - self, self.settings.value('songs/last directory import')) + file_path, filter_used = FileDialog.getSaveFileName(self, + translate('SongPlugin.SongImporter', 'Save Error File'), + self.settings.value('songs/last directory import')) if file_path is None: return file_path.write_text(self.error_report_text_edit.toPlainText(), encoding='utf-8') diff --git a/openlp/plugins/songs/lib/openlyricsxml.py b/openlp/plugins/songs/lib/openlyricsxml.py index c569541db..31e3e222b 100644 --- a/openlp/plugins/songs/lib/openlyricsxml.py +++ b/openlp/plugins/songs/lib/openlyricsxml.py @@ -686,7 +686,10 @@ class OpenLyrics(object): string_lines = etree.tostring(lines) # lxml 4.6.x or some recent version of libxml2 seems to add the rest of the song to the string, so split on the # closing verse tag, and then add it back in - string_lines = string_lines.split(b'', 1)[0] + b'' + if b'' in string_lines: + string_lines = string_lines.split(b'', 1)[0] + b'' + elif b'' in string_lines: + string_lines = string_lines.split(b'', 1)[0] + b'' element = etree.XML(string_lines) # OpenLyrics 0.8 uses
for new lines. Append text from "lines" element to verse text. diff --git a/tests/openlp_plugins/songs/test_openlyricsxml.py b/tests/openlp_plugins/songs/test_openlyricsxml.py index e31b0a028..cb532a485 100644 --- a/tests/openlp_plugins/songs/test_openlyricsxml.py +++ b/tests/openlp_plugins/songs/test_openlyricsxml.py @@ -45,6 +45,7 @@ VERSE_LINES_08_XML = '\ Amazing grace, how sweet the sound
\ That saved a wretch like me\
' +VERSE_LINES_EMPTY_XML = '' AUTHOR_XML = '\ \ Test Author1\ @@ -104,6 +105,21 @@ def test_process_verse_lines_v08(): ' That saved a wretch like me ' +def test_process_empty_verse_lines(): + """ + Test that _process_verse_lines() correctly handles empty verse lines + """ + # GIVEN: An empty lines object with additional content + open_lyrics = OpenLyrics(MagicMock()) + lines = objectify.fromstring(VERSE_LINES_EMPTY_XML) + + # WHEN: The lyrics of a verse are processed + result = open_lyrics._process_verse_lines(lines, '0.8') + + # THEN: The results should be correct + assert result == '' + + def test_process_formatting_tags(settings): """ Test that _process_formatting_tags works