Hi Gary,
One other thing. The person I imported their EW6 database for said that the
importer added the title of each verse at the top of each verse, so Verse 1
would start with "Verse 1" and then the rest of the lines of the verse. I don't
see anything like that in your code, but I thought I'd just check that with you
any way.
Diff comments:
>
> === modified file 'openlp/plugins/songs/lib/importers/easyworship.py'
> --- openlp/plugins/songs/lib/importers/easyworship.py 2016-12-31 11:01:36
> +0000
> +++ openlp/plugins/songs/lib/importers/easyworship.py 2017-03-31 01:18:28
> +0000
> @@ -337,6 +340,84 @@
> db_file.close()
> self.memo_file.close()
>
> + def _find_file(self, base_path, path_list):
> + """
> + Find the specified file, with the option of the file being at any
> level in the specified directory structure.
> +
> + :param base_path: the location search in
> + :param path_list: the targeted file, preceded by directories that
> may be their parents relative to the base_path
> + :return: path for targeted file
> + """
> + target_file = ''
> + while len(path_list) > 0:
> + target_file = os.path.join(path_list[len(path_list) - 1],
> target_file)
You can just use path_list[-1] to get the last element in the list.
> + path_list = path_list[:len(path_list) - 1]
> + full_path = os.path.join(base_path, target_file)
> + full_path = full_path[:len(full_path) - 1]
> + if os.path.isfile(full_path):
> + return full_path
> + return ''
> +
> + def import_sqlite_db(self):
> + """
> + Import the songs from an EasyWorship 6 SQLite database
> + """
> + songs_db_path = self._find_file(self.import_source, ["Databases",
> "Data", "Songs.db"])
> + song_words_db_path = self._find_file(self.import_source,
> ["Databases", "Data", "SongWords.db"])
> + # check to see if needed files are there
> + if not os.path.isfile(songs_db_path):
> + self.log_error(songs_db_path,
> translate('SongsPlugin.EasyWorshipSongImport',
> + 'This file does not
> exist.'))
> + return
> + if not os.path.isfile(song_words_db_path):
> + self.log_error(song_words_db_path,
> translate('SongsPlugin.EasyWorshipSongImport',
> + 'Could not find the
> "Songs.MB" file. It must be in the same '
> + 'folder as the
> "Songs.DB" file.'))
> + return
> + # get database handles
> + songs_conn = sqlite3.connect(songs_db_path)
> + words_conn = sqlite3.connect(song_words_db_path)
> + if songs_conn is None or words_conn is None:
> + self.log_error(self.import_source,
> translate('SongsPlugin.EasyWorshipSongImport',
> + 'This is not a
> valid Easy Worship 6 database.'))
> + songs_conn.close()
> + words_conn.close()
> + return
> + songs_db = songs_conn.cursor()
> + words_db = words_conn.cursor()
> + if songs_conn is None or words_conn is None:
> + self.log_error(self.import_source,
> translate('SongsPlugin.EasyWorshipSongImport',
> + 'This is not a
> valid Easy Worship 6 database.'))
> + songs_conn.close()
> + words_conn.close()
> + return
> + # Take a stab at how text is encoded
> + self.encoding = 'cp1252'
> + self.encoding = retrieve_windows_encoding(self.encoding)
> + if not self.encoding:
> + log.debug('No encoding set.')
> + return
> + # import songs
> + songs = songs_db.execute('SELECT
> rowid,title,author,copyright,vendor_id FROM song;')
> + for song in songs:
> + song_id = song[0]
> + # keep extra copy of title for error message because error check
> clears it
> + self.title = title = song[1]
> + self.author = song[2]
> + self.copyright = song[3]
> + self.ccli_number = song[4]
> + words = words_db.execute('SELECT words FROM word WHERE song_id =
> ?;', (song_id,))
> + self.set_song_import_object(self.author,
> words.fetchone()[0].encode())
> + if not self.finish():
> + self.log_error(self.import_source,
> + translate('SongsPlugin.EasyWorshipSongImport',
> + '"{title}" could not be imported.
> {entry}').
> + format(title=title,
> entry=self.entry_error_log))
> + # close database handles
> + songs_conn.close()
> + words_conn.close()
> + return
> +
> def set_song_import_object(self, authors, words):
> """
> Set the SongImport object members.
--
https://code.launchpad.net/~gtalent/openlp/easyworship6/+merge/321504
Your team OpenLP Core is subscribed to branch lp:openlp.
_______________________________________________
Mailing list: https://launchpad.net/~openlp-core
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openlp-core
More help : https://help.launchpad.net/ListHelp