songimport¶
-
class
openlp.plugins.songs.lib.importers.songimport.
SongImport
(manager, **kwargs)[source]¶ Bases:
PyQt5.QtCore.QObject
Helper class for import a song from a third party source into OpenLP
This class just takes the raw strings, and will work out for itself whether the authors etc already exist and add them or refer to them as necessary
Add an author to the list
-
add_verse
(verse_text, verse_def='v', lang=None)[source]¶ Add a verse. This is the whole verse, lines split by n. It will also attempt to detect duplicates. In this case it will just add to the verse order.
Parameters: - verse_text – The text of the verse.
- verse_def – The verse tag can be v1/c1/b etc, or ‘v’ and ‘c’ (will count the verses/choruses itself) or None, where it will assume verse.
- lang – The language code (ISO-639) of the verse, for example en or de.
-
check_complete
()[source]¶ Check the mandatory fields are entered (i.e. title and a verse) Author not checked here, if no author then “Author unknown” is automatically added
-
copy_media_file
(song_id, filename)[source]¶ This method copies the media file to the correct location and returns the new file location.
Parameters: - song_id –
- filename – The file to copy.
-
static
is_valid_source
(import_source)[source]¶ Override this method to validate the source prior to import.
-
log_error
(file_path, reason='Title and/or verses not found')[source]¶ This should be called, when a song could not be imported.
Parameters: - file_path – This should be the file path if
self.import_source
is a list with different files. If it is not a list, but a single file (for instance a database), then this should be the song’s title. - reason – The reason why the import failed. The string should be as informative as possible.
- file_path – This should be the file path if
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’.
-
parse_song_book_name_and_number
(book_and_number)[source]¶ Build the book name and song number from a single string
-
process_verse_text
(text)[source]¶ Process the song verse text from import
Parameters: text – Some text
-
repeat_verse
(verse_def=None)[source]¶ Repeat the verse with the given verse_def or default to repeating the previous verse in the verse order
Parameters: verse_def – verse_def of the verse to be repeated