diff --git a/openlp/migration/__init__.py b/openlp/migration/__init__.py deleted file mode 100644 index 1a348a0df..000000000 --- a/openlp/migration/__init__.py +++ /dev/null @@ -1,24 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2010 Raoul Snyman # -# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # -# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin # -# Thompson, Jon Tibble, Carsten Tinggaard # -# --------------------------------------------------------------------------- # -# This program is free software; you can redistribute it and/or modify it # -# under the terms of the GNU General Public License as published by the Free # -# Software Foundation; version 2 of the License. # -# # -# This program is distributed in the hope that it will be useful, but WITHOUT # -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # -# more details. # -# # -# You should have received a copy of the GNU General Public License along # -# with this program; if not, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -############################################################################### diff --git a/openlp/migration/display.py b/openlp/migration/display.py deleted file mode 100644 index abe991075..000000000 --- a/openlp/migration/display.py +++ /dev/null @@ -1,42 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2010 Raoul Snyman # -# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # -# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin # -# Thompson, Jon Tibble, Carsten Tinggaard # -# --------------------------------------------------------------------------- # -# This program is free software; you can redistribute it and/or modify it # -# under the terms of the GNU General Public License as published by the Free # -# Software Foundation; version 2 of the License. # -# # -# This program is distributed in the hope that it will be useful, but WITHOUT # -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # -# more details. # -# # -# You should have received a copy of the GNU General Public License along # -# with this program; if not, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -############################################################################### - -import logging - -log = logging.getLogger(__name__) - -class Display(object): - log.info(u'Display Class loaded') - - @staticmethod - def output(string): - log.debug(string) - #print (string) - - @staticmethod - def sub_output(string): - if not string is None: - log.debug(u' '+string) - #print (u' '+string) diff --git a/openlp/migration/migratebibles.py b/openlp/migration/migratebibles.py deleted file mode 100644 index 89bb5ffdf..000000000 --- a/openlp/migration/migratebibles.py +++ /dev/null @@ -1,198 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2010 Raoul Snyman # -# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # -# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin # -# Thompson, Jon Tibble, Carsten Tinggaard # -# --------------------------------------------------------------------------- # -# This program is free software; you can redistribute it and/or modify it # -# under the terms of the GNU General Public License as published by the Free # -# Software Foundation; version 2 of the License. # -# # -# This program is distributed in the hope that it will be useful, but WITHOUT # -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # -# more details. # -# # -# You should have received a copy of the GNU General Public License along # -# with this program; if not, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -############################################################################### - -import os -import sys -import sqlite3 - -from sqlalchemy.exceptions import InvalidRequestError -from sqlalchemy.orm import mapper - -from openlp.core.lib import BaseModel, SettingsManager -from openlp.core.utils import AppLocation -from openlp.plugins.bibles.lib.models import * - -class TBibleMeta(BaseModel): - """ - Bible Meta Data - """ - pass - -class TTestament(BaseModel): - """ - Bible Testaments - """ - pass - -class TBook(BaseModel): - """ - Song model - """ - pass - -class TVerse(BaseModel): - """ - Topic model - """ - pass - -temp_meta_table = Table(u'metadata_temp', metadata, - Column(u'key', types.Unicode(255), primary_key=True), - Column(u'value', types.Unicode(255)), -) -temp_testament_table = Table(u'testament_temp', metadata, - Column(u'id', types.Integer, primary_key=True), - Column(u'name', types.Unicode(30)), -) -temp_book_table = Table(u'book_temp', metadata, - Column(u'id', types.Integer, primary_key=True), - Column(u'testament_id', types.Integer), - Column(u'name', types.Unicode(30)), - Column(u'abbreviation', types.Unicode(5)), -) -temp_verse_table = Table(u'verse_temp', metadata, - Column(u'id', types.Integer, primary_key=True), - Column(u'book_id', types.Integer), - Column(u'chapter', types.Integer), - Column(u'verse', types.Integer), - Column(u'text', types.UnicodeText), -) - -mapper(TBibleMeta, temp_meta_table) -mapper(TTestament, temp_testament_table) -mapper(TBook, temp_book_table) -mapper(TVerse, temp_verse_table) - -class MigrateBibles(object): - def __init__(self, display): - self.display = display - self.data_path = AppLocation.get_section_data_path(u'bibles') - self.database_files = SettingsManager.get_files(u'bibles', u'.sqlite') - print self.database_files - - def progress(self, text): - print text - self.display.output(text) - - def process(self): - self.progress(u'Bibles processing started') - for db_file in self.database_files: - self.v_1_9_0(db_file) - self.progress(u'Bibles processing finished') - - def v_1_9_0(self, database): - self.progress(u'Migration 1.9.0 Started for ' + database) - self._v1_9_0_old(database) - self._v1_9_0_new(database) - self._v1_9_0_cleanup(database) - self.progress(u'Migration 1.9.0 Finished for ' + database) - - def _v1_9_0_old(self, database): - self.progress(u'Rename Tables ' + database) - conn = sqlite3.connect(os.path.join(self.data_path, database)) - conn.execute(u'alter table book rename to book_temp;') - conn.commit() - conn.execute(u'alter table testament rename to testament_temp;') - conn.commit() - conn.execute(u'alter table verse rename to verse_temp;') - conn.commit() - conn.execute(u'alter table metadata rename to metadata_temp;') - conn.commit() - - def _v1_9_0_new(self, database): - self.progress(u'Create new Tables ' + database) - self.db_url = u'sqlite:///' + self.data_path + u'/' + database - print self.db_url - self.session = init_models(self.db_url) - metadata.create_all(checkfirst=True) - self.progress(u'Create testament table') - results = self.session.query(TTestament).order_by(TTestament.id).all() - for testament_temp in results: - testament = Testament() - testament.id = testament_temp.id - testament.name = testament_temp.name - try: - self.session.add(testament) - self.session.commit() - except InvalidRequestError: - self.session.rollback() - print u'Error thrown = ', sys.exc_info()[1] - self.progress(u'Create book table') - results = self.session.query(TBook).order_by(TBook.id).all() - for book_temp in results: - book = Book() - book.id = book_temp.id - book.testament_id = book_temp.testament_id - book.name = book_temp.name - book.abbreviation = book_temp.abbreviation - try: - self.session.add(book) - self.session.commit() - except InvalidRequestError: - self.session.rollback() - print u'Error thrown = ', sys.exc_info()[1] - self.progress(u'Create verse table') - results = self.session.query(TVerse).order_by(TVerse.id).all() - for verse_temp in results: - verse = Verse() - verse.id = verse_temp.id - verse.book_id = verse_temp.book_id - verse.chapter = verse_temp.chapter - verse.verse = verse_temp.verse - verse.text = verse_temp.text - try: - self.session.add(verse) - self.session.commit() - except InvalidRequestError: - self.session.rollback() - print u'Error thrown = ', sys.exc_info()[1] - self.progress(u'Create metadata table') - results = self.session.query(TBibleMeta).order_by(TBibleMeta.key).all() - for biblemeta_temp in results: - biblemeta = BibleMeta() - biblemeta.key = biblemeta_temp.key - biblemeta.value = biblemeta_temp.value - try: - self.session.add(biblemeta) - self.session.commit() - except InvalidRequestError: - self.session.rollback() - print u'Error thrown = ', sys.exc_info()[1] - - def _v1_9_0_cleanup(self, database): - self.progress(u'Update Internal Data ' + database) - conn = sqlite3.connect(os.path.join(self.data_path, database)) - conn.commit() - conn.execute(u'drop table book_temp;') - conn.commit() - conn.execute(u'drop table testament_temp;') - conn.commit() - conn.execute(u'drop table verse_temp;') - conn.commit() - conn.execute(u'drop table metadata_temp;') - conn.commit() - conn.execute(u'vacuum;') - conn.commit() - diff --git a/openlp/migration/migratefiles.py b/openlp/migration/migratefiles.py deleted file mode 100644 index 91fff144d..000000000 --- a/openlp/migration/migratefiles.py +++ /dev/null @@ -1,54 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2010 Raoul Snyman # -# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # -# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin # -# Thompson, Jon Tibble, Carsten Tinggaard # -# --------------------------------------------------------------------------- # -# This program is free software; you can redistribute it and/or modify it # -# under the terms of the GNU General Public License as published by the Free # -# Software Foundation; version 2 of the License. # -# # -# This program is distributed in the hope that it will be useful, but WITHOUT # -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # -# more details. # -# # -# You should have received a copy of the GNU General Public License along # -# with this program; if not, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -############################################################################### - -from openlp.core.utils import AppLocation - -class MigrateFiles(object): - def __init__(self, display): - self.display = display - - def process(self): - self.display.output(u'Files process started') - self._initial_setup() - self.display.output(u'Files process finished') - - def _initial_setup(self): - self.display.output(u'Initial Setup started') - data_path = AppLocation.get_data_path() - print data_path - self.display.sub_output(u'Config created') - bibles_path = AppLocation.get_section_data_path(u'bibles') - print bibles_path - self.display.sub_output(u'Config created') - # Media doesn't use a directory like the other plugins. - #media_path = AppLocation.get_section_data_path(u'media') - #self.display.sub_output(u'videos created') - images_path = AppLocation.get_section_data_path(u'images') - print images_path - self.display.sub_output(u'images created') - presentations_path = AppLocation.get_section_data_path(u'presentations') - print presentations_path - self.display.sub_output(u'presentations created') - self.display.output(u'Initial Setup finished') diff --git a/openlp/migration/migratesongs.py b/openlp/migration/migratesongs.py deleted file mode 100644 index 87d5de40b..000000000 --- a/openlp/migration/migratesongs.py +++ /dev/null @@ -1,186 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2010 Raoul Snyman # -# Portions copyright (c) 2008-2010 Tim Bentley, Jonathan Corwin, Michael # -# Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin # -# Thompson, Jon Tibble, Carsten Tinggaard # -# --------------------------------------------------------------------------- # -# This program is free software; you can redistribute it and/or modify it # -# under the terms of the GNU General Public License as published by the Free # -# Software Foundation; version 2 of the License. # -# # -# This program is distributed in the hope that it will be useful, but WITHOUT # -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # -# more details. # -# # -# You should have received a copy of the GNU General Public License along # -# with this program; if not, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -############################################################################### - -import os -import sys -import sqlite3 - -from sqlalchemy import create_engine -from sqlalchemy.exceptions import InvalidRequestError -from sqlalchemy.orm import scoped_session, sessionmaker, mapper, relation - -from openlp.core.lib import BaseModel, SettingsManager -from openlp.core.utils import AppLocation -from openlp.plugins.songs.lib.models import metadata, songs_table, Song, \ - Author, Topic, Book -from openlp.plugins.songs.lib.tables import * -from openlp.plugins.songs.lib.classes import * - -def init_models(url): - engine = create_engine(url) - metadata.bind = engine - session = scoped_session( - sessionmaker(autoflush=True, autocommit=False, bind=engine)) - mapper(Author, authors_table) - mapper(TAuthor, temp_authors_table) - mapper(Book, song_books_table) - mapper(Song, songs_table, - properties={'authors': relation(Author, backref='songs', - secondary=authors_songs_table), - 'book': relation(Book, backref='songs'), - 'topics': relation(Topic, backref='songs', - secondary=songs_topics_table)}) - mapper(TSong, temp_songs_table) - mapper(TSongAuthor, temp_authors_songs_table) - mapper(Topic, topics_table) - return session - -temp_authors_table = Table(u'authors_temp', metadata, - Column(u'authorid', types.Integer, primary_key=True), - Column(u'authorname', String(40)) -) - -temp_songs_table = Table(u'songs_temp', metadata, - Column(u'songid', types.Integer, primary_key=True), - Column(u'songtitle', String(60)), - Column(u'lyrics', types.UnicodeText), - Column(u'copyrightinfo', String(255)), - Column(u'settingsid', types.Integer) -) - -# Definition of the "authors_songs" table -temp_authors_songs_table = Table(u'songauthors_temp', metadata, - Column(u'authorid', types.Integer, primary_key=True), - Column(u'songid', types.Integer) -) - -class TAuthor(BaseModel): - """ - Author model - """ - pass - -class TSong(BaseModel): - """ - Author model - """ - pass - -class TSongAuthor(BaseModel): - """ - Author model - """ - pass - -class MigrateSongs(object): - def __init__(self, display): - self.display = display - self.data_path = AppLocation.get_section_data_path(u'songs') - self.database_files = SettingsManager.get_files(u'songs', u'.sqlite') - print self.database_files - - def process(self): - self.display.output(u'Songs processing started') - for f in self.database_files: - self.v_1_9_0(f) - self.display.output(u'Songs processing finished') - - def v_1_9_0(self, database): - self.display.output(u'Migration 1.9.0 Started for ' + database) - self._v1_9_0_old(database) - self._v1_9_0_new(database) - self._v1_9_0_cleanup(database) - self.display.output(u'Migration 1.9.0 Finished for ' + database) - - def _v1_9_0_old(self, database): - self.display.sub_output(u'Rename Tables ' + database) - conn = sqlite3.connect(self.data_path + os.sep + database) - conn.execute(u'alter table authors rename to authors_temp;') - conn.commit() - conn.execute(u'alter table songs rename to songs_temp;') - conn.commit() - conn.execute(u'alter table songauthors rename to songauthors_temp;') - conn.commit() - - def _v1_9_0_new(self, database): - self.display.sub_output(u'Create new Tables ' + database) - self.db_url = u'sqlite:///' + self.data_path + u'/songs.sqlite' - print self.db_url - self.session = init_models(self.db_url) - metadata.create_all(checkfirst=True) - results = self.session.query(TSong).order_by(TSong.songid).all() - for songs_temp in results: - song = Song() - song.title = songs_temp.songtitle - song.lyrics = songs_temp.lyrics.replace(u'\r\n', u'\n') - song.copyright = songs_temp.copyrightinfo - song.search_title = u'' - song.search_lyrics = u'' - print songs_temp.songtitle - aa = self.session.execute( - u'select * from songauthors_temp where songid =' + \ - unicode(songs_temp.songid)) - for row in aa: - a = row['authorid'] - authors_temp = self.session.query(TAuthor).get(a) - bb = self.session.execute( - u'select * from authors where display_name = \"%s\"' % \ - unicode(authors_temp.authorname)).fetchone() - if bb is None: - author = Author() - author.display_name = authors_temp.authorname - author.first_name = u'' - author.last_name = u'' - else: - author = self.session.query(Author).get(bb[0]) - song.authors.append(author) - try: - self.session.add(song) - self.session.commit() - except InvalidRequestError: - self.session.rollback() - print u'Error thrown = ', sys.exc_info()[1] - - def _v1_9_0_cleanup(self, database): - self.display.sub_output(u'Update Internal Data ' + database) - conn = sqlite3.connect(self.data_path + os.sep + database) - conn.execute("""update songs set search_title = - replace(replace(replace(replace(replace(replace(replace(replace( - replace(title, '&', 'and'), ',', ''), ';', ''), ':', ''), - '(u', ''), ')', ''), '{', ''), '}',''),'?','');""") - conn.execute("""update songs set search_lyrics = - replace(replace(replace(replace(replace(replace(replace(replace( - replace(lyrics, '&', 'and'), ',', ''), ';', ''), ':', ''), - '(u', ''), ')', ''), '{', ''), '}',''),'?','') - ;""") - conn.commit() - conn.execute(u'drop table authors_temp;') - conn.commit() - conn.execute(u'drop table songs_temp;') - conn.commit() - conn.execute(u'drop table songauthors_temp;') - conn.commit() - conn.execute(u'drop table settings;') - conn.commit() diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 0bdff1897..c6d6f678b 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -297,8 +297,10 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): author = Author.populate(display_name=text) self.songmanager.save_author(author) self.song.authors.append(author) - author_item = QtGui.QListWidgetItem(unicode(author.display_name)) - author_item.setData(QtCore.Qt.UserRole, QtCore.QVariant(author.id)) + author_item = QtGui.QListWidgetItem( + unicode(author.display_name)) + author_item.setData(QtCore.Qt.UserRole, + QtCore.QVariant(author.id)) self.AuthorsListView.addItem(author_item) self.loadAuthors() self.AuthorsSelectionComboItem.setCurrentIndex(0) @@ -348,7 +350,8 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.songmanager.save_topic(topic) self.song.topics.append(topic) topic_item = QtGui.QListWidgetItem(unicode(topic.name)) - topic_item.setData(QtCore.Qt.UserRole, QtCore.QVariant(topic.id)) + topic_item.setData(QtCore.Qt.UserRole, + QtCore.QVariant(topic.id)) self.TopicsListView.addItem(topic_item) self.loadTopics() self.SongTopicCombo.setCurrentIndex(0)