mirror of https://gitlab.com/openlp/openlp.git
Merge branch 'issue-1239' into 'master'
Fix OpenLyrics import error, and save dialog error Closes #1239 See merge request openlp/openlp!522
This commit is contained in:
commit
4aa01953bc
|
@ -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
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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'</lines>', 1)[0] + b'</lines>'
|
||||
if b'</lines>' in string_lines:
|
||||
string_lines = string_lines.split(b'</lines>', 1)[0] + b'</lines>'
|
||||
elif b'<lines/>' in string_lines:
|
||||
string_lines = string_lines.split(b'<lines/>', 1)[0] + b'<lines/>'
|
||||
element = etree.XML(string_lines)
|
||||
|
||||
# OpenLyrics 0.8 uses <br/> for new lines. Append text from "lines" element to verse text.
|
||||
|
|
|
@ -45,6 +45,7 @@ VERSE_LINES_08_XML = '<lines>\
|
|||
Amazing grace, how sweet the sound<br/>\
|
||||
That saved a wretch like me\
|
||||
</lines>'
|
||||
VERSE_LINES_EMPTY_XML = '<lines/>'
|
||||
AUTHOR_XML = '<properties>\
|
||||
<authors>\
|
||||
<author type="words">Test Author1</author>\
|
||||
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue