From e52a80c9c3fb09d3880e640fdc79324fe0388283 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sat, 12 Mar 2011 11:23:42 +0100 Subject: [PATCH 01/97] rename httpbooks.sqlite to bibles_resources.sqlite and change database scheme moved the content of biblegateway.csv, bibleserver.csv and crosswalkbooks.csv into bibles_resources.sqlite adapt loadWebBibles() process according to the changes above remove class HTTPBible from http.py and add the functions to a new class BiblesResourcesDB in db.py which now handels the reading of bibles_resources.sqlite --- .../plugins/bibles/forms/bibleimportform.py | 44 ++-- openlp/plugins/bibles/lib/db.py | 192 ++++++++++++++++++ openlp/plugins/bibles/lib/http.py | 146 +------------ .../plugins/bibles/resources/biblegateway.csv | 81 -------- .../bibles/resources/bibles_resources.sqlite | Bin 0 -> 63488 bytes .../plugins/bibles/resources/bibleserver.csv | 39 ---- .../bibles/resources/crosswalkbooks.csv | 27 --- .../plugins/bibles/resources/httpbooks.sqlite | Bin 45056 -> 0 bytes 8 files changed, 210 insertions(+), 319 deletions(-) delete mode 100644 openlp/plugins/bibles/resources/biblegateway.csv create mode 100644 openlp/plugins/bibles/resources/bibles_resources.sqlite delete mode 100644 openlp/plugins/bibles/resources/bibleserver.csv delete mode 100644 openlp/plugins/bibles/resources/crosswalkbooks.csv delete mode 100644 openlp/plugins/bibles/resources/httpbooks.sqlite diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 7967b2ec4..9fee25654 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -39,6 +39,7 @@ from openlp.core.lib.ui import UiStrings, critical_error_message_box from openlp.core.ui.wizard import OpenLPWizard, WizardStrings from openlp.core.utils import AppLocation, string_is_unicode from openlp.plugins.bibles.lib.manager import BibleFormat +from openlp.plugins.bibles.lib.db import BiblesResourcesDB log = logging.getLogger(__name__) @@ -634,46 +635,27 @@ class BibleImportForm(OpenLPWizard): """ Load the lists of Crosswalk, BibleGateway and Bibleserver bibles. """ - filepath = AppLocation.get_directory(AppLocation.PluginsDir) - filepath = os.path.join(filepath, u'bibles', u'resources') # Load Crosswalk Bibles. - self.loadBibleResourceFile( - os.path.join(filepath, u'crosswalkbooks.csv'), - WebDownload.Crosswalk) + self.loadBibleResource(WebDownload.Crosswalk) # Load BibleGateway Bibles. - self.loadBibleResourceFile(os.path.join(filepath, u'biblegateway.csv'), - WebDownload.BibleGateway) + self.loadBibleResource(WebDownload.BibleGateway) # Load and Bibleserver Bibles. - self.loadBibleResourceFile(os.path.join(filepath, u'bibleserver.csv'), - WebDownload.Bibleserver) + self.loadBibleResource(WebDownload.Bibleserver) - def loadBibleResourceFile(self, file_path_name, download_type): + def loadBibleResource(self, download_type): """ - Loads a web bible resource file. - - ``file_path_name`` - The file to load including the file's path. + Loads a web bible from bible_resources.sqlite. ``download_type`` - The WebDownload type this file is for. + The WebDownload type e.g. bibleserver. """ self.web_bible_list[download_type] = {} - books_file = None - try: - books_file = open(file_path_name, 'rb') - dialect = csv.Sniffer().sniff(books_file.read(1024)) - books_file.seek(0) - books_reader = csv.reader(books_file, dialect) - for line in books_reader: - ver = string_is_unicode(line[0]) - name = string_is_unicode(line[1]) - self.web_bible_list[download_type][ver] = name.strip() - except IOError: - log.exception(u'%s resources missing' % - WebDownload.Names[download_type]) - finally: - if books_file: - books_file.close() + bibles = BiblesResourcesDB.get_webbibles( + WebDownload.Names[download_type]) + for bible in bibles: + ver = bible[u'name'] + name = bible[u'abbreviation'] + self.web_bible_list[download_type][ver] = name.strip() def preWizard(self): """ diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 5cf000ee1..a1c8fb9a1 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -26,7 +26,9 @@ import logging import chardet +import os import re +import sqlite3 from PyQt4 import QtCore from sqlalchemy import Column, ForeignKey, or_, Table, types @@ -36,6 +38,7 @@ from sqlalchemy.orm.exc import UnmappedClassError from openlp.core.lib import Receiver, translate from openlp.core.lib.db import BaseModel, init_db, Manager from openlp.core.lib.ui import critical_error_message_box +from openlp.core.utils import AppLocation log = logging.getLogger(__name__) @@ -444,3 +447,192 @@ class BibleDB(QtCore.QObject, Manager): log.debug(u'...............................Verses ') verses = self.session.query(Verse).all() log.debug(verses) + + +class BiblesResourcesDB(QtCore.QObject, Manager): + """ + This class represents the database-bound Bible Resources. It provide + some resources which are used in the Bibles plugin. + A wrapper class around a small SQLite database which contains the download + resources, a biblelist from the different download resources, the books, + chapter counts and verse counts for the web download Bibles, a language + reference, the testament reference and some basic spelling variants. This + class contains a singleton "cursor" so that only one connection to the + SQLite database is ever used. + """ + cursor = None + + @staticmethod + def get_cursor(): + """ + Return the cursor object. Instantiate one if it doesn't exist yet. + """ + if BiblesResourcesDB.cursor is None: + filepath = os.path.join( + AppLocation.get_directory(AppLocation.PluginsDir), u'bibles', + u'resources', u'bibles_resources.sqlite') + conn = sqlite3.connect(filepath) + BiblesResourcesDB.cursor = conn.cursor() + return BiblesResourcesDB.cursor + + @staticmethod + def run_sql(query, parameters=()): + """ + Run an SQL query on the database, returning the results. + + ``query`` + The actual SQL query to run. + + ``parameters`` + Any variable parameters to add to the query. + """ + cursor = BiblesResourcesDB.get_cursor() + cursor.execute(query, parameters) + return cursor.fetchall() + + @staticmethod + def get_books(): + """ + Return a list of all the books of the Bible. + """ + books = BiblesResourcesDB.run_sql(u'SELECT id, testament_id, name, ' + u'abbreviation, chapters FROM book_reference ORDER BY id') + book_list = [] + for book in books: + book_list.append({ + u'id': book[0], + u'testament_id': book[1], + u'name': unicode(book[2]), + u'abbreviation': unicode(book[3]), + u'chapters': book[4] + }) + return book_list + + @staticmethod + def get_book(name): + """ + Return a book by name or abbreviation. + + ``name`` + The name or abbreviation of the book. + """ + if not isinstance(name, unicode): + name = unicode(name) + name = name.title() + books = BiblesResourcesDB.run_sql(u'SELECT id, testament_id, name, ' + u'abbreviation, chapters FROM book_reference WHERE name = ? OR ' + u'abbreviation = ?', (name, name)) + if books: + return { + u'id': books[0][0], + u'testament_id': books[0][1], + u'name': unicode(books[0][2]), + u'abbreviation': unicode(books[0][3]), + u'chapters': books[0][4] + } + else: + return None + + @staticmethod + def get_chapter(name, chapter): + """ + Return the chapter details for a specific chapter of a book. + + ``name`` + The name or abbreviation of a book. + + ``chapter`` + The chapter number. + """ + if not isinstance(name, int): + chapter = int(chapter) + book = BiblesResourcesDB.get_book(name) + chapters = BiblesResourcesDB.run_sql(u'SELECT id, book_reference_id, ' + u'chapter, verse_count FROM chapters WHERE book_reference_id = ?', + (book[u'id'],)) + if chapters: + return { + u'id': chapters[chapter-1][0], + u'book_reference_id': chapters[chapter-1][1], + u'chapter': chapters[chapter-1][2], + u'verse_count': chapters[chapter-1][3] + } + else: + return None + + @staticmethod + def get_chapter_count(book): + """ + Return the number of chapters in a book. + + ``book`` + The name or abbreviation of the book. + """ + details = BiblesResourcesDB.get_book(book) + if details: + return details[u'chapters'] + return 0 + + @staticmethod + def get_verse_count(book, chapter): + """ + Return the number of verses in a chapter. + + ``book`` + The name or abbreviation of the book. + + ``chapter`` + The number of the chapter. + """ + details = BiblesResourcesDB.get_chapter(book, chapter) + if details: + return details[u'verse_count'] + return 0 + + @staticmethod + def get_download_source(source): + """ + Return a download_source by source. + + ``name`` + The name or abbreviation of the book. + """ + if not isinstance(source, unicode): + source = unicode(source) + source = source.title() + #source = source.lower() + log.debug(u'Test: %s' % source) + dl_source = BiblesResourcesDB.run_sql(u'SELECT id, source FROM ' + u'download_source WHERE source = ?', (source.lower(),)) + if dl_source: + return { + u'id': dl_source[0][0], + u'source': dl_source[0][1] + } + else: + return None + + @staticmethod + def get_webbibles(source): + """ + Return the chapter details for a specific chapter of a book. + + ``name`` + The name of the webbible. + """ + if not isinstance(source, unicode): + source = unicode(source) + source = BiblesResourcesDB.get_download_source(source) + bibles = BiblesResourcesDB.run_sql(u'SELECT id, name, abbreviation, ' + u'language_id, download_source_id FROM webbibles WHERE ' + u'download_source_id = ?', (source[u'id'],)) + bibles_temp = [] + for bible in bibles: + bibles_temp.append({ + u'id': bible[0], + u'name': bible[1], + u'abbreviation': bible[2], + u'language_id': bible[3], + u'download_source_id': bible[4] + }) + return bibles_temp diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index e2dde59fd..d2202909c 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -41,146 +41,10 @@ from openlp.core.lib import Receiver, translate from openlp.core.lib.ui import critical_error_message_box from openlp.core.utils import AppLocation, get_web_page from openlp.plugins.bibles.lib import SearchResults -from openlp.plugins.bibles.lib.db import BibleDB, Book +from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB, Book log = logging.getLogger(__name__) -class HTTPBooks(object): - """ - A wrapper class around a small SQLite database which contains the books, - chapter counts and verse counts for the web download Bibles. This class - contains a singleton "cursor" so that only one connection to the SQLite - database is ever used. - """ - cursor = None - - @staticmethod - def get_cursor(): - """ - Return the cursor object. Instantiate one if it doesn't exist yet. - """ - if HTTPBooks.cursor is None: - filepath = os.path.join( - AppLocation.get_directory(AppLocation.PluginsDir), u'bibles', - u'resources', u'httpbooks.sqlite') - conn = sqlite3.connect(filepath) - HTTPBooks.cursor = conn.cursor() - return HTTPBooks.cursor - - @staticmethod - def run_sql(query, parameters=()): - """ - Run an SQL query on the database, returning the results. - - ``query`` - The actual SQL query to run. - - ``parameters`` - Any variable parameters to add to the query. - """ - cursor = HTTPBooks.get_cursor() - cursor.execute(query, parameters) - return cursor.fetchall() - - @staticmethod - def get_books(): - """ - Return a list of all the books of the Bible. - """ - books = HTTPBooks.run_sql(u'SELECT id, testament_id, name, ' - u'abbreviation, chapters FROM books ORDER BY id') - book_list = [] - for book in books: - book_list.append({ - u'id': book[0], - u'testament_id': book[1], - u'name': unicode(book[2]), - u'abbreviation': unicode(book[3]), - u'chapters': book[4] - }) - return book_list - - @staticmethod - def get_book(name): - """ - Return a book by name or abbreviation. - - ``name`` - The name or abbreviation of the book. - """ - if not isinstance(name, unicode): - name = unicode(name) - name = name.title() - books = HTTPBooks.run_sql(u'SELECT id, testament_id, name, ' - u'abbreviation, chapters FROM books WHERE name = ? OR ' - u'abbreviation = ?', (name, name)) - if books: - return { - u'id': books[0][0], - u'testament_id': books[0][1], - u'name': unicode(books[0][2]), - u'abbreviation': unicode(books[0][3]), - u'chapters': books[0][4] - } - else: - return None - - @staticmethod - def get_chapter(name, chapter): - """ - Return the chapter details for a specific chapter of a book. - - ``name`` - The name or abbreviation of a book. - - ``chapter`` - The chapter number. - """ - if not isinstance(name, int): - chapter = int(chapter) - book = HTTPBooks.get_book(name) - chapters = HTTPBooks.run_sql(u'SELECT id, book_id, chapter, ' - u'verses FROM chapters WHERE book_id = ?', (book[u'id'],)) - if chapters: - return { - u'id': chapters[chapter-1][0], - u'book_id': chapters[chapter-1][1], - u'chapter': chapters[chapter-1][2], - u'verses': chapters[chapter-1][3] - } - else: - return None - - @staticmethod - def get_chapter_count(book): - """ - Return the number of chapters in a book. - - ``book`` - The name or abbreviation of the book. - """ - details = HTTPBooks.get_book(book) - if details: - return details[u'chapters'] - return 0 - - @staticmethod - def get_verse_count(book, chapter): - """ - Return the number of verses in a chapter. - - ``book`` - The name or abbreviation of the book. - - ``chapter`` - The number of the chapter. - """ - details = HTTPBooks.get_chapter(book, chapter) - if details: - return details[u'verses'] - return 0 - - class BGExtract(object): """ Extract verses from BibleGateway @@ -447,7 +311,7 @@ class HTTPBible(BibleDB): book = reference[0] db_book = self.get_book(book) if not db_book: - book_details = HTTPBooks.get_book(book) + book_details = BiblesResourcesDB.get_book(book) if not book_details: critical_error_message_box( translate('BiblesPlugin', 'No Book Found'), @@ -497,13 +361,13 @@ class HTTPBible(BibleDB): Return the list of books. """ return [Book.populate(name=book['name']) - for book in HTTPBooks.get_books()] + for book in BiblesResourcesDB.get_books()] def get_chapter_count(self, book): """ Return the number of chapters in a particular book. """ - return HTTPBooks.get_chapter_count(book) + return BiblesResourcesDB.get_chapter_count(book) def get_verse_count(self, book, chapter): """ @@ -515,7 +379,7 @@ class HTTPBible(BibleDB): ``chapter`` The chapter whose verses are being counted. """ - return HTTPBooks.get_verse_count(book, chapter) + return BiblesResourcesDB.get_verse_count(book, chapter) def get_soup_for_bible_ref(reference_url, header=None, pre_parse_regex=None, pre_parse_substitute=None, cleaner=None): diff --git a/openlp/plugins/bibles/resources/biblegateway.csv b/openlp/plugins/bibles/resources/biblegateway.csv deleted file mode 100644 index ad8052704..000000000 --- a/openlp/plugins/bibles/resources/biblegateway.csv +++ /dev/null @@ -1,81 +0,0 @@ -João Ferreira de Almeida Atualizada,AA -التفسير التطبيقى للكتاب المقدس,ALAB -Shqip,ALB -Amplified Bible,AMP -Amuzgo de Guerrero,AMU -American Standard Version,ASV -La Bible du Semeur,BDS -Български 1940,BG1940 -Български,BULG -Chinanteco de Comaltepec,CCO -Contemporary English Version,CEV -Cakchiquel Occidental,CKW -Hrvatski,CRO -Castilian,CST -聖經和合本 (简体中文),CUVS -聖經和合本 (繁体中文),CUV -Darby Translation,DARBY -Dette er Biblen på dansk,DN1933 -Det Norsk Bibelselskap 1930,DNB1930 -English Standard Version,ESV -GOD’S WORD Translation,GW -Holman Christian Standard Bible,HCSB -Kreyòl ayisyen bib,HCV -Hiligaynon Bible,HLGN -Hoffnung für Alle,HOF -Het Boek,HTB -Icelandic Bible,ICELAND -Jacalteco – Oriental,JAC -Károlyi-biblia,KAR -Kekchi,KEK -21st Century King James Version,KJ21 -King James Version,KJV -La Biblia de las Américas,LBLA -Levande Bibeln,LB -La Parola è Vita,LM -La Nuova Diodati,LND -Louis Segond,LSG -Luther Bibel 1545,LUTH1545 -Māori Bible,MAORI -Македонски Новиот Завет,MNT -The Message,MSG -Mam de Comitancillo Central,MVC -Mam de Todos Santos Cuchumatán,MVJ -New American Standard Bible,NASB -New Century Version,NCV -Náhuatl de Guerrero,NGU -New International Reader's Version,NIRV -New International Version 1984,NIV1984 -New International Version 2010,NIV -New International Version - UK,NIVUK -New King James Version,NKJV -New Living Translation,NLT -Nádej pre kazdého,NPK -Nueva Versión Internacional,NVI -O Livro,OL -Quiché – Centro Occidental,QUT -Reimer 2001,REIMER -Română Cornilescu,RMNN -Новый перевод на русский язык,RUSV -Reina-Valera Antigua,RVA -Reina-Valera 1960,RVR1960 -Reina-Valera 1995,RVR1995 -Slovo na cestu,SNC -Ang Salita ng Diyos,SND -Swahili New Testament,SNT -Svenska 1917,SV1917 -Levande Bibeln,SVL -Создать страницу,SZ -Traducción en lenguaje actual,TLA -New Romanian Translation,TLCR -Today’s New International Version 2005,TNIV -Textus Receptus Stephanus 1550,TR1550 -Textus Receptus Scrivener 1894,TR1894 -Українська Біблія. Переклад Івана Огієнка,UKR -Uspanteco,USP -Kinh Thánh tiếng Việt 1934,VIET -Worldwide English (New Testament),WE -Codex Vaticanus Westcott-Hort 1881,WHNU -Westminster Leningrad Codex,WLC -Wycliffe New Testament,WYC -Young's Literal Translation,YLT diff --git a/openlp/plugins/bibles/resources/bibles_resources.sqlite b/openlp/plugins/bibles/resources/bibles_resources.sqlite new file mode 100644 index 0000000000000000000000000000000000000000..bcb45b8015c5cb6855a3c2d6c0aa821ce2324151 GIT binary patch literal 63488 zcmeIb34C1HStok#y;Y@ClBy(Cl~kqD;?nBUW?S+myKT3%*_Q3L-CnxmB%O}8w%uOa zOLx1oR+YBW3tLDaFd1gZFuVXWkYRf;c!4#MvFMIHm6ZwwgBy02omNniueU(cA+4EUwPs`Zm6=nlrC@*BdiO&4d{-$MK!R_lOxa z2Yq_wZ1c$el(~We`WK4qF{M$bqOGmXnVDFu+-Y+S|1KfUBIQ23(Do(K+EJmrsl>Pb zwWEz^G3at;(j4+DycZQcit8izo-|LO@<+`{TpvIsJMZ)Jcw@?UM&fHC2R3j5yMwF%(>}#e~NF@zc4p z`v!NNn{xiU^J(X&oPX<-oRiLgQ)m9ve8PN>`8pJIvLhWa18sFqJNSMRbzloFG&W~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~JWGjl6tz1ES=k_22{;KHMPJUGd7H!S3H93%Xd_5g=pa1ANFDU4 z@F&Ax2>+Mxm%=&oDg1sh{JHR_Kp#ea>%2V$Jf$dLOCe9IeyLV?wKZRA41d+v`&u2| ZtMyvtz$yn;Ik3usRSv9j;2)0z{|gx&Ns|Bo literal 0 HcmV?d00001 diff --git a/openlp/plugins/bibles/resources/bibleserver.csv b/openlp/plugins/bibles/resources/bibleserver.csv deleted file mode 100644 index 942d43116..000000000 --- a/openlp/plugins/bibles/resources/bibleserver.csv +++ /dev/null @@ -1,39 +0,0 @@ -عربي, ARA -Bible – překlad 21. století, B21 -Bible du Semeur, BDS -Българската Библия, BLG -Český ekumenický překlad, CEP -Hrvatski, CRO -Священное Писание, CRS -Version La Biblia al Dia, CST -中文和合本(简体), CUVS -Bibelen på hverdagsdansk, DK -Revidierte Elberfelder, ELB -Einheitsübersetzung, EU -Gute Nachricht Bibel, GNB -Hoffnung für alle, HFA -Hungarian, HUN -Het Boek, HTB -La Parola è Vita, ITA -IBS-fordítás (Új Károli), KAR -King James Version, KJV -Luther 1984, LUT -Septuaginta, LXX -Neue Genfer Übersetzung, NGU -New International Readers Version, NIRV -New International Version, NIV -Neues Leben, NL -En Levende Bok (NOR), NOR -Nádej pre kazdého, NPK -Noua traducere în limba românã, NTR -Nueva Versión Internacional, NVI -הברית הישנה, OT -Słowo Życia, POL -O Livro, PRT -Новый перевод на русский язык, RUS -Slovo na cestu, SNC -Schlachter 2000, SLT -En Levande Bok (SWE), SVL -Today's New International Version, TNIV -Türkçe, TR -Biblia Vulgata, VUL diff --git a/openlp/plugins/bibles/resources/crosswalkbooks.csv b/openlp/plugins/bibles/resources/crosswalkbooks.csv deleted file mode 100644 index 7957bfdc8..000000000 --- a/openlp/plugins/bibles/resources/crosswalkbooks.csv +++ /dev/null @@ -1,27 +0,0 @@ -New American Standard,nas -American Standard Version,asv -English Standard Version,esv -New King James Version,nkj -King James Version,kjv -Holman Christian Standard Bible,csb -Third Millennium Bible,tmb -New International Version,niv -New Living Translation,nlt -New Revised Standard,nrs -Revised Standard Version,rsv -Good News Translation,gnt -Douay-Rheims Bible,rhe -The Message,msg -The Complete Jewish Bible,cjb -New Century Version,ncv -GOD'S WORD Translation,gwd -Hebrew Names Version,hnv -World English Bible,web -The Bible in Basic English,bbe -Young's Literal Translation,ylt -Today's New International Version,tnv -New International Reader's Version,nrv -The Darby Translation,dby -The Webster Bible,wbt -The Latin Vulgate,vul -Weymouth New Testament,wnt diff --git a/openlp/plugins/bibles/resources/httpbooks.sqlite b/openlp/plugins/bibles/resources/httpbooks.sqlite deleted file mode 100644 index 406914b63cd5d3159f437b850840db4832113d13..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 45056 zcmeHw2Y6h?x%Qcvv%9m})k@lxw5#5`ELn2zwrt~qZHx=ufGakxxY9vdX?F!A0YVyS zq>|nX=^=si21!V{Bq5}bMo7O2r2OwUuNS$)&ArM0bAQW^=Y6M~bLPyP^UXKkd~HR_aj0k|k=eWxu!H+u-f+HhcTLD}dX){ot1%wi)pQ2zPlKpE1|W_f~ley?Ndm zg!KsLc>~@u$4`CQcAS2_w-XoWK77dzFFl|_4Gj${vv90(8@%24w;g51m_GSM8;>Z~ zhzhlP1qk`C5%;*slhh^N3RmGpsOT!hS0Y^EEl1^7dFLa3Cej7xd23PbELWb_T#g($ zwjSYGhjA@#co}Zv$SX-(?n8_67I%SNa?-1x`b_y|l6p%cpZ6@TEf6wWyWG7$+jDI6w&KV=?y1;|dpS|N9b0qH3k2ld)aFm}#1)#S%%99fX11v}LH%R> zDg9bKq|ehmx>Wr^J)}OV-k{Rzd^Jv$c)#^N@4eZ39xil#Q!?m{Yba5TX!m`ngWSQ^ zit1EN&{H)vN-f2`Y{nCtN0X{XPD6!Ki;*MG?|P3cR#}Cd7UV2I+Af?)jw6rORwAzh z=UeDqjr8q@bMvwBtrf_hg=3fDSb0#T7suLiANpL<1GOoX8;5dBQAXN)Cu@xQNjy-A z+i`U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i(1XG(o3*=J%_FiOcj6P3(Svd@6KY>twB2G*x?*Eu0SL$r-+ zN#QP=yM`2>z{*|i=yW)m=B^@*Vz|7L6yG4t9U{dZ`P@NLe3>kFfK-%;{iIkv&Fv!< zWnwQW?jm;uDZF=cdq`ml%O;+0Mrz8$ z{x?gn^N#+G=kaTH_|oU5r`PQ8wf_IkmptLSvCjO^JZ2s@zc+t5J)HlqZ2=j0tp5^$ zkpE)F4luUgfp(*DNIRQX$aJ_wb3VZ-Eg^G|F*p8(j5|xnyorhT5xznAl>^@m<{{r% z+(Q01Cb|_g{CEy*Wc(>H{(zdjPO`1{8p5Xu|3Pr0sZ|LVQ(c64gbN6V2rnl%h0H2v zJhaMb1y(sro7LC4BAO-j-Hf^6-fE|bS<~qf4Nq;HR%8vYU|b_w^JW&gpYTn>;|_dH zs3r6e+|Q|n!*bvJAvOMdT=;s)4tuYa_kWr`;63}_={WV9uMfZj@L7G0_kZnEfBMFr zsRiWO3;Hi|;N4634#BDYK~>^n$_a#^n#0(61Sdg)>Sc_%X-`nSi!nEg3928vn7*38 zlG?qULG7j|LH&fwGwlSP+H7KsS1@iu5;Ux*aj$I9I1v#vUuVf*I`G}>Cg@i))=ij6 zSVC}Wd(d}6E$Hu)7cvxbp>w(jt#{l>iI8`f924?BMffhk%{f9U?qbRbi;$Yj7)2(3 z#U`ZgWa8@y?3VJ4OGGnrlzG|Noh~@^t>`7C7Ak|6B{$QQAxg$}#h! z&2*rw%8t@zI#60 Date: Sun, 13 Mar 2011 20:45:46 +0100 Subject: [PATCH 02/97] filled tables language, testament_reference, webbibles, download_source in bibles_resources.sqlite with data and extend tables book_reference and chapters add method reload_spelling() in manager.py add class SpellingDB and extend class BiblesResourcesDB --- openlp/plugins/bibles/lib/db.py | 198 ++++++++++++++++-- openlp/plugins/bibles/lib/manager.py | 22 +- .../bibles/resources/bibles_resources.sqlite | Bin 63488 -> 63488 bytes 3 files changed, 205 insertions(+), 15 deletions(-) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index a1c8fb9a1..3eb7c3af1 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -69,6 +69,12 @@ class Verse(BaseModel): """ pass +class Spelling(BaseModel): + """ + Spelling model + """ + pass + def init_schema(url): """ @@ -123,6 +129,29 @@ def init_schema(url): metadata.create_all(checkfirst=True) return session +def init_schema_spelling_extension(url): + """ + Setup a spelling database connection and initialise the database schema. + + ``url`` + The database to setup. + """ + session, metadata = init_db(url) + + spelling_table = Table(u'spelling', metadata, + Column(u'id', types.Integer, primary_key=True), + Column(u'book_reference_id', types.Integer), + Column(u'language_id', types.Integer), + Column(u'name', types.Unicode(50), index=True), + ) + + try: + class_mapper(Spelling) + except UnmappedClassError: + mapper(Spelling, spelling_table) + + metadata.create_all(checkfirst=True) + return session class BibleDB(QtCore.QObject, Manager): """ @@ -592,7 +621,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): @staticmethod def get_download_source(source): """ - Return a download_source by source. + Return a download_source_id by source. ``name`` The name or abbreviation of the book. @@ -600,8 +629,6 @@ class BiblesResourcesDB(QtCore.QObject, Manager): if not isinstance(source, unicode): source = unicode(source) source = source.title() - #source = source.lower() - log.debug(u'Test: %s' % source) dl_source = BiblesResourcesDB.run_sql(u'SELECT id, source FROM ' u'download_source WHERE source = ?', (source.lower(),)) if dl_source: @@ -615,7 +642,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): @staticmethod def get_webbibles(source): """ - Return the chapter details for a specific chapter of a book. + Return the bibles a webbible provide for download. ``name`` The name of the webbible. @@ -626,13 +653,156 @@ class BiblesResourcesDB(QtCore.QObject, Manager): bibles = BiblesResourcesDB.run_sql(u'SELECT id, name, abbreviation, ' u'language_id, download_source_id FROM webbibles WHERE ' u'download_source_id = ?', (source[u'id'],)) - bibles_temp = [] - for bible in bibles: - bibles_temp.append({ - u'id': bible[0], - u'name': bible[1], - u'abbreviation': bible[2], - u'language_id': bible[3], - u'download_source_id': bible[4] - }) - return bibles_temp + if bibles: + bibles_temp = [] + for bible in bibles: + bibles_temp.append({ + u'id': bible[0], + u'name': bible[1], + u'abbreviation': bible[2], + u'language_id': bible[3], + u'download_source_id': bible[4] + }) + return bibles_temp + else: + return None + + @staticmethod + def get_spelling(name, language_id=None): + """ + Return a book_reference_id if the name matches. + """ + if language_id: + id = BiblesResourcesDB.run_sql(u'SELECT book_reference_id ' + u'FROM spelling WHERE name = ? and language_id = ? ORDER BY id', + (name, language_id)) + else: + id = BiblesResourcesDB.run_sql(u'SELECT book_reference_id ' + u'FROM spelling WHERE name = ? ORDER BY id', (name, )) + if id: + return int(id[0][0]) + else: + return None + + @staticmethod + def get_language(name): + """ + Return a dict containing the language id, name and code by name or + abbreviation. + + ``name`` + The name or abbreviation of the language. + """ + if not isinstance(name, unicode): + name = unicode(name) + name = name.title() + language = BiblesResourcesDB.run_sql(u'SELECT id, name, code FROM ' + u'language WHERE name = ? OR code = ?', (name, name.lower())) + if language: + return { + u'id': language[0][0], + u'name': unicode(language[0][1]), + u'code': unicode(language[0][2]) + } + else: + return None + + @staticmethod + def get_testament_reference(): + """ + Return a list of all testaments and their id of the Bible. + """ + testaments = BiblesResourcesDB.run_sql(u'SELECT id, name FROM ' + u'testament_reference ORDER BY id') + testament_list = [] + for testament in testaments: + testament_list.append({ + u'id': testament[0], + u'name': unicode(testament[1]) + }) + return testament_list + +class SpellingDB(QtCore.QObject, Manager): + """ + This class represents a database-bound spelling. + """ + + def __init__(self, parent, **kwargs): + """ + The constructor loads up the database and creates and initialises the + tables if the database doesn't exist. + + **Required keyword arguments:** + + ``path`` + The path to the bible database file. + + ``name`` + The name of the database. This is also used as the file name for + SQLite databases. + """ + log.info(u'SpellingDB loaded') + QtCore.QObject.__init__(self) + self.bible_plugin = parent + if u'path' not in kwargs: + raise KeyError(u'Missing keyword argument "path".') + self.stop_import_flag = False + self.name = u'spelling_extension.sqlite' + if not isinstance(self.name, unicode): + self.name = unicode(self.name, u'utf-8') + self.file = self.name + Manager.__init__(self, u'bibles/resources', + init_schema_spelling_extension, self.file) + self.wizard = None + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_import) + + def stop_import(self): + """ + Stops the import of the Bible. + """ + log.debug(u'Stopping import') + self.stop_import_flag = True + + def get_book_reference_id(self, name, language=None): + """ + Return the book_reference_id of a name. + + ``name`` + The name to search the id. + + ``language`` + The language for which should be searched + """ + log.debug(u'SpellingDB.get_book_reference_id("%s")', name) + if language: + id = self.session.query(Spelling.book_reference_id)\ + .filter(Spelling.name.like(name))\ + .filter(Spelling.language_id.like(language)).first() + else: + id = self.get_object_filtered(Spelling.book_reference_id, + Spelling.name.like(name)) + if not id: + return None + else: + return id + + def create_spelling(self, name, book_reference_id, language_id): + """ + Add a spelling to the database. + + ``name`` + The name of the spelling. + + ``book_reference_id`` + The book_reference_id of the book. + + ``language_id`` + The language which the spelling of the book name is. + """ + log.debug(u'create_spelling %s, book_reference_id:%s, language_id:%s', + name, book_reference_id, language_id) + spelling = Spelling.populate(name=name, + book_reference_id=book_reference_id, language_id=language_id) + self.save_object(spelling) + return spelling diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index dcbad3e63..46dc0ce3b 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -31,7 +31,8 @@ from PyQt4 import QtCore from openlp.core.lib import Receiver, SettingsManager, translate from openlp.core.utils import AppLocation from openlp.plugins.bibles.lib import parse_reference -from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta +from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta, SpellingDB, \ + Spelling, BiblesResourcesDB from csvbible import CSVBible from http import HTTPBible @@ -129,6 +130,7 @@ class BibleManager(object): self.suffix = u'.sqlite' self.import_wizard = None self.reload_bibles() + self.reload_spelling() self.media = None def reload_bibles(self): @@ -162,6 +164,24 @@ class BibleManager(object): self.db_cache[name] = web_bible log.debug(u'Bibles reloaded') + def reload_spelling(self): + """ + Reloads the Spelling from the Spelling table and spelling_extension + database on disk. + """ + log.debug(u'Reload spelling') + self.spelling_cache = {} + self.spelling_cache[u'spelling'] = SpellingDB(self.parent, + path=self.path) + #db_spelling = self.spelling_cache[u'spelling'].get_book_reference_id(u'Markus', 40) + #db_spelling = BiblesResourcesDB.get_spelling(u'1.Mose', 30) + #db_spelling = BiblesResourcesDB.get_language(u'de') + #db_spelling = BiblesResourcesDB.get_books() + #db_spelling = BiblesResourcesDB.get_testament_reference() + #db_spelling = self.spelling_cache[u'spelling'] .create_spelling(u'Johannes', 43, 40) + #log.debug(u'Spellings: %s' % db_spelling) + log.debug(u'Spelling reloaded') + def set_process_dialog(self, wizard): """ Sets the reference to the dialog with the progress bar on it. diff --git a/openlp/plugins/bibles/resources/bibles_resources.sqlite b/openlp/plugins/bibles/resources/bibles_resources.sqlite index bcb45b8015c5cb6855a3c2d6c0aa821ce2324151..3049657ecce5196e97303df41161553b81f203f1 100644 GIT binary patch delta 116 zcmZqpz})bGd4e=!!bBNo#)ORtOV|b2m|Yl{?=c@|Ud-IZ9L4OiS&_qlSz3gRS(mYx zp@1QkAqNOE8S)s?85p%#nIjn|J9w*YZso3zU}I!{&A|M6v!KXBW)WdVRt82!RYna% U20aE}hJ1!%hSbgf(-|iK0MDizRsaA1 delta 64 zcmV-G0Kfl$@B@JG1CSd5Uy&R`0bj9Tqz4WK16lwB-UG)2qXUWqTC*_>NCO2b1p`?D WlR!%*vxN(PShECpqXe_3XjzYlF%(k( From 1c59fd656f73a4cf01e35547a8be950b2d9204c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Thu, 17 Mar 2011 19:36:54 +0100 Subject: [PATCH 03/97] add download of all books a webbible contains add dialog while the import of a webbible if the book could not be assign to a reference_book add dialog while tho import of a webbible if the language is unknown change the bible database --- openlp/plugins/bibles/forms/__init__.py | 1 + .../bibles/forms/bibleimportrequestdialog.py | 95 ++++++++++ .../bibles/forms/bibleimportrequestform.py | 82 +++++++++ openlp/plugins/bibles/lib/csvbible.py | 3 + openlp/plugins/bibles/lib/db.py | 127 +++++++++++--- openlp/plugins/bibles/lib/http.py | 163 ++++++++++++++++-- openlp/plugins/bibles/lib/manager.py | 66 ++++++- openlp/plugins/bibles/lib/mediaitem.py | 6 + openlp/plugins/bibles/lib/openlp1.py | 3 + openlp/plugins/bibles/lib/opensong.py | 3 + openlp/plugins/bibles/lib/osis.py | 3 + .../bibles/resources/bibles_resources.sqlite | Bin 63488 -> 63488 bytes 12 files changed, 504 insertions(+), 48 deletions(-) create mode 100644 openlp/plugins/bibles/forms/bibleimportrequestdialog.py create mode 100644 openlp/plugins/bibles/forms/bibleimportrequestform.py diff --git a/openlp/plugins/bibles/forms/__init__.py b/openlp/plugins/bibles/forms/__init__.py index 15f14de9e..d0966c7ce 100644 --- a/openlp/plugins/bibles/forms/__init__.py +++ b/openlp/plugins/bibles/forms/__init__.py @@ -52,5 +52,6 @@ from the .ui files later if necessary. """ from bibleimportform import BibleImportForm +from bibleimportrequestform import BibleImportRequest __all__ = ['BibleImportForm'] diff --git a/openlp/plugins/bibles/forms/bibleimportrequestdialog.py b/openlp/plugins/bibles/forms/bibleimportrequestdialog.py new file mode 100644 index 000000000..d58c1df9f --- /dev/null +++ b/openlp/plugins/bibles/forms/bibleimportrequestdialog.py @@ -0,0 +1,95 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2011 Raoul Snyman # +# Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Meinert Jordan, Armin Köhler, Andreas Preikschat, # +# Christian Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon # +# Tibble, Carsten Tinggaard, Frode Woldsund # +# --------------------------------------------------------------------------- # +# 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 PyQt4 import QtCore, QtGui + +from openlp.core.lib import translate +from openlp.core.lib.ui import create_accept_reject_button_box + +class Ui_BibleImportRequest(object): + def setupUi(self, bibleImportRequest): + bibleImportRequest.setObjectName("BibleImportRequest") + bibleImportRequest.resize(400, 175) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, + QtGui.QSizePolicy.MinimumExpanding) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(bibleImportRequest.sizePolicy() + .hasHeightForWidth()) + bibleImportRequest.setSizePolicy(sizePolicy) + self.widget = QtGui.QWidget(bibleImportRequest) + self.widget.setGeometry(QtCore.QRect(10, 15, 381, 151)) + self.widget.setObjectName("widget") + self.verticalLayout = QtGui.QVBoxLayout(self.widget) + self.verticalLayout.setObjectName("verticalLayout") + self.headlineLabel = QtGui.QLabel(self.widget) + font = QtGui.QFont() + font.setFamily("Arial") + font.setPointSize(11) + font.setWeight(75) + font.setBold(True) + self.headlineLabel.setFont(font) + self.headlineLabel.setObjectName("HeadlineLabel") + self.verticalLayout.addWidget(self.HeadlineLabel) + self.infoLabel = QtGui.QLabel(self.widget) + self.infoLabel.setObjectName("InfoLabel") + self.verticalLayout.addWidget(self.infoLabel) + self.formLayout = QtGui.QFormLayout() + self.formLayout.setObjectName("formLayout") + self.requestLabel = QtGui.QLabel(self.widget) + self.requestLabel.setObjectName("RequestLabel") + self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, + self.requestLabel) + self.requestComboBox = QtGui.QComboBox(self.widget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, + QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.requestComboBox.sizePolicy() + .hasHeightForWidth()) + self.requestComboBox.setSizePolicy(sizePolicy) + self.requestComboBox.setObjectName("RequestComboBox") + self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, + self.requestComboBox) + self.verticalLayout.addLayout(self.formLayout) + spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, + QtGui.QSizePolicy.Expanding) + self.verticalLayout.addItem(spacerItem) + self.formLayout.addWidget( + create_accept_reject_button_box(bibleImportRequest)) + self.retranslateUi(bibleImportRequest) + QtCore.QMetaObject.connectSlotsByName(bibleImportRequest) + + def retranslateUi(self, bibleImportRequest): + bibleImportRequest.setWindowTitle( + translate("BiblesPlugin.bibleImportRequest", "Dialog")) + self.headlineLabel.setText( + translate("BiblesPlugin.bibleImportRequest", "Choose Book:")) + self.infoLabel.setText(translate("BiblesPlugin.bibleImportRequest", + "The following books cannot be clearly attributed. \n" + "Please choose the book it is.")) + self.requestLabel.setText(translate("BiblesPlugin.bibleImportRequest", + "Book:")) diff --git a/openlp/plugins/bibles/forms/bibleimportrequestform.py b/openlp/plugins/bibles/forms/bibleimportrequestform.py new file mode 100644 index 000000000..caac8e83b --- /dev/null +++ b/openlp/plugins/bibles/forms/bibleimportrequestform.py @@ -0,0 +1,82 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2011 Raoul Snyman # +# Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Meinert Jordan, Armin Köhler, Andreas Preikschat, # +# Christian Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon # +# Tibble, Carsten Tinggaard, Frode Woldsund # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### + +""" +Module implementing BibleImportRequest. +""" +import logging + +from PyQt4.QtGui import QDialog + +from openlp.core.lib import translate +from openlp.core.lib.ui import critical_error_message_box +from openlp.plugins.bibles.forms.bibleimportrequestdialog import \ + Ui_BibleImportRequest +from openlp.plugins.bibles.lib.db import BiblesResourcesDB + +log = logging.getLogger(__name__) + +class BibleImportRequest(QDialog, Ui_BibleImportRequest): + """ + Class documentation goes here. + """ + log.info(u'BibleImportRequest loaded') + + def __init__(self, parent = None): + """ + Constructor + """ + QDialog.__init__(self, parent) + self.setupUi(self) + + def exec_(self, case, name=None): + items = [] + self.requestComboBox.addItem(u'') + if case == u'language': + self.headlineLabel.setText(translate( + "BiblesPlugin.BibleImportRequest", "Choose Language:")) + self.infoLabel.setText(translate("BiblesPlugin.BibleImportRequest", + "Please choose the language the bible is.")) + self.requestLabel.setText( + translate("BiblesPlugin.BibleImportRequest", "Language:")) + items = BiblesResourcesDB.get_languages() + elif case == u'book': + self.requestLabel.setText( + translate("BiblesPlugin.BibleImportRequest", name)) + items = BiblesResourcesDB.get_books() + for item in items: + self.requestComboBox.addItem(item[u'name']) + return QDialog.exec_(self) + + def accept(self): + if self.requestComboBox.currentText() == u"": + critical_error_message_box( + message=translate('BiblesPlugin.BibleImportRequest', + 'You need to choose an item.')) + self.requestComboBox.setFocus() + return False + else: + return QDialog.accept(self) diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index b96382df2..b5644db81 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -135,6 +135,7 @@ class CSVBible(BibleDB): self.wizard.progressBar.setMinimum(0) self.wizard.progressBar.setMaximum(66) success = True + #TODO: include create_meta language books_file = None book_list = {} # Populate the Tables @@ -148,6 +149,8 @@ class CSVBible(BibleDB): self.wizard.incrementProgressBar(unicode( translate('BibleDB.Wizard', 'Importing books... %s')) % unicode(line[2], details['encoding'])) + #TODO: change create_book to the new database model + #(name, bk_ref_id, testament) self.create_book(unicode(line[2], details['encoding']), unicode(line[3], details['encoding']), int(line[1])) book_list[int(line[0])] = unicode(line[2], details['encoding']) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 3eb7c3af1..68edc55ef 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -95,9 +95,9 @@ def init_schema(url): ) book_table = Table(u'book', metadata, Column(u'id', types.Integer, primary_key=True), - Column(u'testament_id', types.Integer, ForeignKey(u'testament.id')), + Column(u'book_reference_id', types.Integer), + Column(u'testament_reference_id', types.Integer), Column(u'name', types.Unicode(50), index=True), - Column(u'abbreviation', types.Unicode(5), index=True), ) verse_table = Table(u'verse', metadata, Column(u'id', types.Integer, primary_key=True, index=True), @@ -114,8 +114,7 @@ def init_schema(url): try: class_mapper(Testament) except UnmappedClassError: - mapper(Testament, testament_table, - properties={'books': relation(Book, backref='testament')}) + mapper(Testament, testament_table) try: class_mapper(Book) except UnmappedClassError: @@ -251,22 +250,23 @@ class BibleDB(QtCore.QObject, Manager): self.save_object(Testament.populate(name=u'New Testament')) self.save_object(Testament.populate(name=u'Apocrypha')) - def create_book(self, name, abbrev, testament=1): + def create_book(self, name, bk_ref_id, testament=1): """ Add a book to the database. ``name`` The name of the book. - ``abbrev`` - The abbreviation of the book. + ``bk_ref_id`` + The book_reference_id from bibles_resources.sqlite of the book. ``testament`` - *Defaults to 1.* The id of the testament this book belongs to. + *Defaults to 1.* The testament_reference_id from + bibles_resources.sqlite of the testament this book belongs to. """ - log.debug(u'create_book %s,%s', name, abbrev) - book = Book.populate(name=name, abbreviation=abbrev, - testament_id=testament) + log.debug(u'create_book %s,%s', name, bk_ref_id) + book = Book.populate(name=name, book_reference_id=bk_ref_id, + testament_reference_id=testament) self.save_object(book) return book @@ -334,6 +334,8 @@ class BibleDB(QtCore.QObject, Manager): ``value`` The value for this instance. """ + if not isinstance(value, unicode): + value = unicode(value) log.debug(u'save_meta %s/%s', key, value) self.save_object(BibleMeta.populate(key=key, value=value)) @@ -346,9 +348,6 @@ class BibleDB(QtCore.QObject, Manager): """ log.debug(u'BibleDb.get_book("%s")', book) db_book = self.get_object_filtered(Book, Book.name.like(book + u'%')) - if db_book is None: - db_book = self.get_object_filtered(Book, - Book.abbreviation.like(book + u'%')) return db_book def get_books(self): @@ -358,7 +357,7 @@ class BibleDB(QtCore.QObject, Manager): """ return self.get_all_objects(Book, order_by_ref=Book.id) - def get_verses(self, reference_list): + def get_verses(self, reference_list, en_reference_list): """ This is probably the most used function. It retrieves the list of verses based on the user's query. @@ -376,15 +375,18 @@ class BibleDB(QtCore.QObject, Manager): [(u'Genesis', 1, 1, 1), (u'Genesis', 2, 2, 3)] """ - log.debug(u'BibleDB.get_verses: %s', reference_list) + log.debug(u'BibleDB.get_verses: %s - %s', reference_list, + en_reference_list) verse_list = [] - for book, chapter, start_verse, end_verse in reference_list: + for (book, chapter, start_verse, end_verse), (en_book, en_chapter, + en_start_verse, en_end_verse) in zip(reference_list, + en_reference_list): db_book = self.get_book(book) if db_book: book = db_book.name log.debug(u'Book name corrected to "%s"', book) if end_verse == -1: - end_verse = self.get_verse_count(book, chapter) + end_verse = self.get_verse_count(en_book, chapter) verses = self.session.query(Verse)\ .filter_by(book_id=db_book.id)\ .filter_by(chapter=chapter)\ @@ -545,9 +547,9 @@ class BiblesResourcesDB(QtCore.QObject, Manager): ``name`` The name or abbreviation of the book. """ + log.debug(u'get_book: %s', name) if not isinstance(name, unicode): name = unicode(name) - name = name.title() books = BiblesResourcesDB.run_sql(u'SELECT id, testament_id, name, ' u'abbreviation, chapters FROM book_reference WHERE name = ? OR ' u'abbreviation = ?', (name, name)) @@ -562,6 +564,30 @@ class BiblesResourcesDB(QtCore.QObject, Manager): else: return None + @staticmethod + def get_book_by_id(id): + """ + Return a book by id. + + ``id`` + The id of the book. + """ + if not isinstance(id, int): + id = int(id) + books = BiblesResourcesDB.run_sql(u'SELECT id, testament_id, name, ' + u'abbreviation, chapters FROM book_reference WHERE id = ?', + (id, )) + if books: + return { + u'id': books[0][0], + u'testament_id': books[0][1], + u'name': unicode(books[0][2]), + u'abbreviation': unicode(books[0][3]), + u'chapters': books[0][4] + } + else: + return None + @staticmethod def get_chapter(name, chapter): """ @@ -644,8 +670,8 @@ class BiblesResourcesDB(QtCore.QObject, Manager): """ Return the bibles a webbible provide for download. - ``name`` - The name of the webbible. + ``source`` + The source of the webbible. """ if not isinstance(source, unicode): source = unicode(source) @@ -668,7 +694,39 @@ class BiblesResourcesDB(QtCore.QObject, Manager): return None @staticmethod - def get_spelling(name, language_id=None): + def get_webbible(abbreviation, source): + """ + Return the bibles a webbible provide for download. + + ``abbreviation`` + The abbreviation of the webbible. + + ``source`` + The source of the webbible. + """ + if not isinstance(abbreviation, unicode): + abbreviation = unicode(abbreviation) + if not isinstance(source, unicode): + source = unicode(source) + source = BiblesResourcesDB.get_download_source(source) + bible = BiblesResourcesDB.run_sql(u'SELECT id, name, abbreviation, ' + u'language_id, download_source_id FROM webbibles WHERE ' + u'download_source_id = ? AND abbreviation = ?', (source[u'id'], + abbreviation)) + if bible: + bibles_temp = { + u'id': bible[0][0], + u'name': bible[0][1], + u'abbreviation': bible[0][2], + u'language_id': bible[0][3], + u'download_source_id': bible[0][4] + } + return bibles_temp + else: + return None + + @staticmethod + def get_spelling(name, language_id=None): """ Return a book_reference_id if the name matches. """ @@ -678,7 +736,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): (name, language_id)) else: id = BiblesResourcesDB.run_sql(u'SELECT book_reference_id ' - u'FROM spelling WHERE name = ? ORDER BY id', (name, )) + u'FROM spelling WHERE name = ? ORDER BY id', (name, )) if id: return int(id[0][0]) else: @@ -707,6 +765,25 @@ class BiblesResourcesDB(QtCore.QObject, Manager): else: return None + @staticmethod + def get_languages(): + """ + Return a dict containing all languages with id, name and code. + """ + languages = BiblesResourcesDB.run_sql(u'SELECT id, name, code FROM ' + u'language ORDER by name') + if languages: + languages_temp = [] + for language in languages: + languages_temp.append({ + u'id': language[0], + u'name': unicode(language[1]), + u'code': unicode(language[2]) + }) + return languages_temp + else: + return None + @staticmethod def get_testament_reference(): """ @@ -766,7 +843,7 @@ class SpellingDB(QtCore.QObject, Manager): def get_book_reference_id(self, name, language=None): """ - Return the book_reference_id of a name. + Return the book_reference_id of a book by name. ``name`` The name to search the id. @@ -785,7 +862,7 @@ class SpellingDB(QtCore.QObject, Manager): if not id: return None else: - return id + return id[0] def create_spelling(self, name, book_reference_id, language_id): """ diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index d2202909c..29c86e0bd 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -41,7 +41,8 @@ from openlp.core.lib import Receiver, translate from openlp.core.lib.ui import critical_error_message_box from openlp.core.utils import AppLocation, get_web_page from openlp.plugins.bibles.lib import SearchResults -from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB, Book +from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB, \ + SpellingDB, Book log = logging.getLogger(__name__) @@ -123,6 +124,52 @@ class BGExtract(object): return None return SearchResults(bookname, chapter, verse_list) + def get_books_from_http(self, version): + """ + Load a list of all books a bible contaions from BibleGateway website. + + ``version`` + The version of the bible like NIV for New International Version + """ + log.debug(u'get_books_from_http %s', version) + url_params = urllib.urlencode( + {u'search': 'Bible-List', u'version': u'%s' % version}) + reference_url = u'http://www.biblegateway.com/passage/?%s' % url_params + page = get_web_page(reference_url) + if not page: + send_error_message(u'download') + return None + page_source = page.read() + page_source = unicode(page_source, 'utf8') + page_source_temp = re.search(u'.*?
', \ + page_source, re.DOTALL) + if page_source_temp: + soup = page_source_temp.group(0) + else: + soup = None + try: + soup = BeautifulSoup(soup) + except HTMLParseError: + log.exception(u'BeautifulSoup could not parse the bible page.') + if not soup: + send_error_message(u'parse') + return None + Receiver.send_message(u'openlp_process_events') + content = soup.find(u'table', {u'id': u'booklist'}) + content = content.findAll(u'tr') + #log.debug(content) + if not content: + log.exception(u'No books found in the Biblegateway response.') + send_error_message(u'parse') + return None + books = [] + for book in content: + book = book.find(u'td') + if book: + books.append(book.contents[0]) + log.debug(book.contents[0]) + return books + class BSExtract(object): """ @@ -168,6 +215,31 @@ class BSExtract(object): verses[versenumber] = verse.contents[1].rstrip(u'\n') return SearchResults(bookname, chapter, verses) + def get_books_from_http(self, version): + """ + Load a list of all books a bible contains from Bibleserver mobile + website. + + ``version`` + The version of the bible like NIV for New International Version + """ + log.debug(u'get_books_from_http %s', version) + chapter_url = u'http://m.bibleserver.com/overlay/selectBook?'\ + 'translation=%s' % (version) + soup = get_soup_for_bible_ref(chapter_url) + if not soup: + return None + content = soup.find(u'ul') + if not content: + log.exception(u'No books found in the Bibleserver response.') + send_error_message(u'parse') + return None + content = content.findAll(u'li') + books = [] + for book in content: + books.append(book.contents[0].contents[0]) + return books + class CWExtract(object): """ @@ -237,6 +309,33 @@ class CWExtract(object): verses[versenumber] = versetext return SearchResults(bookname, chapter, verses) + def get_books_from_http(self, version): + """ + Load a list of all books a bible contain from the Crosswalk website. + + ``version`` + The version of the bible like NIV for New International Version + """ + log.debug(u'get_books_from_http %s', version) + chapter_url = u'http://www.biblestudytools.com/%s/'\ + % (version) + soup = get_soup_for_bible_ref(chapter_url) + if not soup: + return None + content = soup.find(u'div', {u'class': u'Body'}) + content = content.find(u'ul', {u'class': u'parent'}) + if not content: + log.exception(u'No books found in the Crosswalk response.') + send_error_message(u'parse') + return None + content = content.findAll(u'li') + books = [] + for book in content: + book = book.find(u'a') + books.append(book.contents[0]) + log.debug(book.contents[0]) + return books + class HTTPBible(BibleDB): log.info(u'%s HTTPBible loaded' , __name__) @@ -252,6 +351,7 @@ class HTTPBible(BibleDB): Init confirms the bible exists and stores the database path. """ BibleDB.__init__(self, parent, **kwargs) + self.parent = parent self.download_source = kwargs[u'download_source'] self.download_name = kwargs[u'download_name'] # TODO: Clean up proxy stuff. We probably want one global proxy per @@ -259,6 +359,8 @@ class HTTPBible(BibleDB): self.proxy_server = None self.proxy_username = None self.proxy_password = None + if u'path' in kwargs: + self.path = kwargs[u'path'] if u'proxy_server' in kwargs: self.proxy_server = kwargs[u'proxy_server'] if u'proxy_username' in kwargs: @@ -283,9 +385,37 @@ class HTTPBible(BibleDB): if self.proxy_password: # Store the proxy password. self.create_meta(u'proxy password', self.proxy_password) + if self.download_source.lower() == u'crosswalk': + handler = CWExtract(self.proxy_server) + elif self.download_source.lower() == u'biblegateway': + handler = BGExtract(self.proxy_server) + elif self.download_source.lower() == u'bibleserver': + handler = BSExtract(self.proxy_server) + books = handler.get_books_from_http(self.download_name) + if not books: + log.exception(u'Importing books from %s - download name: "%s" '\ + 'failed' % (self.download_source, self.download_name)) + return False + bible = BiblesResourcesDB.get_webbible(self.download_name, + self.download_source.lower()) + if bible[u'language_id']: + language_id = bible[u'language_id'] + else: + language = self.parent.mediaItem.importRequest(u'language') + language = BiblesResourcesDB.get_language(language) + language_id = language[u'id'] + # Store the language_id. + self.create_meta(u'language_id', language_id) + for book in books: + book_ref_id = self.parent.manager.get_book_ref_id_by_name(book, + language_id) + book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) + log.debug(u'Book details: Name:%s; id:%s; testament_id:%s', + book, book_ref_id, book_details[u'testament_id']) + self.create_book(book, book_ref_id, book_details[u'testament_id']) return True - def get_verses(self, reference_list): + def get_verses(self, reference_list, en_reference_list): """ A reimplementation of the ``BibleDB.get_verses`` method, this one is specifically for web Bibles. It first checks to see if the particular @@ -298,6 +428,13 @@ class HTTPBible(BibleDB): a list of tuples, with the following format:: (book, chapter, start_verse, end_verse) + + ``en_reference_list`` + This is the list of references the media manager item wants. It is + a list of tuples, with the following format with englisch book + names:: + + (book, chapter, start_verse, end_verse) Therefore, when you are looking for multiple items, simply break them up into references like this, bundle them into a list. This @@ -311,17 +448,12 @@ class HTTPBible(BibleDB): book = reference[0] db_book = self.get_book(book) if not db_book: - book_details = BiblesResourcesDB.get_book(book) - if not book_details: - critical_error_message_box( - translate('BiblesPlugin', 'No Book Found'), - translate('BiblesPlugin', 'No matching ' - 'book could be found in this Bible. Check that you ' - 'have spelled the name of the book correctly.')) - return [] - db_book = self.create_book(book_details[u'name'], - book_details[u'abbreviation'], - book_details[u'testament_id']) + critical_error_message_box( + translate('BiblesPlugin', 'No Book Found'), + translate('BiblesPlugin', 'No matching ' + 'book could be found in this Bible. Check that you ' + 'have spelled the name of the book correctly.')) + return [] book = db_book.name if BibleDB.get_verse_count(self, book, reference[1]) == 0: Receiver.send_message(u'cursor_busy') @@ -340,7 +472,7 @@ class HTTPBible(BibleDB): Receiver.send_message(u'openlp_process_events') Receiver.send_message(u'cursor_normal') Receiver.send_message(u'openlp_process_events') - return BibleDB.get_verses(self, reference_list) + return BibleDB.get_verses(self, reference_list, en_reference_list) def get_chapter(self, book, chapter): """ @@ -360,8 +492,7 @@ class HTTPBible(BibleDB): """ Return the list of books. """ - return [Book.populate(name=book['name']) - for book in BiblesResourcesDB.get_books()] + return self.get_all_objects(Book, order_by_ref=Book.id) def get_chapter_count(self, book): """ diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 6a12c3877..de66c38e0 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -220,19 +220,28 @@ class BibleManager(object): Unicode. The Bible to get the list of books from. """ log.debug(u'BibleManager.get_books("%s")', bible) - return [ + language_id = self.get_meta_data(bible, u'language_id') + books = [] + for book in self.db_cache[bible].get_books(): + book_id = self.get_book_ref_id_by_name(book.name, int( + language_id.value)) + book_temp = BiblesResourcesDB.get_book_by_id(book_id) + book_ref = book_temp[u'name'] + books.append( { u'name': book.name, - u'chapters': self.db_cache[bible].get_chapter_count(book.name) - } - for book in self.db_cache[bible].get_books() - ] + u'chapters': self.db_cache[bible].get_chapter_count(book_ref) + }) + return books def get_chapter_count(self, bible, book): """ Returns the number of Chapters for a given book. """ - log.debug(u'get_book_chapter_count %s', book) + log.debug(u'BibleManager.get_book_chapter_count ("%s", "%s")', bible, + book) + language_id = self.get_meta_data(bible, u'language_id') + book = self.get_book_ref(book, int(language_id.value)) return self.db_cache[bible].get_chapter_count(book) def get_verse_count(self, bible, book, chapter): @@ -242,6 +251,8 @@ class BibleManager(object): """ log.debug(u'BibleManager.get_verse_count("%s", "%s", %s)', bible, book, chapter) + language_id = self.get_meta_data(bible, u'language_id') + book = self.get_book_ref(book, int(language_id.value)) return self.db_cache[bible].get_verse_count(book, chapter) def get_verses(self, bible, versetext): @@ -275,7 +286,14 @@ class BibleManager(object): return None reflist = parse_reference(versetext) if reflist: - return self.db_cache[bible].get_verses(reflist) + log.debug(u'reflist:%s', reflist) + en_reflist = [] + for item in reflist: + if item: + book = self.get_book_ref(item[0]) + en_reflist.append((book, item[1], item[2], item[3])) + log.debug(u'en_reflist:%s', en_reflist) + return self.db_cache[bible].get_verses(reflist, en_reflist) else: Receiver.send_message(u'openlp_information_message', { u'title': translate('BiblesPlugin.BibleManager', @@ -293,6 +311,40 @@ class BibleManager(object): }) return None + def get_book_ref(self, book, language_id=None): + log.debug(u'BibleManager.get_book_ref("%s", "%s")', book, language_id) + book_id = self.get_book_ref_id_by_name(book, language_id) + book_temp = BiblesResourcesDB.get_book_by_id(book_id) + log.debug(u'get_book_ref - Return:%s', book_temp[u'name']) + return book_temp[u'name'] + + def get_book_ref_id_by_name(self, book, language_id=None): + log.debug(u'BibleManager.get_book_ref_id_by_name:("%s", "%s")', book, + language_id) + if BiblesResourcesDB.get_book(book): + book_temp = BiblesResourcesDB.get_book(book) + book_id = book_temp[u'id'] + elif BiblesResourcesDB.get_spelling(book, language_id): + book_id = BiblesResourcesDB.get_spelling(book, language_id) + elif self.spelling_cache[u'spelling'].get_book_reference_id(book, + language_id): + book_id = self.spelling_cache[u'spelling'].\ + get_book_reference_id(book, language_id) + else: + book_ref = self.parent.mediaItem.importRequest(u'book', book) + log.debug(book_ref) + book_temp = BiblesResourcesDB.get_book(book_ref) + log.debug(book_temp) + book_id = book_temp[u'id'] + if book_id: + self.spelling_cache[u'spelling'].create_spelling(book, book_id, + language_id) + if book_id: + log.debug(u'get_book_ref_id_by_name - Return:%s', book_id) + return book_id + else: + return None + def verse_search(self, bible, second_bible, text): """ Does a verse search for the given bible and text. diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 2b2f6597e..58fa0eec7 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -36,6 +36,7 @@ from openlp.core.lib.ui import UiStrings, add_widget_completer, \ from openlp.plugins.bibles.forms import BibleImportForm from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, \ get_reference_match +from openlp.plugins.bibles.forms import BibleImportRequest log = logging.getLogger(__name__) @@ -286,6 +287,11 @@ class BibleMediaItem(MediaManagerItem): if self.import_wizard.exec_(): self.reloadBibles() + def importRequest(self, case, name=None): + self.import_request = BibleImportRequest(self) + if self.import_request.exec_(case, name): + return unicode(self.import_request.RequestComboBox.currentText()) + def loadBibles(self): log.debug(u'Loading Bibles') self.quickVersionComboBox.clear() diff --git a/openlp/plugins/bibles/lib/openlp1.py b/openlp/plugins/bibles/lib/openlp1.py index 2d19db20c..f0e12481a 100644 --- a/openlp/plugins/bibles/lib/openlp1.py +++ b/openlp/plugins/bibles/lib/openlp1.py @@ -56,6 +56,7 @@ class OpenLP1Bible(BibleDB): cursor = connection.cursor() except: return False + #TODO: include create_meta language # Create all books. cursor.execute(u'SELECT id, testament_id, name, abbreviation FROM book') books = cursor.fetchall() @@ -68,6 +69,8 @@ class OpenLP1Bible(BibleDB): testament_id = int(book[1]) name = unicode(book[2], u'cp1252') abbreviation = unicode(book[3], u'cp1252') + #TODO: change create_book to the new database model + #(name, bk_ref_id, testament) self.create_book(name, abbreviation, testament_id) # Update the progess bar. self.wizard.incrementProgressBar(WizardStrings.ImportingType % name) diff --git a/openlp/plugins/bibles/lib/opensong.py b/openlp/plugins/bibles/lib/opensong.py index a7f1eff33..62cf12eaf 100644 --- a/openlp/plugins/bibles/lib/opensong.py +++ b/openlp/plugins/bibles/lib/opensong.py @@ -61,9 +61,12 @@ class OpenSongBible(BibleDB): file = open(self.filename, u'r') opensong = objectify.parse(file) bible = opensong.getroot() + #TODO: include create_meta language for book in bible.b: if self.stop_import_flag: break + #TODO: change create_book to the new database model + #(name, bk_ref_id, testament) db_book = self.create_book(unicode(book.attrib[u'n']), unicode(book.attrib[u'n'][:4])) for chapter in book.c: diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index 78e2551d9..05a57bbe4 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -104,6 +104,7 @@ class OSISBible(BibleDB): finally: if detect_file: detect_file.close() + #TODO: include create_meta language with try - except scheme try: osis = codecs.open(self.filename, u'r', details['encoding']) for file_record in osis: @@ -120,6 +121,8 @@ class OSISBible(BibleDB): log.debug(u'New book: "%s"', self.books[book][0]) if book == u'Matt' or book == u'Jdt': testament += 1 + #TODO: change create_book to the new database model + #(name, bk_ref_id, testament) db_book = self.create_book( unicode(self.books[book][0]), unicode(self.books[book][1]), diff --git a/openlp/plugins/bibles/resources/bibles_resources.sqlite b/openlp/plugins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=7UjMv#+*lt z(ibHzdivOEvcUucbZ~*13lbjZcFGPJmnWo;Bz;VcH3!9(IMVD*kuC47V~0y~XW{d>Y`C6g+BDl1*n# zQev#LjCFxgPg#-%c(g2650q<}pWZUe4wD+d$59 z^$gBZo2oPB)}L!Zx?4fhYX g%;y|mZlkn%!fx0%kCOY1+eTU3d0G}byA=Ze0*BQ3^Z)<= From 7a15251ffc2a8e5c27a624ec755bc3f6c945b612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Thu, 17 Mar 2011 20:40:01 +0100 Subject: [PATCH 04/97] Clean up changed create_book in cscbible, openlp1, opensong and osis --- .../bibles/forms/bibleimportrequestdialog.py | 2 +- openlp/plugins/bibles/lib/csvbible.py | 15 +- openlp/plugins/bibles/lib/mediaitem.py | 2 +- openlp/plugins/bibles/lib/openlp1.py | 16 +- openlp/plugins/bibles/lib/opensong.py | 17 ++- openlp/plugins/bibles/lib/osis.py | 16 +- resources/forms/bibleimportrequestdialog.ui | 137 ++++++++++++++++++ 7 files changed, 183 insertions(+), 22 deletions(-) create mode 100644 resources/forms/bibleimportrequestdialog.ui diff --git a/openlp/plugins/bibles/forms/bibleimportrequestdialog.py b/openlp/plugins/bibles/forms/bibleimportrequestdialog.py index d58c1df9f..7fcc36932 100644 --- a/openlp/plugins/bibles/forms/bibleimportrequestdialog.py +++ b/openlp/plugins/bibles/forms/bibleimportrequestdialog.py @@ -53,7 +53,7 @@ class Ui_BibleImportRequest(object): font.setBold(True) self.headlineLabel.setFont(font) self.headlineLabel.setObjectName("HeadlineLabel") - self.verticalLayout.addWidget(self.HeadlineLabel) + self.verticalLayout.addWidget(self.headlineLabel) self.infoLabel = QtGui.QLabel(self.widget) self.infoLabel.setObjectName("InfoLabel") self.verticalLayout.addWidget(self.infoLabel) diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index b5644db81..7d1791281 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -70,7 +70,7 @@ import chardet import csv from openlp.core.lib import Receiver, translate -from openlp.plugins.bibles.lib.db import BibleDB, Testament +from openlp.plugins.bibles.lib.db import BibleDB, Testament, BiblesResourcesDB log = logging.getLogger(__name__) @@ -86,6 +86,7 @@ class CSVBible(BibleDB): """ log.info(self.__class__.__name__) BibleDB.__init__(self, parent, **kwargs) + self.parent = parent try: self.testamentsfile = kwargs[u'testamentsfile'] except KeyError: @@ -135,7 +136,10 @@ class CSVBible(BibleDB): self.wizard.progressBar.setMinimum(0) self.wizard.progressBar.setMaximum(66) success = True - #TODO: include create_meta language + language = self.parent.mediaItem.importRequest(u'language') + language = BiblesResourcesDB.get_language(language) + language_id = language[u'id'] + self.create_meta(u'language_id', language_id) books_file = None book_list = {} # Populate the Tables @@ -149,10 +153,11 @@ class CSVBible(BibleDB): self.wizard.incrementProgressBar(unicode( translate('BibleDB.Wizard', 'Importing books... %s')) % unicode(line[2], details['encoding'])) - #TODO: change create_book to the new database model - #(name, bk_ref_id, testament) + book_ref_id = self.parent.manager.get_book_ref_id_by_name( + unicode(line[2], details['encoding']), language_id) + book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) self.create_book(unicode(line[2], details['encoding']), - unicode(line[3], details['encoding']), int(line[1])) + book_ref_id, book_details[u'testament_id']) book_list[int(line[0])] = unicode(line[2], details['encoding']) Receiver.send_message(u'openlp_process_events') except (IOError, IndexError): diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 58fa0eec7..1f1a7e2a0 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -290,7 +290,7 @@ class BibleMediaItem(MediaManagerItem): def importRequest(self, case, name=None): self.import_request = BibleImportRequest(self) if self.import_request.exec_(case, name): - return unicode(self.import_request.RequestComboBox.currentText()) + return unicode(self.import_request.requestComboBox.currentText()) def loadBibles(self): log.debug(u'Loading Bibles') diff --git a/openlp/plugins/bibles/lib/openlp1.py b/openlp/plugins/bibles/lib/openlp1.py index f0e12481a..508add469 100644 --- a/openlp/plugins/bibles/lib/openlp1.py +++ b/openlp/plugins/bibles/lib/openlp1.py @@ -29,7 +29,7 @@ import sqlite from openlp.core.lib import Receiver from openlp.core.ui.wizard import WizardStrings -from openlp.plugins.bibles.lib.db import BibleDB +from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB log = logging.getLogger(__name__) @@ -43,6 +43,7 @@ class OpenLP1Bible(BibleDB): """ log.debug(self.__class__.__name__) BibleDB.__init__(self, parent, **kwargs) + self.parent = parent self.filename = kwargs[u'filename'] def do_import(self): @@ -56,7 +57,11 @@ class OpenLP1Bible(BibleDB): cursor = connection.cursor() except: return False - #TODO: include create_meta language + #Create the bible language + language = self.parent.mediaItem.importRequest(u'language') + language = BiblesResourcesDB.get_language(language) + language_id = language[u'id'] + self.create_meta(u'language_id', language_id) # Create all books. cursor.execute(u'SELECT id, testament_id, name, abbreviation FROM book') books = cursor.fetchall() @@ -69,9 +74,10 @@ class OpenLP1Bible(BibleDB): testament_id = int(book[1]) name = unicode(book[2], u'cp1252') abbreviation = unicode(book[3], u'cp1252') - #TODO: change create_book to the new database model - #(name, bk_ref_id, testament) - self.create_book(name, abbreviation, testament_id) + book_ref_id = self.parent.manager.get_book_ref_id_by_name(name, + language_id) + book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) + self.create_book(name, book_ref_id, book_details[u'testament_id']) # Update the progess bar. self.wizard.incrementProgressBar(WizardStrings.ImportingType % name) # Import the verses for this book. diff --git a/openlp/plugins/bibles/lib/opensong.py b/openlp/plugins/bibles/lib/opensong.py index 62cf12eaf..91b96abf2 100644 --- a/openlp/plugins/bibles/lib/opensong.py +++ b/openlp/plugins/bibles/lib/opensong.py @@ -28,7 +28,7 @@ import logging from lxml import objectify from openlp.core.lib import Receiver, translate -from openlp.plugins.bibles.lib.db import BibleDB +from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB log = logging.getLogger(__name__) @@ -43,6 +43,7 @@ class OpenSongBible(BibleDB): """ log.debug(self.__class__.__name__) BibleDB.__init__(self, parent, **kwargs) + self.parent = parent self.filename = kwargs['filename'] def do_import(self): @@ -61,14 +62,18 @@ class OpenSongBible(BibleDB): file = open(self.filename, u'r') opensong = objectify.parse(file) bible = opensong.getroot() - #TODO: include create_meta language + language = self.parent.mediaItem.importRequest(u'language') + language = BiblesResourcesDB.get_language(language) + language_id = language[u'id'] + self.create_meta(u'language_id', language_id) for book in bible.b: if self.stop_import_flag: break - #TODO: change create_book to the new database model - #(name, bk_ref_id, testament) - db_book = self.create_book(unicode(book.attrib[u'n']), - unicode(book.attrib[u'n'][:4])) + book_ref_id = self.parent.manager.get_book_ref_id_by_name( + unicode(book.attrib[u'n']), language_id) + book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) + db_book = self.create_book(unicode(book.attrib[u'n']), + book_ref_id, book_details[u'testament_id']) for chapter in book.c: if self.stop_import_flag: break diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index 05a57bbe4..6c8b2153b 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -33,7 +33,7 @@ import re from openlp.core.lib import Receiver, translate from openlp.core.utils import AppLocation -from openlp.plugins.bibles.lib.db import BibleDB +from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB log = logging.getLogger(__name__) @@ -46,6 +46,7 @@ class OSISBible(BibleDB): def __init__(self, parent, **kwargs): log.debug(self.__class__.__name__) BibleDB.__init__(self, parent, **kwargs) + self.parent = parent self.filename = kwargs[u'filename'] fbibles = None self.books = {} @@ -104,7 +105,11 @@ class OSISBible(BibleDB): finally: if detect_file: detect_file.close() - #TODO: include create_meta language with try - except scheme + # Set meta language_id + language = self.parent.mediaItem.importRequest(u'language') + language = BiblesResourcesDB.get_language(language) + language_id = language[u'id'] + self.create_meta(u'language_id', language_id) try: osis = codecs.open(self.filename, u'r', details['encoding']) for file_record in osis: @@ -123,10 +128,13 @@ class OSISBible(BibleDB): testament += 1 #TODO: change create_book to the new database model #(name, bk_ref_id, testament) + book_ref_id = self.parent.manager.get_book_ref_id_by_name( + unicode(self.books[book][0]), language_id) + book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) db_book = self.create_book( unicode(self.books[book][0]), - unicode(self.books[book][1]), - testament) + book_ref_id, + book_details[u'testament_id']) if last_chapter == 0: if book == u'Gen': self.wizard.progressBar.setMaximum(1188) diff --git a/resources/forms/bibleimportrequestdialog.ui b/resources/forms/bibleimportrequestdialog.ui new file mode 100644 index 000000000..5795300f9 --- /dev/null +++ b/resources/forms/bibleimportrequestdialog.ui @@ -0,0 +1,137 @@ + + + BibleImportRequest + + + + 0 + 0 + 400 + 175 + + + + + 0 + 0 + + + + Dialog + + + + + 10 + 15 + 381 + 151 + + + + + + + + Arial + 12 + 75 + true + + + + Choose Book: + + + + + + + The following books cannot be clearly attributed. +Please choose the book it is. + + + + + + + + + Book: + + + + + + + + 0 + 0 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + BibleImportRequestButtonBox + accepted() + BibleImportRequest + accept() + + + 248 + 254 + + + 157 + 274 + + + + + BibleImportRequestButtonBox + rejected() + BibleImportRequest + reject() + + + 316 + 260 + + + 286 + 274 + + + + + From a23d902fa57ac3901a36042e16486ffee148b38e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Thu, 17 Mar 2011 21:54:22 +0100 Subject: [PATCH 05/97] adapt the second_bible searchfunction to the new book name scheme --- openlp/plugins/bibles/lib/db.py | 31 ++++++++++++++++++++++++++ openlp/plugins/bibles/lib/manager.py | 22 +++++++++++++++--- openlp/plugins/bibles/lib/mediaitem.py | 4 ++-- 3 files changed, 52 insertions(+), 5 deletions(-) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 68edc55ef..6f2f2e2cb 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -357,6 +357,17 @@ class BibleDB(QtCore.QObject, Manager): """ return self.get_all_objects(Book, order_by_ref=Book.id) + def get_book_by_book_ref_id(self, id): + """ + Return a book object from the database. + + ``book`` + The name of the book to return. + """ + log.debug(u'BibleDb.get_book_by_book_ref_id("%s")', id) + db_book = self.get_object_filtered(Book, Book.book_reference_id.like(id)) + return db_book + def get_verses(self, reference_list, en_reference_list): """ This is probably the most used function. It retrieves the list of @@ -863,6 +874,26 @@ class SpellingDB(QtCore.QObject, Manager): return None else: return id[0] + + def get_book_name_by_reference_id(self, id, language): + """ + Return the name of a book by id and language. + + ``id`` + The name to search the id. + + ``language`` + The language for which should be searched + """ + log.debug(u'SpellingDB.get_book_name_by_reference_id("%s", "%s")', id, + language) + name = self.session.query(Spelling.name)\ + .filter(Spelling.book_reference_id.like(id))\ + .filter(Spelling.language_id.like(language)).first() + if not name: + return None + else: + return unicode(name[0]) def create_spelling(self, name, book_reference_id, language_id): """ diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index de66c38e0..44bb6dcd3 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -255,7 +255,7 @@ class BibleManager(object): book = self.get_book_ref(book, int(language_id.value)) return self.db_cache[bible].get_verse_count(book, chapter) - def get_verses(self, bible, versetext): + def get_verses(self, bible, versetext, secondbible=False): """ Parses a scripture reference, fetches the verses from the Bible specified, and returns a list of ``Verse`` objects. @@ -286,13 +286,29 @@ class BibleManager(object): return None reflist = parse_reference(versetext) if reflist: - log.debug(u'reflist:%s', reflist) + # if we use a second bible we have to rename the book names + if secondbible: + log.debug(u'BibleManager.get_verses("secondbible true")') + meta = self.db_cache[bible].get_object(BibleMeta, + u'language_id') + language_id = meta.value + new_reflist = [] + for item in reflist: + if item: + book = self.get_book_ref(item[0]) + book_ref_id = self.parent.manager.\ + get_book_ref_id_by_name(book, language_id) + book = self.db_cache[bible].get_book_by_book_ref_id( + book_ref_id) + new_reflist.append((book.name, item[1], item[2], item[3])) + reflist = new_reflist + log.debug(u'BibleManager.get_verses("reflist: %s")', reflist) en_reflist = [] for item in reflist: if item: book = self.get_book_ref(item[0]) en_reflist.append((book, item[1], item[2], item[3])) - log.debug(u'en_reflist:%s', en_reflist) + log.debug(u'BibleManager.get_verses("en_reflist: %s")', en_reflist) return self.db_cache[bible].get_verses(reflist, en_reflist) else: Receiver.send_message(u'openlp_information_message', { diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 1f1a7e2a0..d2753cfc5 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -482,7 +482,7 @@ class BibleMediaItem(MediaManagerItem): self.search_results = self.parent.manager.get_verses(bible, versetext) if second_bible: self.second_search_results = self.parent.manager.get_verses( - second_bible, versetext) + second_bible, versetext, True) if self.advancedClearComboBox.currentIndex() == 0: self.listView.clear() if self.listView.count() != 0: @@ -509,7 +509,7 @@ class BibleMediaItem(MediaManagerItem): self.search_results = self.parent.manager.get_verses(bible, text) if second_bible and self.search_results: self.second_search_results = self.parent.manager.get_verses( - second_bible, text) + second_bible, text, True) else: # We are doing a 'Text Search'. Receiver.send_message(u'cursor_busy') From 9a30a4ae6acd1b093dfde57090d638d162971524 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Thu, 17 Mar 2011 22:04:54 +0100 Subject: [PATCH 06/97] Clean up --- openlp/plugins/bibles/lib/db.py | 23 ++--------------------- openlp/plugins/bibles/lib/manager.py | 3 ++- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 6f2f2e2cb..2d1d1efad 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -365,7 +365,8 @@ class BibleDB(QtCore.QObject, Manager): The name of the book to return. """ log.debug(u'BibleDb.get_book_by_book_ref_id("%s")', id) - db_book = self.get_object_filtered(Book, Book.book_reference_id.like(id)) + db_book = self.get_object_filtered(Book, + Book.book_reference_id.like(id)) return db_book def get_verses(self, reference_list, en_reference_list): @@ -874,26 +875,6 @@ class SpellingDB(QtCore.QObject, Manager): return None else: return id[0] - - def get_book_name_by_reference_id(self, id, language): - """ - Return the name of a book by id and language. - - ``id`` - The name to search the id. - - ``language`` - The language for which should be searched - """ - log.debug(u'SpellingDB.get_book_name_by_reference_id("%s", "%s")', id, - language) - name = self.session.query(Spelling.name)\ - .filter(Spelling.book_reference_id.like(id))\ - .filter(Spelling.language_id.like(language)).first() - if not name: - return None - else: - return unicode(name[0]) def create_spelling(self, name, book_reference_id, language_id): """ diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 44bb6dcd3..4fa405c24 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -300,7 +300,8 @@ class BibleManager(object): get_book_ref_id_by_name(book, language_id) book = self.db_cache[bible].get_book_by_book_ref_id( book_ref_id) - new_reflist.append((book.name, item[1], item[2], item[3])) + new_reflist.append((book.name, item[1], item[2], + item[3])) reflist = new_reflist log.debug(u'BibleManager.get_verses("reflist: %s")', reflist) en_reflist = [] From 4071daec18cec5bdae0a0ae86defb6944568206f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Fri, 18 Mar 2011 10:52:54 +0100 Subject: [PATCH 07/97] add error handling if the user abort the dialog --- openlp/plugins/bibles/lib/csvbible.py | 8 ++++++++ openlp/plugins/bibles/lib/http.py | 8 ++++++++ openlp/plugins/bibles/lib/manager.py | 5 ++++- openlp/plugins/bibles/lib/openlp1.py | 8 ++++++++ openlp/plugins/bibles/lib/opensong.py | 8 ++++++++ openlp/plugins/bibles/lib/osis.py | 10 ++++++++-- 6 files changed, 44 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index 7d1791281..8884c436a 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -137,6 +137,10 @@ class CSVBible(BibleDB): self.wizard.progressBar.setMaximum(66) success = True language = self.parent.mediaItem.importRequest(u'language') + if not language: + log.exception(u'Importing books from %s " '\ + 'failed' % self.booksfile) + return False language = BiblesResourcesDB.get_language(language) language_id = language[u'id'] self.create_meta(u'language_id', language_id) @@ -155,6 +159,10 @@ class CSVBible(BibleDB): unicode(line[2], details['encoding'])) book_ref_id = self.parent.manager.get_book_ref_id_by_name( unicode(line[2], details['encoding']), language_id) + if not book_ref_id: + log.exception(u'Importing books from %s " '\ + 'failed' % self.booksfile) + return False book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) self.create_book(unicode(line[2], details['encoding']), book_ref_id, book_details[u'testament_id']) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index cd5f5a2d9..9d91298d0 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -406,6 +406,10 @@ class HTTPBible(BibleDB): language_id = bible[u'language_id'] else: language = self.parent.mediaItem.importRequest(u'language') + if not language: + log.exception(u'Importing books from %s - download name: "%s" '\ + 'failed' % (self.download_source, self.download_name)) + return False language = BiblesResourcesDB.get_language(language) language_id = language[u'id'] # Store the language_id. @@ -413,6 +417,10 @@ class HTTPBible(BibleDB): for book in books: book_ref_id = self.parent.manager.get_book_ref_id_by_name(book, language_id) + if not book_ref_id: + log.exception(u'Importing books from %s - download name: "%s" '\ + 'failed' % (self.download_source, self.download_name)) + return False book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) log.debug(u'Book details: Name:%s; id:%s; testament_id:%s', book, book_ref_id, book_details[u'testament_id']) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 4fa405c24..58e7b052f 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -352,7 +352,10 @@ class BibleManager(object): log.debug(book_ref) book_temp = BiblesResourcesDB.get_book(book_ref) log.debug(book_temp) - book_id = book_temp[u'id'] + if book_temp: + book_id = book_temp[u'id'] + else: + return None if book_id: self.spelling_cache[u'spelling'].create_spelling(book, book_id, language_id) diff --git a/openlp/plugins/bibles/lib/openlp1.py b/openlp/plugins/bibles/lib/openlp1.py index 508add469..2d7ed903b 100644 --- a/openlp/plugins/bibles/lib/openlp1.py +++ b/openlp/plugins/bibles/lib/openlp1.py @@ -59,6 +59,10 @@ class OpenLP1Bible(BibleDB): return False #Create the bible language language = self.parent.mediaItem.importRequest(u'language') + if not language: + log.exception(u'Importing books from %s " '\ + 'failed' % self.filename) + return False language = BiblesResourcesDB.get_language(language) language_id = language[u'id'] self.create_meta(u'language_id', language_id) @@ -76,6 +80,10 @@ class OpenLP1Bible(BibleDB): abbreviation = unicode(book[3], u'cp1252') book_ref_id = self.parent.manager.get_book_ref_id_by_name(name, language_id) + if not book_ref_id: + log.exception(u'Importing books from %s " '\ + 'failed' % self.filename) + return False book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) self.create_book(name, book_ref_id, book_details[u'testament_id']) # Update the progess bar. diff --git a/openlp/plugins/bibles/lib/opensong.py b/openlp/plugins/bibles/lib/opensong.py index 91b96abf2..f1a64c2e7 100644 --- a/openlp/plugins/bibles/lib/opensong.py +++ b/openlp/plugins/bibles/lib/opensong.py @@ -63,6 +63,10 @@ class OpenSongBible(BibleDB): opensong = objectify.parse(file) bible = opensong.getroot() language = self.parent.mediaItem.importRequest(u'language') + if not language: + log.exception(u'Importing books from %s " '\ + 'failed' % self.filename) + return False language = BiblesResourcesDB.get_language(language) language_id = language[u'id'] self.create_meta(u'language_id', language_id) @@ -71,6 +75,10 @@ class OpenSongBible(BibleDB): break book_ref_id = self.parent.manager.get_book_ref_id_by_name( unicode(book.attrib[u'n']), language_id) + if not book_ref_id: + log.exception(u'Importing books from %s " '\ + 'failed' % self.filename) + return False book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) db_book = self.create_book(unicode(book.attrib[u'n']), book_ref_id, book_details[u'testament_id']) diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index 6c8b2153b..277b73a23 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -107,6 +107,10 @@ class OSISBible(BibleDB): detect_file.close() # Set meta language_id language = self.parent.mediaItem.importRequest(u'language') + if not language: + log.exception(u'Importing books from %s " '\ + 'failed' % self.filename) + return False language = BiblesResourcesDB.get_language(language) language_id = language[u'id'] self.create_meta(u'language_id', language_id) @@ -126,10 +130,12 @@ class OSISBible(BibleDB): log.debug(u'New book: "%s"', self.books[book][0]) if book == u'Matt' or book == u'Jdt': testament += 1 - #TODO: change create_book to the new database model - #(name, bk_ref_id, testament) book_ref_id = self.parent.manager.get_book_ref_id_by_name( unicode(self.books[book][0]), language_id) + if not book_ref_id: + log.exception(u'Importing books from %s " '\ + 'failed' % self.filename) + return False book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) db_book = self.create_book( unicode(self.books[book][0]), From 599e87695590eb18829cbc1dcf14651f916ddbc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Wed, 23 Mar 2011 20:18:51 +0100 Subject: [PATCH 08/97] Bug fixes Changed book handling from name to book_reference_id Comment out unused function to fill the testament table in the local bible database --- openlp/plugins/bibles/lib/csvbible.py | 9 +- openlp/plugins/bibles/lib/db.py | 111 +++++++++++++++---------- openlp/plugins/bibles/lib/http.py | 84 ++++++++++--------- openlp/plugins/bibles/lib/manager.py | 67 +++++++-------- openlp/plugins/bibles/lib/mediaitem.py | 4 +- openlp/plugins/bibles/lib/openlp1.py | 5 +- openlp/plugins/bibles/lib/osis.py | 14 ++-- 7 files changed, 163 insertions(+), 131 deletions(-) diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index 8884c436a..2a3949dea 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -70,7 +70,7 @@ import chardet import csv from openlp.core.lib import Receiver, translate -from openlp.plugins.bibles.lib.db import BibleDB, Testament, BiblesResourcesDB +from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB#, Testament log = logging.getLogger(__name__) @@ -87,13 +87,16 @@ class CSVBible(BibleDB): log.info(self.__class__.__name__) BibleDB.__init__(self, parent, **kwargs) self.parent = parent + #TODO: Delete unused code + ''' try: self.testamentsfile = kwargs[u'testamentsfile'] except KeyError: self.testamentsfile = None + ''' self.booksfile = kwargs[u'booksfile'] self.versesfile = kwargs[u'versefile'] - + ''' def setup_testaments(self): """ Overrides parent method so we can handle importing a testament file. @@ -127,7 +130,7 @@ class CSVBible(BibleDB): 'BibleDB.Wizard', 'Importing testaments... done.')), 2) else: BibleDB.setup_testaments(self) - + ''' def do_import(self): """ Import the bible books and verses. diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 2d1d1efad..b4a5b0d3b 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -48,13 +48,14 @@ class BibleMeta(BaseModel): """ pass - +#TODO: Delete unused code +''' class Testament(BaseModel): """ Bible Testaments """ pass - +''' class Book(BaseModel): """ @@ -89,10 +90,13 @@ def init_schema(url): Column(u'key', types.Unicode(255), primary_key=True, index=True), Column(u'value', types.Unicode(255)), ) + #TODO: Delete unused code + ''' testament_table = Table(u'testament', metadata, Column(u'id', types.Integer, primary_key=True), Column(u'name', types.Unicode(50)), ) + ''' book_table = Table(u'book', metadata, Column(u'id', types.Integer, primary_key=True), Column(u'book_reference_id', types.Integer), @@ -101,7 +105,8 @@ def init_schema(url): ) verse_table = Table(u'verse', metadata, Column(u'id', types.Integer, primary_key=True, index=True), - Column(u'book_id', types.Integer, ForeignKey(u'book.id'), index=True), + Column(u'book_id', types.Integer, ForeignKey( + u'book.id'), index=True), Column(u'chapter', types.Integer, index=True), Column(u'verse', types.Integer, index=True), Column(u'text', types.UnicodeText, index=True), @@ -111,10 +116,13 @@ def init_schema(url): class_mapper(BibleMeta) except UnmappedClassError: mapper(BibleMeta, meta_table) + #TODO: Delete unused code + ''' try: class_mapper(Testament) except UnmappedClassError: mapper(Testament, testament_table) + ''' try: class_mapper(Book) except UnmappedClassError: @@ -239,9 +247,12 @@ class BibleDB(QtCore.QObject, Manager): """ self.wizard = wizard self.create_meta(u'dbversion', u'2') - self.setup_testaments() + #TODO: Delete unused code + #self.setup_testaments() return self.name + #TODO: Delete unused code + ''' def setup_testaments(self): """ Initialise the testaments section of a bible with suitable defaults. @@ -249,6 +260,7 @@ class BibleDB(QtCore.QObject, Manager): self.save_object(Testament.populate(name=u'Old Testament')) self.save_object(Testament.populate(name=u'New Testament')) self.save_object(Testament.populate(name=u'Apocrypha')) + ''' def create_book(self, name, bk_ref_id, testament=1): """ @@ -264,7 +276,7 @@ class BibleDB(QtCore.QObject, Manager): *Defaults to 1.* The testament_reference_id from bibles_resources.sqlite of the testament this book belongs to. """ - log.debug(u'create_book %s,%s', name, bk_ref_id) + log.debug(u'BibleDB.create_book("%s", "%s")', name, bk_ref_id) book = Book.populate(name=name, book_reference_id=bk_ref_id, testament_reference_id=testament) self.save_object(book) @@ -284,7 +296,7 @@ class BibleDB(QtCore.QObject, Manager): A dict of the verses to be inserted. The key is the verse number, and the value is the verse text. """ - log.debug(u'create_chapter %s,%s', book_id, chapter) + log.debug(u'BibleDBcreate_chapter("%s", "%s")', book_id, chapter) # Text list has book and chapter as first two elements of the array. for verse_number, verse_text in textlist.iteritems(): verse = Verse.populate( @@ -336,7 +348,7 @@ class BibleDB(QtCore.QObject, Manager): """ if not isinstance(value, unicode): value = unicode(value) - log.debug(u'save_meta %s/%s', key, value) + log.debug(u'BibleDB.save_meta("%s/%s")', key, value) self.save_object(BibleMeta.populate(key=key, value=value)) def get_book(self, book): @@ -346,7 +358,7 @@ class BibleDB(QtCore.QObject, Manager): ``book`` The name of the book to return. """ - log.debug(u'BibleDb.get_book("%s")', book) + log.debug(u'BibleDB.get_book("%s")', book) db_book = self.get_object_filtered(Book, Book.name.like(book + u'%')) return db_book @@ -361,15 +373,15 @@ class BibleDB(QtCore.QObject, Manager): """ Return a book object from the database. - ``book`` - The name of the book to return. + ``id`` + The reference id of the book to return. """ - log.debug(u'BibleDb.get_book_by_book_ref_id("%s")', id) + log.debug(u'BibleDB.get_book_by_book_ref_id("%s")', id) db_book = self.get_object_filtered(Book, Book.book_reference_id.like(id)) return db_book - def get_verses(self, reference_list, en_reference_list): + def get_verses(self, reference_list): """ This is probably the most used function. It retrieves the list of verses based on the user's query. @@ -378,27 +390,24 @@ class BibleDB(QtCore.QObject, Manager): This is the list of references the media manager item wants. It is a list of tuples, with the following format:: - (book, chapter, start_verse, end_verse) + (book_reference_id, chapter, start_verse, end_verse) Therefore, when you are looking for multiple items, simply break them up into references like this, bundle them into a list. This function then runs through the list, and returns an amalgamated list of ``Verse`` objects. For example:: - [(u'Genesis', 1, 1, 1), (u'Genesis', 2, 2, 3)] + [(u'35', 1, 1, 1), (u'35', 2, 2, 3)] """ - log.debug(u'BibleDB.get_verses: %s - %s', reference_list, - en_reference_list) + log.debug(u'BibleDB.get_verses("%s")', reference_list) verse_list = [] - for (book, chapter, start_verse, end_verse), (en_book, en_chapter, - en_start_verse, en_end_verse) in zip(reference_list, - en_reference_list): - db_book = self.get_book(book) + for book_id, chapter, start_verse, end_verse in reference_list: + db_book = self.get_book_by_book_ref_id(book_id) if db_book: - book = db_book.name - log.debug(u'Book name corrected to "%s"', book) + book_id = db_book.book_reference_id + log.debug(u'Book name corrected to "%s"', db_book.name) if end_verse == -1: - end_verse = self.get_verse_count(en_book, chapter) + end_verse = self.get_verse_count(book_id, chapter) verses = self.session.query(Verse)\ .filter_by(book_id=db_book.id)\ .filter_by(chapter=chapter)\ @@ -443,23 +452,23 @@ class BibleDB(QtCore.QObject, Manager): verses = verses.all() return verses - def get_chapter_count(self, book): + def get_chapter_count(self, book_id): """ Return the number of chapters in a book. ``book`` The book to get the chapter count for. """ - log.debug(u'BibleDB.get_chapter_count("%s")', book) + log.debug(u'BibleDB.get_chapter_count("%s")', book_id) count = self.session.query(Verse.chapter).join(Book)\ - .filter(Book.name==book)\ + .filter(Book.book_reference_id==book_id)\ .distinct().count() if not count: return 0 else: return count - def get_verse_count(self, book, chapter): + def get_verse_count(self, book_id, chapter): """ Return the number of verses in a chapter. @@ -469,9 +478,9 @@ class BibleDB(QtCore.QObject, Manager): ``chapter`` The chapter to get the verse count for. """ - log.debug(u'BibleDB.get_verse_count("%s", %s)', book, chapter) + log.debug(u'BibleDB.get_verse_count("%s", "%s")', book_id, chapter) count = self.session.query(Verse).join(Book)\ - .filter(Book.name==book)\ + .filter(Book.book_reference_id==book_id)\ .filter(Verse.chapter==chapter)\ .count() if not count: @@ -538,6 +547,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): """ Return a list of all the books of the Bible. """ + log.debug(u'BiblesResourcesDB.get_books()') books = BiblesResourcesDB.run_sql(u'SELECT id, testament_id, name, ' u'abbreviation, chapters FROM book_reference ORDER BY id') book_list = [] @@ -559,7 +569,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): ``name`` The name or abbreviation of the book. """ - log.debug(u'get_book: %s', name) + log.debug(u'BiblesResourcesDB.get_book("%s")', name) if not isinstance(name, unicode): name = unicode(name) books = BiblesResourcesDB.run_sql(u'SELECT id, testament_id, name, ' @@ -584,6 +594,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): ``id`` The id of the book. """ + log.debug(u'BiblesResourcesDB.get_book_by_id("%s")', id) if not isinstance(id, int): id = int(id) books = BiblesResourcesDB.run_sql(u'SELECT id, testament_id, name, ' @@ -601,22 +612,22 @@ class BiblesResourcesDB(QtCore.QObject, Manager): return None @staticmethod - def get_chapter(name, chapter): + def get_chapter(book_id, chapter): """ Return the chapter details for a specific chapter of a book. - ``name`` - The name or abbreviation of a book. + ``book_id`` + The id of a book. ``chapter`` The chapter number. """ - if not isinstance(name, int): + log.debug(u'BiblesResourcesDB.get_chapter("%s", "%s")', book_id, chapter) + if not isinstance(chapter, int): chapter = int(chapter) - book = BiblesResourcesDB.get_book(name) chapters = BiblesResourcesDB.run_sql(u'SELECT id, book_reference_id, ' u'chapter, verse_count FROM chapters WHERE book_reference_id = ?', - (book[u'id'],)) + (book_id,)) if chapters: return { u'id': chapters[chapter-1][0], @@ -628,30 +639,33 @@ class BiblesResourcesDB(QtCore.QObject, Manager): return None @staticmethod - def get_chapter_count(book): + def get_chapter_count(book_id): """ Return the number of chapters in a book. - ``book`` - The name or abbreviation of the book. + ``book_id`` + The id of the book. """ - details = BiblesResourcesDB.get_book(book) + log.debug(u'BiblesResourcesDB.get_chapter_count("%s")', book_id) + details = BiblesResourcesDB.get_book_by_id(book_id) if details: return details[u'chapters'] return 0 @staticmethod - def get_verse_count(book, chapter): + def get_verse_count(book_id, chapter): """ Return the number of verses in a chapter. ``book`` - The name or abbreviation of the book. + The id of the book. ``chapter`` The number of the chapter. """ - details = BiblesResourcesDB.get_chapter(book, chapter) + log.debug(u'BiblesResourcesDB.get_verse_count("%s", "%s")', book_id, + chapter) + details = BiblesResourcesDB.get_chapter(book_id, chapter) if details: return details[u'verse_count'] return 0 @@ -664,6 +678,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): ``name`` The name or abbreviation of the book. """ + log.debug(u'BiblesResourcesDB.get_download_source("%s")', source) if not isinstance(source, unicode): source = unicode(source) source = source.title() @@ -685,6 +700,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): ``source`` The source of the webbible. """ + log.debug(u'BiblesResourcesDB.get_webbibles("%s")', source) if not isinstance(source, unicode): source = unicode(source) source = BiblesResourcesDB.get_download_source(source) @@ -716,6 +732,8 @@ class BiblesResourcesDB(QtCore.QObject, Manager): ``source`` The source of the webbible. """ + log.debug(u'BiblesResourcesDB.get_webbibles("%s", "%s")', abbreviation, + source) if not isinstance(abbreviation, unicode): abbreviation = unicode(abbreviation) if not isinstance(source, unicode): @@ -742,6 +760,8 @@ class BiblesResourcesDB(QtCore.QObject, Manager): """ Return a book_reference_id if the name matches. """ + log.debug(u'BiblesResourcesDB.get_spelling("%s", "%s")', name, + language_id) if language_id: id = BiblesResourcesDB.run_sql(u'SELECT book_reference_id ' u'FROM spelling WHERE name = ? and language_id = ? ORDER BY id', @@ -763,6 +783,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): ``name`` The name or abbreviation of the language. """ + log.debug(u'BiblesResourcesDB.get_language("%s", "%s")', name) if not isinstance(name, unicode): name = unicode(name) name = name.title() @@ -782,6 +803,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): """ Return a dict containing all languages with id, name and code. """ + log.debug(u'BiblesResourcesDB.get_languages()') languages = BiblesResourcesDB.run_sql(u'SELECT id, name, code FROM ' u'language ORDER by name') if languages: @@ -801,6 +823,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): """ Return a list of all testaments and their id of the Bible. """ + log.debug(u'BiblesResourcesDB.get_testament_reference()') testaments = BiblesResourcesDB.run_sql(u'SELECT id, name FROM ' u'testament_reference ORDER BY id') testament_list = [] @@ -889,7 +912,7 @@ class SpellingDB(QtCore.QObject, Manager): ``language_id`` The language which the spelling of the book name is. """ - log.debug(u'create_spelling %s, book_reference_id:%s, language_id:%s', + log.debug(u'SpellingDBcreate_spelling("%s", "%s", "%s"', name, book_reference_id, language_id) spelling = Spelling.populate(name=name, book_reference_id=book_reference_id, language_id=language_id) diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 9d91298d0..39a2e3699 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -42,7 +42,7 @@ from openlp.core.lib.ui import critical_error_message_box from openlp.core.utils import AppLocation, get_web_page from openlp.plugins.bibles.lib import SearchResults from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB, \ - SpellingDB, Book + SpellingDB, Book, BibleMeta log = logging.getLogger(__name__) @@ -51,7 +51,7 @@ class BGExtract(object): Extract verses from BibleGateway """ def __init__(self, proxyurl=None): - log.debug(u'init %s', proxyurl) + log.debug(u'BGExtract.init("%s")', proxyurl) self.proxyurl = proxyurl socket.setdefaulttimeout(30) @@ -68,9 +68,11 @@ class BGExtract(object): ``chapter`` Chapter number. """ - log.debug(u'get_bible_chapter %s, %s, %s', version, bookname, chapter) + log.debug(u'BGExtract.get_bible_chapter("%s", "%s", "%s")', version, + bookname, chapter) + urlbookname = urllib.quote(bookname.encode("utf-8")) url_params = urllib.urlencode( - {u'search': u'%s %s' % (bookname, chapter), + {u'search': u'%s %s' % (urlbookname, chapter), u'version': u'%s' % version}) cleaner = [(re.compile(' |
|\'\+\''), lambda match: '')] soup = get_soup_for_bible_ref( @@ -135,7 +137,7 @@ class BGExtract(object): ``version`` The version of the bible like NIV for New International Version """ - log.debug(u'get_books_from_http %s', version) + log.debug(u'BGExtract.get_books_from_http("%s")', version) url_params = urllib.urlencode( {u'search': 'Bible-List', u'version': u'%s' % version}) reference_url = u'http://www.biblegateway.com/passage/?%s' % url_params @@ -161,7 +163,6 @@ class BGExtract(object): Receiver.send_message(u'openlp_process_events') content = soup.find(u'table', {u'id': u'booklist'}) content = content.findAll(u'tr') - #log.debug(content) if not content: log.exception(u'No books found in the Biblegateway response.') send_error_message(u'parse') @@ -171,7 +172,6 @@ class BGExtract(object): book = book.find(u'td') if book: books.append(book.contents[0]) - log.debug(book.contents[0]) return books @@ -180,7 +180,7 @@ class BSExtract(object): Extract verses from Bibleserver.com """ def __init__(self, proxyurl=None): - log.debug(u'init %s', proxyurl) + log.debug(u'BSExtract.init("%s")', proxyurl) self.proxyurl = proxyurl socket.setdefaulttimeout(30) @@ -197,9 +197,11 @@ class BSExtract(object): ``chapter`` Chapter number """ - log.debug(u'get_bible_chapter %s,%s,%s', version, bookname, chapter) + log.debug(u'BSExtract.get_bible_chapter("%s", "%s", "%s")', version, + bookname, chapter) + urlbookname = urllib.quote(bookname.encode("utf-8")) chapter_url = u'http://m.bibleserver.com/text/%s/%s%s' % \ - (version, bookname, chapter) + (version, urlbookname, chapter) header = (u'Accept-Language', u'en') soup = get_soup_for_bible_ref(chapter_url, header) if not soup: @@ -227,7 +229,7 @@ class BSExtract(object): ``version`` The version of the bible like NIV for New International Version """ - log.debug(u'get_books_from_http %s', version) + log.debug(u'BSExtract.get_books_from_http("%s")', version) chapter_url = u'http://m.bibleserver.com/overlay/selectBook?'\ 'translation=%s' % (version) soup = get_soup_for_bible_ref(chapter_url) @@ -250,7 +252,7 @@ class CWExtract(object): Extract verses from CrossWalk/BibleStudyTools """ def __init__(self, proxyurl=None): - log.debug(u'init %s', proxyurl) + log.debug(u'CWExtract.init("%s")', proxyurl) self.proxyurl = proxyurl socket.setdefaulttimeout(30) @@ -267,10 +269,13 @@ class CWExtract(object): ``chapter`` Chapter number """ - log.debug(u'get_bible_chapter %s,%s,%s', version, bookname, chapter) + log.debug(u'CWExtract.get_bible_chapter("%s", "%s", "%s")', version, + bookname, chapter) urlbookname = bookname.replace(u' ', u'-') + urlbookname = urlbookname.lower() + urlbookname = urllib.quote(urlbookname.encode("utf-8")) chapter_url = u'http://www.biblestudytools.com/%s/%s/%s.html' % \ - (version, urlbookname.lower(), chapter) + (version, urlbookname, chapter) soup = get_soup_for_bible_ref(chapter_url) if not soup: return None @@ -320,7 +325,7 @@ class CWExtract(object): ``version`` The version of the bible like NIV for New International Version """ - log.debug(u'get_books_from_http %s', version) + log.debug(u'CWExtract.get_books_from_http("%s")', version) chapter_url = u'http://www.biblestudytools.com/%s/'\ % (version) soup = get_soup_for_bible_ref(chapter_url) @@ -337,7 +342,6 @@ class CWExtract(object): for book in content: book = book.find(u'a') books.append(book.contents[0]) - log.debug(book.contents[0]) return books @@ -377,8 +381,10 @@ class HTTPBible(BibleDB): Run the import. This method overrides the parent class method. Returns ``True`` on success, ``False`` on failure. """ - self.wizard.progressBar.setMaximum(2) - self.wizard.incrementProgressBar('Registering bible...') + self.wizard.progressBar.setMaximum(68) + self.wizard.incrementProgressBar(unicode(translate( + 'BiblesPlugin.HTTPBible', + 'Registering bible and loading books...'))) self.create_meta(u'download source', self.download_source) self.create_meta(u'download name', self.download_name) if self.proxy_server: @@ -400,6 +406,9 @@ class HTTPBible(BibleDB): log.exception(u'Importing books from %s - download name: "%s" '\ 'failed' % (self.download_source, self.download_name)) return False + self.wizard.progressBar.setMaximum(len(books)+2) + self.wizard.incrementProgressBar(unicode(translate( + 'BiblesPlugin.HTTPBible', 'Registering Language...'))) bible = BiblesResourcesDB.get_webbible(self.download_name, self.download_source.lower()) if bible[u'language_id']: @@ -415,6 +424,9 @@ class HTTPBible(BibleDB): # Store the language_id. self.create_meta(u'language_id', language_id) for book in books: + self.wizard.incrementProgressBar(unicode(translate( + 'BiblesPlugin.HTTPBible', 'Importing %s...', + 'Importing ...')) % book) book_ref_id = self.parent.manager.get_book_ref_id_by_name(book, language_id) if not book_ref_id: @@ -427,7 +439,7 @@ class HTTPBible(BibleDB): self.create_book(book, book_ref_id, book_details[u'testament_id']) return True - def get_verses(self, reference_list, en_reference_list): + def get_verses(self, reference_list): """ A reimplementation of the ``BibleDB.get_verses`` method, this one is specifically for web Bibles. It first checks to see if the particular @@ -439,26 +451,19 @@ class HTTPBible(BibleDB): This is the list of references the media manager item wants. It is a list of tuples, with the following format:: - (book, chapter, start_verse, end_verse) - - ``en_reference_list`` - This is the list of references the media manager item wants. It is - a list of tuples, with the following format with englisch book - names:: - - (book, chapter, start_verse, end_verse) + (book_reference_id, chapter, start_verse, end_verse) Therefore, when you are looking for multiple items, simply break them up into references like this, bundle them into a list. This function then runs through the list, and returns an amalgamated list of ``Verse`` objects. For example:: - [(u'Genesis', 1, 1, 1), (u'Genesis', 2, 2, 3)] + [(u'35', 1, 1, 1), (u'35', 2, 2, 3)] """ + log.debug(u'HTTPBible.get_verses("%s")', reference_list) for reference in reference_list: - log.debug(u'Reference: %s', reference) - book = reference[0] - db_book = self.get_book(book) + book_id = reference[0] + db_book = self.get_book_by_book_ref_id(book_id) if not db_book: critical_error_message_box( translate('BiblesPlugin', 'No Book Found'), @@ -467,7 +472,7 @@ class HTTPBible(BibleDB): 'have spelled the name of the book correctly.')) return [] book = db_book.name - if BibleDB.get_verse_count(self, book, reference[1]) == 0: + if BibleDB.get_verse_count(self, book_id, reference[1]) == 0: Receiver.send_message(u'cursor_busy') search_results = self.get_chapter(book, reference[1]) if search_results and search_results.has_verselist(): @@ -484,13 +489,13 @@ class HTTPBible(BibleDB): Receiver.send_message(u'openlp_process_events') Receiver.send_message(u'cursor_normal') Receiver.send_message(u'openlp_process_events') - return BibleDB.get_verses(self, reference_list, en_reference_list) + return BibleDB.get_verses(self, reference_list) def get_chapter(self, book, chapter): """ Receive the request and call the relevant handler methods. """ - log.debug(u'get_chapter %s, %s', book, chapter) + log.debug(u'HTTPBible.get_chapter("%s", "%s")', book, chapter) log.debug(u'source = %s', self.download_source) if self.download_source.lower() == u'crosswalk': handler = CWExtract(self.proxy_server) @@ -504,15 +509,17 @@ class HTTPBible(BibleDB): """ Return the list of books. """ + log.debug(u'HTTPBible.get_books("%s")', Book.name) return self.get_all_objects(Book, order_by_ref=Book.id) - def get_chapter_count(self, book): + def get_chapter_count(self, book_id): """ Return the number of chapters in a particular book. """ - return BiblesResourcesDB.get_chapter_count(book) + log.debug(u'HTTPBible.get_chapter_count("%s")', book_id) + return BiblesResourcesDB.get_chapter_count(book_id) - def get_verse_count(self, book, chapter): + def get_verse_count(self, book_id, chapter): """ Return the number of verses for the specified chapter and book. @@ -522,7 +529,8 @@ class HTTPBible(BibleDB): ``chapter`` The chapter whose verses are being counted. """ - return BiblesResourcesDB.get_verse_count(book, chapter) + log.debug(u'HTTPBible.get_verse_count("%s", %s)', book_id, chapter) + return BiblesResourcesDB.get_verse_count(book_id, chapter) def get_soup_for_bible_ref(reference_url, header=None, pre_parse_regex=None, pre_parse_substitute=None, cleaner=None): diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 58e7b052f..5f0890f0e 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -30,10 +30,11 @@ import os from PyQt4 import QtCore from openlp.core.lib import Receiver, SettingsManager, translate +from openlp.core.lib.ui import critical_error_message_box from openlp.core.utils import AppLocation, delete_file from openlp.plugins.bibles.lib import parse_reference from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta, SpellingDB, \ - Spelling, BiblesResourcesDB + BiblesResourcesDB from csvbible import CSVBible from http import HTTPBible from opensong import OpenSongBible @@ -223,14 +224,10 @@ class BibleManager(object): language_id = self.get_meta_data(bible, u'language_id') books = [] for book in self.db_cache[bible].get_books(): - book_id = self.get_book_ref_id_by_name(book.name, int( - language_id.value)) - book_temp = BiblesResourcesDB.get_book_by_id(book_id) - book_ref = book_temp[u'name'] books.append( { u'name': book.name, - u'chapters': self.db_cache[bible].get_chapter_count(book_ref) + u'chapters': self.db_cache[bible].get_chapter_count(book.book_reference_id) }) return books @@ -240,8 +237,6 @@ class BibleManager(object): """ log.debug(u'BibleManager.get_book_chapter_count ("%s", "%s")', bible, book) - language_id = self.get_meta_data(bible, u'language_id') - book = self.get_book_ref(book, int(language_id.value)) return self.db_cache[bible].get_chapter_count(book) def get_verse_count(self, bible, book, chapter): @@ -251,11 +246,11 @@ class BibleManager(object): """ log.debug(u'BibleManager.get_verse_count("%s", "%s", %s)', bible, book, chapter) - language_id = self.get_meta_data(bible, u'language_id') - book = self.get_book_ref(book, int(language_id.value)) - return self.db_cache[bible].get_verse_count(book, chapter) + db_book = self.db_cache[bible].get_book(book) + book_ref_id = db_book.book_reference_id + return self.db_cache[bible].get_verse_count(book_ref_id, chapter) - def get_verses(self, bible, versetext, secondbible=False): + def get_verses(self, bible, versetext, firstbible=False): """ Parses a scripture reference, fetches the verses from the Bible specified, and returns a list of ``Verse`` objects. @@ -286,31 +281,29 @@ class BibleManager(object): return None reflist = parse_reference(versetext) if reflist: - # if we use a second bible we have to rename the book names - if secondbible: - log.debug(u'BibleManager.get_verses("secondbible true")') - meta = self.db_cache[bible].get_object(BibleMeta, - u'language_id') - language_id = meta.value - new_reflist = [] - for item in reflist: - if item: - book = self.get_book_ref(item[0]) - book_ref_id = self.parent.manager.\ - get_book_ref_id_by_name(book, language_id) - book = self.db_cache[bible].get_book_by_book_ref_id( - book_ref_id) - new_reflist.append((book.name, item[1], item[2], - item[3])) - reflist = new_reflist - log.debug(u'BibleManager.get_verses("reflist: %s")', reflist) - en_reflist = [] + new_reflist = [] for item in reflist: if item: - book = self.get_book_ref(item[0]) - en_reflist.append((book, item[1], item[2], item[3])) - log.debug(u'BibleManager.get_verses("en_reflist: %s")', en_reflist) - return self.db_cache[bible].get_verses(reflist, en_reflist) + if firstbible: + db_book = self.db_cache[firstbible].get_book(item[0]) + db_book = self.db_cache[bible].get_book_by_book_ref_id( + db_book.book_reference_id) + else: + db_book = self.db_cache[bible].get_book(item[0]) + if db_book: + book_id = db_book.book_reference_id + log.debug(u'Book name corrected to "%s"', db_book.name) + new_reflist.append((book_id, item[1], item[2], + item[3])) + else: + log.debug(u'OpenLP failed to find book %s', item[0]) + critical_error_message_box( + translate('BiblesPlugin', 'No Book Found'), + translate('BiblesPlugin', 'No matching book ' + 'could be found in this Bible. Check that you have ' + 'spelled the name of the book correctly.')) + reflist = new_reflist + return self.db_cache[bible].get_verses(reflist) else: Receiver.send_message(u'openlp_information_message', { u'title': translate('BiblesPlugin.BibleManager', @@ -332,7 +325,8 @@ class BibleManager(object): log.debug(u'BibleManager.get_book_ref("%s", "%s")', book, language_id) book_id = self.get_book_ref_id_by_name(book, language_id) book_temp = BiblesResourcesDB.get_book_by_id(book_id) - log.debug(u'get_book_ref - Return:%s', book_temp[u'name']) + log.debug(u'BibleManager.get_book_ref("Return: %s")', + book_temp[u'name']) return book_temp[u'name'] def get_book_ref_id_by_name(self, book, language_id=None): @@ -360,7 +354,6 @@ class BibleManager(object): self.spelling_cache[u'spelling'].create_spelling(book, book_id, language_id) if book_id: - log.debug(u'get_book_ref_id_by_name - Return:%s', book_id) return book_id else: return None diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index d2753cfc5..43a20325f 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -482,7 +482,7 @@ class BibleMediaItem(MediaManagerItem): self.search_results = self.parent.manager.get_verses(bible, versetext) if second_bible: self.second_search_results = self.parent.manager.get_verses( - second_bible, versetext, True) + second_bible, versetext, bible) if self.advancedClearComboBox.currentIndex() == 0: self.listView.clear() if self.listView.count() != 0: @@ -509,7 +509,7 @@ class BibleMediaItem(MediaManagerItem): self.search_results = self.parent.manager.get_verses(bible, text) if second_bible and self.search_results: self.second_search_results = self.parent.manager.get_verses( - second_bible, text, True) + second_bible, text, bible) else: # We are doing a 'Text Search'. Receiver.send_message(u'cursor_busy') diff --git a/openlp/plugins/bibles/lib/openlp1.py b/openlp/plugins/bibles/lib/openlp1.py index 2d7ed903b..4cdb1e3fc 100644 --- a/openlp/plugins/bibles/lib/openlp1.py +++ b/openlp/plugins/bibles/lib/openlp1.py @@ -85,7 +85,8 @@ class OpenLP1Bible(BibleDB): 'failed' % self.filename) return False book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) - self.create_book(name, book_ref_id, book_details[u'testament_id']) + db_book = self.create_book(name, book_ref_id, + book_details[u'testament_id']) # Update the progess bar. self.wizard.incrementProgressBar(WizardStrings.ImportingType % name) # Import the verses for this book. @@ -99,7 +100,7 @@ class OpenLP1Bible(BibleDB): chapter = int(verse[0]) verse_number = int(verse[1]) text = unicode(verse[2], u'cp1252') - self.create_verse(book_id, chapter, verse_number, text) + self.create_verse(db_book.id, chapter, verse_number, text) Receiver.send_message(u'openlp_process_events') self.session.commit() connection.close() diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index 277b73a23..df9083da2 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -92,7 +92,8 @@ class OSISBible(BibleDB): osis = None success = True last_chapter = 0 - testament = 1 + #TODO: Delete unused code + #testament = 1 match_count = 0 self.wizard.incrementProgressBar(translate('BiblesPlugin.OsisImport', 'Detecting encoding (this may take a few minutes)...')) @@ -128,15 +129,18 @@ class OSISBible(BibleDB): verse_text = match.group(4) if not db_book or db_book.name != self.books[book][0]: log.debug(u'New book: "%s"', self.books[book][0]) - if book == u'Matt' or book == u'Jdt': - testament += 1 - book_ref_id = self.parent.manager.get_book_ref_id_by_name( + #TODO: Delete unused code + #if book == u'Matt' or book == u'Jdt': + # testament += 1 + book_ref_id = self.parent.manager.\ + get_book_ref_id_by_name( unicode(self.books[book][0]), language_id) if not book_ref_id: log.exception(u'Importing books from %s " '\ 'failed' % self.filename) return False - book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) + book_details = BiblesResourcesDB.get_book_by_id( + book_ref_id) db_book = self.create_book( unicode(self.books[book][0]), book_ref_id, From 27e635144dc7e8dfd1b0e56704d4463e635aa898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Wed, 23 Mar 2011 21:08:49 +0100 Subject: [PATCH 09/97] rename spelling to alternative_book_name --- openlp/plugins/bibles/lib/db.py | 71 +++++++++--------- openlp/plugins/bibles/lib/http.py | 2 +- openlp/plugins/bibles/lib/manager.py | 32 ++++---- .../bibles/resources/bibles_resources.sqlite | Bin 63488 -> 63488 bytes 4 files changed, 54 insertions(+), 51 deletions(-) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index b4a5b0d3b..abd0ebb9b 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -70,9 +70,9 @@ class Verse(BaseModel): """ pass -class Spelling(BaseModel): +class AlternativeBookNames(BaseModel): """ - Spelling model + Alternative Book Names model """ pass @@ -136,16 +136,17 @@ def init_schema(url): metadata.create_all(checkfirst=True) return session -def init_schema_spelling_extension(url): +def init_schema_alternative_book_names(url): """ - Setup a spelling database connection and initialise the database schema. + Setup a alternative book names database connection and initialise the + database schema. ``url`` The database to setup. """ session, metadata = init_db(url) - spelling_table = Table(u'spelling', metadata, + alternative_book_names_table = Table(u'alternative_book_names', metadata, Column(u'id', types.Integer, primary_key=True), Column(u'book_reference_id', types.Integer), Column(u'language_id', types.Integer), @@ -153,9 +154,9 @@ def init_schema_spelling_extension(url): ) try: - class_mapper(Spelling) + class_mapper(AlternativeBookNames) except UnmappedClassError: - mapper(Spelling, spelling_table) + mapper(AlternativeBookNames, alternative_book_names_table) metadata.create_all(checkfirst=True) return session @@ -508,7 +509,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): A wrapper class around a small SQLite database which contains the download resources, a biblelist from the different download resources, the books, chapter counts and verse counts for the web download Bibles, a language - reference, the testament reference and some basic spelling variants. This + reference, the testament reference and some alternative book names. This class contains a singleton "cursor" so that only one connection to the SQLite database is ever used. """ @@ -756,19 +757,20 @@ class BiblesResourcesDB(QtCore.QObject, Manager): return None @staticmethod - def get_spelling(name, language_id=None): + def get_alternative_book_name(name, language_id=None): """ Return a book_reference_id if the name matches. """ - log.debug(u'BiblesResourcesDB.get_spelling("%s", "%s")', name, - language_id) + log.debug(u'BiblesResourcesDB.get_alternative_book_name("%s", "%s")', + name, language_id) if language_id: id = BiblesResourcesDB.run_sql(u'SELECT book_reference_id ' - u'FROM spelling WHERE name = ? and language_id = ? ORDER BY id', - (name, language_id)) + u'FROM alternative_book_names WHERE name = ? and language_id ' + u'= ? ORDER BY id', (name, language_id)) else: id = BiblesResourcesDB.run_sql(u'SELECT book_reference_id ' - u'FROM spelling WHERE name = ? ORDER BY id', (name, )) + u'FROM alternative_book_names WHERE name = ? ORDER BY id', ( + name, )) if id: return int(id[0][0]) else: @@ -834,9 +836,9 @@ class BiblesResourcesDB(QtCore.QObject, Manager): }) return testament_list -class SpellingDB(QtCore.QObject, Manager): +class AlternativeBookNamesDB(QtCore.QObject, Manager): """ - This class represents a database-bound spelling. + This class represents a database-bound alternative book names system. """ def __init__(self, parent, **kwargs): @@ -853,18 +855,18 @@ class SpellingDB(QtCore.QObject, Manager): The name of the database. This is also used as the file name for SQLite databases. """ - log.info(u'SpellingDB loaded') + log.info(u'AlternativeBookNamesDB loaded') QtCore.QObject.__init__(self) self.bible_plugin = parent if u'path' not in kwargs: raise KeyError(u'Missing keyword argument "path".') self.stop_import_flag = False - self.name = u'spelling_extension.sqlite' + self.name = u'alternative_book_names.sqlite' if not isinstance(self.name, unicode): self.name = unicode(self.name, u'utf-8') self.file = self.name Manager.__init__(self, u'bibles/resources', - init_schema_spelling_extension, self.file) + init_schema_alternative_book_names, self.file) self.wizard = None QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_import) @@ -886,35 +888,36 @@ class SpellingDB(QtCore.QObject, Manager): ``language`` The language for which should be searched """ - log.debug(u'SpellingDB.get_book_reference_id("%s")', name) + log.debug(u'AlternativeBookNamesDB.get_book_reference_id("%s")', name) if language: - id = self.session.query(Spelling.book_reference_id)\ - .filter(Spelling.name.like(name))\ - .filter(Spelling.language_id.like(language)).first() + id = self.session.query(AlternativeBookNames.book_reference_id)\ + .filter(AlternativeBookNames.name.like(name))\ + .filter(AlternativeBookNames.language_id.like(language)).first() else: - id = self.get_object_filtered(Spelling.book_reference_id, - Spelling.name.like(name)) + id = self.get_object_filtered(AlternativeBookNames.book_reference_id, + AlternativeBookNames.name.like(name)) if not id: return None else: return id[0] - def create_spelling(self, name, book_reference_id, language_id): + def create_alternative_book_name(self, name, book_reference_id, + language_id): """ - Add a spelling to the database. + Add an alternative book name to the database. ``name`` - The name of the spelling. + The name of the alternative book name. ``book_reference_id`` The book_reference_id of the book. ``language_id`` - The language which the spelling of the book name is. + The language to which the alternative book name belong. """ - log.debug(u'SpellingDBcreate_spelling("%s", "%s", "%s"', - name, book_reference_id, language_id) - spelling = Spelling.populate(name=name, + log.debug(u'AlternativeBookNamesDB.create_alternative_book_name("%s", ' + '"%s", "%s"', name, book_reference_id, language_id) + alternative_book_name = AlternativeBookNames.populate(name=name, book_reference_id=book_reference_id, language_id=language_id) - self.save_object(spelling) - return spelling + self.save_object(alternative_book_name) + return alternative_book_name diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 39a2e3699..9fe21c09e 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -42,7 +42,7 @@ from openlp.core.lib.ui import critical_error_message_box from openlp.core.utils import AppLocation, get_web_page from openlp.plugins.bibles.lib import SearchResults from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB, \ - SpellingDB, Book, BibleMeta + Book, BibleMeta log = logging.getLogger(__name__) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 5f0890f0e..3657d1028 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -33,8 +33,8 @@ from openlp.core.lib import Receiver, SettingsManager, translate from openlp.core.lib.ui import critical_error_message_box from openlp.core.utils import AppLocation, delete_file from openlp.plugins.bibles.lib import parse_reference -from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta, SpellingDB, \ - BiblesResourcesDB +from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta, \ + AlternativeBookNamesDB, BiblesResourcesDB from csvbible import CSVBible from http import HTTPBible from opensong import OpenSongBible @@ -131,7 +131,7 @@ class BibleManager(object): self.suffix = u'.sqlite' self.import_wizard = None self.reload_bibles() - self.reload_spelling() + self.reload_alternative_book_names() self.media = None def reload_bibles(self): @@ -169,16 +169,15 @@ class BibleManager(object): self.db_cache[name] = web_bible log.debug(u'Bibles reloaded') - def reload_spelling(self): + def reload_alternative_book_names(self): """ - Reloads the Spelling from the Spelling table and spelling_extension + Reloads the alternative book names from the local alternative book names database on disk. """ - log.debug(u'Reload spelling') - self.spelling_cache = {} - self.spelling_cache[u'spelling'] = SpellingDB(self.parent, + log.debug(u'Reload AlternativeBookNames') + self.alternative_book_names_cache = AlternativeBookNamesDB(self.parent, path=self.path) - log.debug(u'Spelling reloaded') + log.debug(u'AlternativeBookNames reloaded') def set_process_dialog(self, wizard): """ @@ -335,12 +334,13 @@ class BibleManager(object): if BiblesResourcesDB.get_book(book): book_temp = BiblesResourcesDB.get_book(book) book_id = book_temp[u'id'] - elif BiblesResourcesDB.get_spelling(book, language_id): - book_id = BiblesResourcesDB.get_spelling(book, language_id) - elif self.spelling_cache[u'spelling'].get_book_reference_id(book, + elif BiblesResourcesDB.get_alternative_book_name(book, language_id): + book_id = BiblesResourcesDB.get_alternative_book_name(book, + language_id) + elif self.alternative_book_names_cache.get_book_reference_id(book, language_id): - book_id = self.spelling_cache[u'spelling'].\ - get_book_reference_id(book, language_id) + book_id = self.alternative_book_names_cache.get_book_reference_id( + book, language_id) else: book_ref = self.parent.mediaItem.importRequest(u'book', book) log.debug(book_ref) @@ -351,8 +351,8 @@ class BibleManager(object): else: return None if book_id: - self.spelling_cache[u'spelling'].create_spelling(book, book_id, - language_id) + self.alternative_book_names_cache.create_alternative_book_name( + book, book_id, language_id) if book_id: return book_id else: diff --git a/openlp/plugins/bibles/resources/bibles_resources.sqlite b/openlp/plugins/bibles/resources/bibles_resources.sqlite index 102fe25b7b69699a415a795bf7e13f84d392da16..47d136618a8b30aa35673472486e38a1cac239a3 100644 GIT binary patch delta 306 zcmZqpz})bGd4jZH7Xt%>9T4jRF*6V=Pt-AH?An;HjGa$|f%zWuapuL$UCdF;8k-e4 zM3~JD*qBop6B%+CN*GcZiWu@35`nBthB6>8o*{`L9|*I7ERc9EP^_4NQHzy1l5w(w zx7y}b?gkrnh9?XRPnZr*Y`l@%9K+A9n3~GiT37;9o&+>B6-X0rG%0GOCckHt(o`bW Z{K*rSm2T$r`YpMcrD8G5=H(fY{Q&wHNofE8 delta 224 zcmZqpz})bGd4jZH2Ll6x9T4jRF*6V=P1G@F?AVyFjGfPgf%zWuapuL$UCdF;E}IQ` z449=w*qC)0ix~RIdm9} zn>qN|6?JtPTP;f%5*dfhMPJ{-4e`0RXkvGWP%g From e2ae3025c99d8889e8bc3e0f73397e2c080fec41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Wed, 23 Mar 2011 22:07:04 +0100 Subject: [PATCH 10/97] fill up bibles_resources database with alternative book names in different languages (EN, DE, FR, IT, ES, PT, RU, SV, NO, NL, CS, SK, RO, HR, HU, BG, AR, TR, PL, DA, ZH) --- .../bibles/resources/bibles_resources.sqlite | Bin 63488 -> 101376 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/openlp/plugins/bibles/resources/bibles_resources.sqlite b/openlp/plugins/bibles/resources/bibles_resources.sqlite index 47d136618a8b30aa35673472486e38a1cac239a3..23c89b5df80e39da39e81eb94cc6a0e9b8dd1474 100644 GIT binary patch literal 101376 zcmeFa2Y6h`btPQyz3xUeGCH6ejlf1^BasA1kRXTT5Q!w1hhb(o(rCmq91i1TlJ1SwC~*YGx;YkU%hzZdVal$7|%01@_A#tcN$|(;s5Zj6@(xD zxQSjCyqrWHy`Qa%A}A945hJ>SF9m-S{JDNCPkEodO%FthIlrWNeB3LxUpFVrNpr!R zG1ts9_&#T@gMI?P&fxd6_`HO{dZpN4#2hwbX2=}HXC9wJX4vd=^xd;9Ao~;MA`0kP zEV9!~4tpid&CTA-*iz+An#=fi9%+^+|IUTBEKAmc3KdK#KJ~8!Z9HulI&KcQ3hzQi z599YCe2$y_sQh7b9KZJ>oZmy{7}6bd=~d=_#PHcXJ`XN_A47xpp&83dV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437a28067c353927ad2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Fri, 1 Apr 2011 19:54:12 +0200 Subject: [PATCH 11/97] mark and comment out some unused code in csv import form bug fix --- .../plugins/bibles/forms/bibleimportform.py | 42 ++++++++++++++----- openlp/plugins/bibles/lib/opensong.py | 2 +- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 9fee25654..7857a9151 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -114,9 +114,10 @@ class BibleImportForm(OpenLPWizard): QtCore.QObject.connect(self.osisBrowseButton, QtCore.SIGNAL(u'clicked()'), self.onOsisBrowseButtonClicked) - QtCore.QObject.connect(self.csvTestamentsButton, - QtCore.SIGNAL(u'clicked()'), - self.onCsvTestamentsBrowseButtonClicked) + #TODO: Delete unused code + #QtCore.QObject.connect(self.csvTestamentsButton, + # QtCore.SIGNAL(u'clicked()'), + # self.onCsvTestamentsBrowseButtonClicked) QtCore.QObject.connect(self.csvBooksButton, QtCore.SIGNAL(u'clicked()'), self.onCsvBooksBrowseButtonClicked) @@ -177,6 +178,8 @@ class BibleImportForm(OpenLPWizard): self.csvLayout = QtGui.QFormLayout(self.csvWidget) self.csvLayout.setMargin(0) self.csvLayout.setObjectName(u'CsvLayout') + #TODO: Delete unused code + ''' self.csvTestamentsLabel = QtGui.QLabel(self.csvWidget) self.csvTestamentsLabel.setObjectName(u'CsvTestamentsLabel') self.csvTestamentsLayout = QtGui.QHBoxLayout() @@ -184,11 +187,13 @@ class BibleImportForm(OpenLPWizard): self.csvTestamentsEdit = QtGui.QLineEdit(self.csvWidget) self.csvTestamentsEdit.setObjectName(u'CsvTestamentsEdit') self.csvTestamentsLayout.addWidget(self.csvTestamentsEdit) + self.csvTestamentsButton = QtGui.QToolButton(self.csvWidget) self.csvTestamentsButton.setIcon(self.openIcon) self.csvTestamentsButton.setObjectName(u'CsvTestamentsButton') self.csvTestamentsLayout.addWidget(self.csvTestamentsButton) self.csvLayout.addRow(self.csvTestamentsLabel, self.csvTestamentsLayout) + ''' self.csvBooksLabel = QtGui.QLabel(self.csvWidget) self.csvBooksLabel.setObjectName(u'CsvBooksLabel') self.csvBooksLayout = QtGui.QHBoxLayout() @@ -373,8 +378,9 @@ class BibleImportForm(OpenLPWizard): translate('BiblesPlugin.ImportWizardForm', 'Bible file:')) self.osisFileLabel.setText( translate('BiblesPlugin.ImportWizardForm', 'Bible file:')) - self.csvTestamentsLabel.setText( - translate('BiblesPlugin.ImportWizardForm', 'Testaments file:')) + #TODO: Delete unused code + #self.csvTestamentsLabel.setText( + # translate('BiblesPlugin.ImportWizardForm', 'Testaments file:')) self.csvBooksLabel.setText( translate('BiblesPlugin.ImportWizardForm', 'Books file:')) self.csvVersesLabel.setText( @@ -425,7 +431,8 @@ class BibleImportForm(OpenLPWizard): # Align all QFormLayouts towards each other. labelWidth = max(self.formatLabel.minimumSizeHint().width(), self.osisFileLabel.minimumSizeHint().width(), - self.csvTestamentsLabel.minimumSizeHint().width(), + #TODO: Delete unused code + #self.csvTestamentsLabel.minimumSizeHint().width(), self.csvBooksLabel.minimumSizeHint().width(), self.csvVersesLabel.minimumSizeHint().width(), self.openSongFileLabel.minimumSizeHint().width(), @@ -447,6 +454,8 @@ class BibleImportForm(OpenLPWizard): self.osisFileEdit.setFocus() return False elif self.field(u'source_format').toInt()[0] == BibleFormat.CSV: + #TODO: Delete unused code + ''' if not self.field(u'csv_testamentsfile').toString(): answer = critical_error_message_box(UiStrings.NFSs, translate('BiblesPlugin.ImportWizardForm', @@ -455,6 +464,7 @@ class BibleImportForm(OpenLPWizard): if answer == QtGui.QMessageBox.No: self.csvTestamentsEdit.setFocus() return False + ''' if not self.field(u'csv_booksfile').toString(): critical_error_message_box(UiStrings.NFSs, translate('BiblesPlugin.ImportWizardForm', @@ -531,7 +541,8 @@ class BibleImportForm(OpenLPWizard): """ self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.OSIS, self.osisFileEdit) - + #TODO: Delete unused code + ''' def onCsvTestamentsBrowseButtonClicked(self): """ Show the file open dialog for the testaments CSV file. @@ -539,7 +550,7 @@ class BibleImportForm(OpenLPWizard): self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.CSV, self.csvTestamentsEdit, u'%s (*.csv)' % translate('BiblesPlugin.ImportWizardForm', 'CSV File')) - + ''' def onCsvBooksBrowseButtonClicked(self): """ Show the file open dialog for the books CSV file. @@ -578,8 +589,9 @@ class BibleImportForm(OpenLPWizard): """ self.selectPage.registerField(u'source_format', self.formatComboBox) self.selectPage.registerField(u'osis_location', self.osisFileEdit) - self.selectPage.registerField( - u'csv_testamentsfile', self.csvTestamentsEdit) + #TODO: Delete unused code + #self.selectPage.registerField( + # u'csv_testamentsfile', self.csvTestamentsEdit) self.selectPage.registerField(u'csv_booksfile', self.csvBooksEdit) self.selectPage.registerField(u'csv_versefile', self.csvVersesEdit) self.selectPage.registerField(u'opensong_file', self.openSongFileEdit) @@ -608,7 +620,8 @@ class BibleImportForm(OpenLPWizard): self.cancelButton.setVisible(True) self.setField(u'source_format', QtCore.QVariant(0)) self.setField(u'osis_location', QtCore.QVariant('')) - self.setField(u'csv_testamentsfile', QtCore.QVariant('')) + #TODO: Delete unused code + #self.setField(u'csv_testamentsfile', QtCore.QVariant('')) self.setField(u'csv_booksfile', QtCore.QVariant('')) self.setField(u'csv_versefile', QtCore.QVariant('')) self.setField(u'opensong_file', QtCore.QVariant('')) @@ -689,11 +702,18 @@ class BibleImportForm(OpenLPWizard): ) elif bible_type == BibleFormat.CSV: # Import a CSV bible. + #TODO: Delete unused code + ''' importer = self.manager.import_bible(BibleFormat.CSV, name=license_version, testamentsfile=unicode( self.field(u'csv_testamentsfile').toString()), booksfile=unicode(self.field(u'csv_booksfile').toString()), versefile=unicode(self.field(u'csv_versefile').toString()) + ''' + importer = self.manager.import_bible(BibleFormat.CSV, + name=license_version, + booksfile=unicode(self.field(u'csv_booksfile').toString()), + versefile=unicode(self.field(u'csv_versefile').toString()) ) elif bible_type == BibleFormat.OpenSong: # Import an OpenSong bible. diff --git a/openlp/plugins/bibles/lib/opensong.py b/openlp/plugins/bibles/lib/opensong.py index f1a64c2e7..a1f65ad04 100644 --- a/openlp/plugins/bibles/lib/opensong.py +++ b/openlp/plugins/bibles/lib/opensong.py @@ -66,7 +66,7 @@ class OpenSongBible(BibleDB): if not language: log.exception(u'Importing books from %s " '\ 'failed' % self.filename) - return False + return False language = BiblesResourcesDB.get_language(language) language_id = language[u'id'] self.create_meta(u'language_id', language_id) From c04a76e12dde1de9781dad696c30368e4ccae198 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Fri, 1 Apr 2011 22:26:25 +0200 Subject: [PATCH 12/97] split BibleImportRequest in BookNameForm and LanugageForm --- openlp/plugins/bibles/forms/__init__.py | 3 +- ...portrequestdialog.py => booknamedialog.py} | 32 +++---- ...leimportrequestform.py => booknameform.py} | 31 +++--- openlp/plugins/bibles/forms/languagedialog.py | 94 +++++++++++++++++++ openlp/plugins/bibles/forms/languageform.py | 71 ++++++++++++++ openlp/plugins/bibles/lib/csvbible.py | 2 +- openlp/plugins/bibles/lib/db.py | 2 +- openlp/plugins/bibles/lib/http.py | 2 +- openlp/plugins/bibles/lib/manager.py | 12 ++- openlp/plugins/bibles/lib/mediaitem.py | 17 ++-- openlp/plugins/bibles/lib/openlp1.py | 2 +- openlp/plugins/bibles/lib/opensong.py | 2 +- openlp/plugins/bibles/lib/osis.py | 4 +- 13 files changed, 221 insertions(+), 53 deletions(-) rename openlp/plugins/bibles/forms/{bibleimportrequestdialog.py => booknamedialog.py} (82%) rename openlp/plugins/bibles/forms/{bibleimportrequestform.py => booknameform.py} (72%) create mode 100644 openlp/plugins/bibles/forms/languagedialog.py create mode 100644 openlp/plugins/bibles/forms/languageform.py diff --git a/openlp/plugins/bibles/forms/__init__.py b/openlp/plugins/bibles/forms/__init__.py index aed6f71f3..367ebcefc 100644 --- a/openlp/plugins/bibles/forms/__init__.py +++ b/openlp/plugins/bibles/forms/__init__.py @@ -52,6 +52,7 @@ from the .ui files later if necessary. """ from bibleimportform import BibleImportForm -from bibleimportrequestform import BibleImportRequest +from booknameform import BookNameForm +from languageform import LanguageForm __all__ = ['BibleImportForm'] diff --git a/openlp/plugins/bibles/forms/bibleimportrequestdialog.py b/openlp/plugins/bibles/forms/booknamedialog.py similarity index 82% rename from openlp/plugins/bibles/forms/bibleimportrequestdialog.py rename to openlp/plugins/bibles/forms/booknamedialog.py index 7fcc36932..d17bd8522 100644 --- a/openlp/plugins/bibles/forms/bibleimportrequestdialog.py +++ b/openlp/plugins/bibles/forms/booknamedialog.py @@ -29,18 +29,18 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate from openlp.core.lib.ui import create_accept_reject_button_box -class Ui_BibleImportRequest(object): - def setupUi(self, bibleImportRequest): - bibleImportRequest.setObjectName("BibleImportRequest") - bibleImportRequest.resize(400, 175) +class Ui_BookNameDialog(object): + def setupUi(self, bookNameDialog): + bookNameDialog.setObjectName("BookNameDialog") + bookNameDialog.resize(400, 175) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.MinimumExpanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(bibleImportRequest.sizePolicy() + sizePolicy.setHeightForWidth(bookNameDialog.sizePolicy() .hasHeightForWidth()) - bibleImportRequest.setSizePolicy(sizePolicy) - self.widget = QtGui.QWidget(bibleImportRequest) + bookNameDialog.setSizePolicy(sizePolicy) + self.widget = QtGui.QWidget(bookNameDialog) self.widget.setGeometry(QtCore.QRect(10, 15, 381, 151)) self.widget.setObjectName("widget") self.verticalLayout = QtGui.QVBoxLayout(self.widget) @@ -79,17 +79,17 @@ class Ui_BibleImportRequest(object): QtGui.QSizePolicy.Expanding) self.verticalLayout.addItem(spacerItem) self.formLayout.addWidget( - create_accept_reject_button_box(bibleImportRequest)) - self.retranslateUi(bibleImportRequest) - QtCore.QMetaObject.connectSlotsByName(bibleImportRequest) + create_accept_reject_button_box(bookNameDialog)) + self.retranslateUi(bookNameDialog) + QtCore.QMetaObject.connectSlotsByName(bookNameDialog) - def retranslateUi(self, bibleImportRequest): - bibleImportRequest.setWindowTitle( - translate("BiblesPlugin.bibleImportRequest", "Dialog")) + def retranslateUi(self, bookNameDialog): + bookNameDialog.setWindowTitle( + translate("BiblesPlugin.BookNameDialog", "Choose Book")) self.headlineLabel.setText( - translate("BiblesPlugin.bibleImportRequest", "Choose Book:")) - self.infoLabel.setText(translate("BiblesPlugin.bibleImportRequest", + translate("BiblesPlugin.BookNameDialog", "Choose Book:")) + self.infoLabel.setText(translate("BiblesPlugin.BookNameDialog", "The following books cannot be clearly attributed. \n" "Please choose the book it is.")) - self.requestLabel.setText(translate("BiblesPlugin.bibleImportRequest", + self.requestLabel.setText(translate("BiblesPlugin.BookNameDialog", "Book:")) diff --git a/openlp/plugins/bibles/forms/bibleimportrequestform.py b/openlp/plugins/bibles/forms/booknameform.py similarity index 72% rename from openlp/plugins/bibles/forms/bibleimportrequestform.py rename to openlp/plugins/bibles/forms/booknameform.py index caac8e83b..f3923cb63 100644 --- a/openlp/plugins/bibles/forms/bibleimportrequestform.py +++ b/openlp/plugins/bibles/forms/booknameform.py @@ -25,7 +25,7 @@ ############################################################################### """ -Module implementing BibleImportRequest. +Module implementing BookNameForm. """ import logging @@ -33,17 +33,17 @@ from PyQt4.QtGui import QDialog from openlp.core.lib import translate from openlp.core.lib.ui import critical_error_message_box -from openlp.plugins.bibles.forms.bibleimportrequestdialog import \ - Ui_BibleImportRequest +from openlp.plugins.bibles.forms.booknamedialog import \ + Ui_BookNameDialog from openlp.plugins.bibles.lib.db import BiblesResourcesDB log = logging.getLogger(__name__) -class BibleImportRequest(QDialog, Ui_BibleImportRequest): +class BookNameForm(QDialog, Ui_BookNameDialog): """ Class documentation goes here. """ - log.info(u'BibleImportRequest loaded') + log.info(u'BookNameForm loaded') def __init__(self, parent = None): """ @@ -52,21 +52,12 @@ class BibleImportRequest(QDialog, Ui_BibleImportRequest): QDialog.__init__(self, parent) self.setupUi(self) - def exec_(self, case, name=None): + def exec_(self, name): items = [] self.requestComboBox.addItem(u'') - if case == u'language': - self.headlineLabel.setText(translate( - "BiblesPlugin.BibleImportRequest", "Choose Language:")) - self.infoLabel.setText(translate("BiblesPlugin.BibleImportRequest", - "Please choose the language the bible is.")) - self.requestLabel.setText( - translate("BiblesPlugin.BibleImportRequest", "Language:")) - items = BiblesResourcesDB.get_languages() - elif case == u'book': - self.requestLabel.setText( - translate("BiblesPlugin.BibleImportRequest", name)) - items = BiblesResourcesDB.get_books() + self.requestLabel.setText( + translate("BiblesPlugin.BookNameForm", name)) + items = BiblesResourcesDB.get_books() for item in items: self.requestComboBox.addItem(item[u'name']) return QDialog.exec_(self) @@ -74,8 +65,8 @@ class BibleImportRequest(QDialog, Ui_BibleImportRequest): def accept(self): if self.requestComboBox.currentText() == u"": critical_error_message_box( - message=translate('BiblesPlugin.BibleImportRequest', - 'You need to choose an item.')) + message=translate('BiblesPlugin.BookNameForm', + 'You need to choose a book.')) self.requestComboBox.setFocus() return False else: diff --git a/openlp/plugins/bibles/forms/languagedialog.py b/openlp/plugins/bibles/forms/languagedialog.py new file mode 100644 index 000000000..08155a5b2 --- /dev/null +++ b/openlp/plugins/bibles/forms/languagedialog.py @@ -0,0 +1,94 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2011 Raoul Snyman # +# Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Meinert Jordan, Armin Köhler, Andreas Preikschat, # +# Christian Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon # +# Tibble, Carsten Tinggaard, Frode Woldsund # +# --------------------------------------------------------------------------- # +# 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 PyQt4 import QtCore, QtGui + +from openlp.core.lib import translate +from openlp.core.lib.ui import create_accept_reject_button_box + +class Ui_LanguageDialog(object): + def setupUi(self, languageDialog): + languageDialog.setObjectName("LanugageDialog") + languageDialog.resize(400, 175) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, + QtGui.QSizePolicy.MinimumExpanding) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(languageDialog.sizePolicy() + .hasHeightForWidth()) + languageDialog.setSizePolicy(sizePolicy) + self.widget = QtGui.QWidget(languageDialog) + self.widget.setGeometry(QtCore.QRect(10, 15, 381, 151)) + self.widget.setObjectName("widget") + self.verticalLayout = QtGui.QVBoxLayout(self.widget) + self.verticalLayout.setObjectName("verticalLayout") + self.headlineLabel = QtGui.QLabel(self.widget) + font = QtGui.QFont() + font.setFamily("Arial") + font.setPointSize(11) + font.setWeight(75) + font.setBold(True) + self.headlineLabel.setFont(font) + self.headlineLabel.setObjectName("HeadlineLabel") + self.verticalLayout.addWidget(self.headlineLabel) + self.infoLabel = QtGui.QLabel(self.widget) + self.infoLabel.setObjectName("InfoLabel") + self.verticalLayout.addWidget(self.infoLabel) + self.formLayout = QtGui.QFormLayout() + self.formLayout.setObjectName("formLayout") + self.requestLabel = QtGui.QLabel(self.widget) + self.requestLabel.setObjectName("RequestLabel") + self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, + self.requestLabel) + self.requestComboBox = QtGui.QComboBox(self.widget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, + QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.requestComboBox.sizePolicy() + .hasHeightForWidth()) + self.requestComboBox.setSizePolicy(sizePolicy) + self.requestComboBox.setObjectName("RequestComboBox") + self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, + self.requestComboBox) + self.verticalLayout.addLayout(self.formLayout) + spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, + QtGui.QSizePolicy.Expanding) + self.verticalLayout.addItem(spacerItem) + self.formLayout.addWidget( + create_accept_reject_button_box(languageDialog)) + self.retranslateUi(languageDialog) + QtCore.QMetaObject.connectSlotsByName(languageDialog) + + def retranslateUi(self, languageDialog): + languageDialog.setWindowTitle( + translate("BiblesPlugin.LanguageDialog", "Choose Language")) + self.headlineLabel.setText( + translate("BiblesPlugin.LanguageDialog", "Choose Language:")) + self.infoLabel.setText(translate("BiblesPlugin.LanguageDialog", + "Please choose the language the bible is.")) + self.requestLabel.setText(translate("BiblesPlugin.languageDialog", + "Language:")) diff --git a/openlp/plugins/bibles/forms/languageform.py b/openlp/plugins/bibles/forms/languageform.py new file mode 100644 index 000000000..220e28271 --- /dev/null +++ b/openlp/plugins/bibles/forms/languageform.py @@ -0,0 +1,71 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2011 Raoul Snyman # +# Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Meinert Jordan, Armin Köhler, Andreas Preikschat, # +# Christian Richter, Philip Ridout, Maikel Stuivenberg, Martin Thompson, Jon # +# Tibble, Carsten Tinggaard, Frode Woldsund # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### + +""" +Module implementing BookNameForm. +""" +import logging + +from PyQt4.QtGui import QDialog + +from openlp.core.lib import translate +from openlp.core.lib.ui import critical_error_message_box +from openlp.plugins.bibles.forms.languagedialog import \ + Ui_LanguageDialog +from openlp.plugins.bibles.lib.db import BiblesResourcesDB + +log = logging.getLogger(__name__) + +class LanguageForm(QDialog, Ui_LanguageDialog): + """ + Class documentation goes here. + """ + log.info(u'LanguageForm loaded') + + def __init__(self, parent = None): + """ + Constructor + """ + QDialog.__init__(self, parent) + self.setupUi(self) + + def exec_(self): + items = [] + self.requestComboBox.addItem(u'') + items = BiblesResourcesDB.get_languages() + for item in items: + self.requestComboBox.addItem(item[u'name']) + return QDialog.exec_(self) + + def accept(self): + if self.requestComboBox.currentText() == u"": + critical_error_message_box( + message=translate('BiblesPlugin.LanguageForm', + 'You need to choose a language.')) + self.requestComboBox.setFocus() + return False + else: + return QDialog.accept(self) diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index 8ce1c87e5..1c53383ac 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -139,7 +139,7 @@ class CSVBible(BibleDB): self.wizard.progressBar.setMinimum(0) self.wizard.progressBar.setMaximum(66) success = True - language = self.parent.mediaItem.importRequest(u'language') + language = self.parent.mediaItem.languageDialog() if not language: log.exception(u'Importing books from %s " '\ 'failed' % self.booksfile) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 4d4f401d4..e1abecd89 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -198,7 +198,7 @@ class BibleDB(QtCore.QObject, Manager): self.file = self.clean_filename(self.name) if u'file' in kwargs: self.file = kwargs[u'file'] - Manager.__init__(self, u'bibles', init_schema, self.file) + Manager.__init__(self, u'bibles/bibles', init_schema, self.file) if u'file' in kwargs: self.get_name() self.wizard = None diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 5923fc565..dc751052a 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -414,7 +414,7 @@ class HTTPBible(BibleDB): if bible[u'language_id']: language_id = bible[u'language_id'] else: - language = self.parent.mediaItem.importRequest(u'language') + language = self.parent.mediaItem.languageDialog() if not language: log.exception(u'Importing books from %s - download name: "%s" '\ 'failed' % (self.download_source, self.download_name)) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 09f71de91..0e6cc1e3a 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -121,7 +121,7 @@ class BibleManager(object): """ log.debug(u'Bible Initialising') self.parent = parent - self.settingsSection = u'bibles' + self.settingsSection = u'bibles/bibles' self.web = u'Web' self.db_cache = None self.path = AppLocation.get_section_data_path(self.settingsSection) @@ -131,7 +131,8 @@ class BibleManager(object): self.suffix = u'.sqlite' self.import_wizard = None self.reload_bibles() - self.reload_alternative_book_names() + #TODO: Delete unused code + #self.reload_alternative_book_names() self.media = None def reload_bibles(self): @@ -169,6 +170,8 @@ class BibleManager(object): self.db_cache[name] = web_bible log.debug(u'Bibles reloaded') + #TODO: Delete unused code + ''' def reload_alternative_book_names(self): """ Reloads the alternative book names from the local alternative book names @@ -178,6 +181,7 @@ class BibleManager(object): self.alternative_book_names_cache = AlternativeBookNamesDB(self.parent, path=self.path) log.debug(u'AlternativeBookNames reloaded') + ''' def set_process_dialog(self, wizard): """ @@ -331,6 +335,8 @@ class BibleManager(object): def get_book_ref_id_by_name(self, book, language_id=None): log.debug(u'BibleManager.get_book_ref_id_by_name:("%s", "%s")', book, language_id) + self.alternative_book_names_cache = AlternativeBookNamesDB(self.parent, + path=self.path) if BiblesResourcesDB.get_book(book): book_temp = BiblesResourcesDB.get_book(book) book_id = book_temp[u'id'] @@ -342,7 +348,7 @@ class BibleManager(object): book_id = self.alternative_book_names_cache.get_book_reference_id( book, language_id) else: - book_ref = self.parent.mediaItem.importRequest(u'book', book) + book_ref = self.parent.mediaItem.bookNameDialog(book) log.debug(book_ref) book_temp = BiblesResourcesDB.get_book(book_ref) log.debug(book_temp) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 1cb53d99c..e55d4fe14 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -33,10 +33,10 @@ from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \ from openlp.core.lib.searchedit import SearchEdit from openlp.core.lib.ui import UiStrings, add_widget_completer, \ media_item_combo_box, critical_error_message_box -from openlp.plugins.bibles.forms import BibleImportForm +from openlp.plugins.bibles.forms import BibleImportForm, BookNameForm, \ + LanguageForm from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, \ VerseReferenceList, get_reference_match -from openlp.plugins.bibles.forms import BibleImportRequest log = logging.getLogger(__name__) @@ -287,10 +287,15 @@ class BibleMediaItem(MediaManagerItem): if self.import_wizard.exec_(): self.reloadBibles() - def importRequest(self, case, name=None): - self.import_request = BibleImportRequest(self) - if self.import_request.exec_(case, name): - return unicode(self.import_request.requestComboBox.currentText()) + def bookNameDialog(self, name): + self.book_name = BookNameForm(self) + if self.book_name.exec_(name): + return unicode(self.book_name.requestComboBox.currentText()) + + def languageDialog(self): + self.language = LanguageForm(self) + if self.language.exec_(): + return unicode(self.language.requestComboBox.currentText()) def loadBibles(self): log.debug(u'Loading Bibles') diff --git a/openlp/plugins/bibles/lib/openlp1.py b/openlp/plugins/bibles/lib/openlp1.py index 46c83c3c3..7a6ebbece 100644 --- a/openlp/plugins/bibles/lib/openlp1.py +++ b/openlp/plugins/bibles/lib/openlp1.py @@ -58,7 +58,7 @@ class OpenLP1Bible(BibleDB): except: return False #Create the bible language - language = self.parent.mediaItem.importRequest(u'language') + language = self.parent.mediaItem.languageDialog() if not language: log.exception(u'Importing books from %s " '\ 'failed' % self.filename) diff --git a/openlp/plugins/bibles/lib/opensong.py b/openlp/plugins/bibles/lib/opensong.py index 074a8833d..55f83c33a 100644 --- a/openlp/plugins/bibles/lib/opensong.py +++ b/openlp/plugins/bibles/lib/opensong.py @@ -62,7 +62,7 @@ class OpenSongBible(BibleDB): file = open(self.filename, u'r') opensong = objectify.parse(file) bible = opensong.getroot() - language = self.parent.mediaItem.importRequest(u'language') + language = self.parent.mediaItem.languageDialog() if not language: log.exception(u'Importing books from %s " '\ 'failed' % self.filename) diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index f525512ba..83a5a2974 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -107,7 +107,7 @@ class OSISBible(BibleDB): if detect_file: detect_file.close() # Set meta language_id - language = self.parent.mediaItem.importRequest(u'language') + language = self.parent.mediaItem.languageDialog() if not language: log.exception(u'Importing books from %s " '\ 'failed' % self.filename) @@ -128,7 +128,7 @@ class OSISBible(BibleDB): verse = int(match.group(3)) verse_text = match.group(4) if not db_book or db_book.name != self.books[book][0]: - log.debug(u'New book: "%s"', self.books[book][0]) + log.debug(u'New book: "%s"' % self.books[book][0]) #TODO: Delete unused code #if book == u'Matt' or book == u'Jdt': # testament += 1 From 9de33cf1949636c85d27b4c2171db58b82488730 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sat, 2 Apr 2011 21:17:48 +0200 Subject: [PATCH 13/97] moved Dialog from mediaitem.py to bibleimportform.py some fixes --- openlp/plugins/bibles/forms/__init__.py | 3 +- .../plugins/bibles/forms/bibleimportform.py | 11 +++++++ openlp/plugins/bibles/forms/booknamedialog.py | 32 +++++++++---------- openlp/plugins/bibles/forms/booknameform.py | 7 ++-- openlp/plugins/bibles/forms/languagedialog.py | 30 ++++++++--------- openlp/plugins/bibles/forms/languageform.py | 4 +-- openlp/plugins/bibles/lib/csvbible.py | 2 +- openlp/plugins/bibles/lib/db.py | 2 +- openlp/plugins/bibles/lib/http.py | 2 +- openlp/plugins/bibles/lib/manager.py | 2 +- openlp/plugins/bibles/lib/mediaitem.py | 13 +------- openlp/plugins/bibles/lib/openlp1.py | 2 +- openlp/plugins/bibles/lib/opensong.py | 2 +- openlp/plugins/bibles/lib/osis.py | 2 +- 14 files changed, 57 insertions(+), 57 deletions(-) diff --git a/openlp/plugins/bibles/forms/__init__.py b/openlp/plugins/bibles/forms/__init__.py index 367ebcefc..561944563 100644 --- a/openlp/plugins/bibles/forms/__init__.py +++ b/openlp/plugins/bibles/forms/__init__.py @@ -50,9 +50,8 @@ This allows OpenLP to use ``self.object`` for all the GUI elements while keeping them separate from the functionality, so that it is easier to recreate the GUI from the .ui files later if necessary. """ - -from bibleimportform import BibleImportForm from booknameform import BookNameForm from languageform import LanguageForm +from bibleimportform import BibleImportForm __all__ = ['BibleImportForm'] diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index fd6690888..ea7156193 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -40,6 +40,7 @@ from openlp.core.ui.wizard import OpenLPWizard, WizardStrings from openlp.core.utils import AppLocation, string_is_unicode from openlp.plugins.bibles.lib.manager import BibleFormat from openlp.plugins.bibles.lib.db import BiblesResourcesDB +from openlp.plugins.bibles.forms import BookNameForm, LanguageForm log = logging.getLogger(__name__) @@ -758,3 +759,13 @@ class BibleImportForm(OpenLPWizard): 'BiblesPlugin.ImportWizardForm', 'Your Bible import failed.')) del self.manager.db_cache[importer.name] delete_database(self.plugin.settingsSection, importer.file) + + def bookNameDialog(self, name): + self.book_name = BookNameForm(self) + if self.book_name.exec_(name): + return unicode(self.book_name.requestComboBox.currentText()) + + def languageDialog(self): + self.language = LanguageForm(self) + if self.language.exec_(): + return unicode(self.language.requestComboBox.currentText()) diff --git a/openlp/plugins/bibles/forms/booknamedialog.py b/openlp/plugins/bibles/forms/booknamedialog.py index d17bd8522..bb48548c0 100644 --- a/openlp/plugins/bibles/forms/booknamedialog.py +++ b/openlp/plugins/bibles/forms/booknamedialog.py @@ -31,7 +31,7 @@ from openlp.core.lib.ui import create_accept_reject_button_box class Ui_BookNameDialog(object): def setupUi(self, bookNameDialog): - bookNameDialog.setObjectName("BookNameDialog") + bookNameDialog.setObjectName(u'BookNameDialog') bookNameDialog.resize(400, 175) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.MinimumExpanding) @@ -42,25 +42,25 @@ class Ui_BookNameDialog(object): bookNameDialog.setSizePolicy(sizePolicy) self.widget = QtGui.QWidget(bookNameDialog) self.widget.setGeometry(QtCore.QRect(10, 15, 381, 151)) - self.widget.setObjectName("widget") + self.widget.setObjectName(u'widget') self.verticalLayout = QtGui.QVBoxLayout(self.widget) - self.verticalLayout.setObjectName("verticalLayout") + self.verticalLayout.setObjectName(u'verticalLayout') self.headlineLabel = QtGui.QLabel(self.widget) font = QtGui.QFont() - font.setFamily("Arial") + font.setFamily(u'Arial') font.setPointSize(11) font.setWeight(75) font.setBold(True) self.headlineLabel.setFont(font) - self.headlineLabel.setObjectName("HeadlineLabel") + self.headlineLabel.setObjectName(u'HeadlineLabel') self.verticalLayout.addWidget(self.headlineLabel) self.infoLabel = QtGui.QLabel(self.widget) - self.infoLabel.setObjectName("InfoLabel") + self.infoLabel.setObjectName(u'InfoLabel') self.verticalLayout.addWidget(self.infoLabel) self.formLayout = QtGui.QFormLayout() - self.formLayout.setObjectName("formLayout") + self.formLayout.setObjectName(u'formLayout') self.requestLabel = QtGui.QLabel(self.widget) - self.requestLabel.setObjectName("RequestLabel") + self.requestLabel.setObjectName(u'RequestLabel') self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.requestLabel) self.requestComboBox = QtGui.QComboBox(self.widget) @@ -71,7 +71,7 @@ class Ui_BookNameDialog(object): sizePolicy.setHeightForWidth(self.requestComboBox.sizePolicy() .hasHeightForWidth()) self.requestComboBox.setSizePolicy(sizePolicy) - self.requestComboBox.setObjectName("RequestComboBox") + self.requestComboBox.setObjectName(u'RequestComboBox') self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.requestComboBox) self.verticalLayout.addLayout(self.formLayout) @@ -85,11 +85,11 @@ class Ui_BookNameDialog(object): def retranslateUi(self, bookNameDialog): bookNameDialog.setWindowTitle( - translate("BiblesPlugin.BookNameDialog", "Choose Book")) + translate('BiblesPlugin.BookNameDialog', 'Choose Book')) self.headlineLabel.setText( - translate("BiblesPlugin.BookNameDialog", "Choose Book:")) - self.infoLabel.setText(translate("BiblesPlugin.BookNameDialog", - "The following books cannot be clearly attributed. \n" - "Please choose the book it is.")) - self.requestLabel.setText(translate("BiblesPlugin.BookNameDialog", - "Book:")) + translate('BiblesPlugin.BookNameDialog', 'Choose Book:')) + self.infoLabel.setText(translate('BiblesPlugin.BookNameDialog', + 'The following books cannot be clearly attributed. \n' + 'Please choose the book it is.')) + self.requestLabel.setText(translate('BiblesPlugin.BookNameDialog', + 'Book:')) diff --git a/openlp/plugins/bibles/forms/booknameform.py b/openlp/plugins/bibles/forms/booknameform.py index f3923cb63..58603226c 100644 --- a/openlp/plugins/bibles/forms/booknameform.py +++ b/openlp/plugins/bibles/forms/booknameform.py @@ -41,7 +41,8 @@ log = logging.getLogger(__name__) class BookNameForm(QDialog, Ui_BookNameDialog): """ - Class documentation goes here. + Class to manage a dialog which help the user to refer a book name a + to a english book name """ log.info(u'BookNameForm loaded') @@ -56,14 +57,14 @@ class BookNameForm(QDialog, Ui_BookNameDialog): items = [] self.requestComboBox.addItem(u'') self.requestLabel.setText( - translate("BiblesPlugin.BookNameForm", name)) + translate('BiblesPlugin.BookNameForm', name)) items = BiblesResourcesDB.get_books() for item in items: self.requestComboBox.addItem(item[u'name']) return QDialog.exec_(self) def accept(self): - if self.requestComboBox.currentText() == u"": + if self.requestComboBox.currentText() == u'': critical_error_message_box( message=translate('BiblesPlugin.BookNameForm', 'You need to choose a book.')) diff --git a/openlp/plugins/bibles/forms/languagedialog.py b/openlp/plugins/bibles/forms/languagedialog.py index 08155a5b2..c4ede8e77 100644 --- a/openlp/plugins/bibles/forms/languagedialog.py +++ b/openlp/plugins/bibles/forms/languagedialog.py @@ -31,7 +31,7 @@ from openlp.core.lib.ui import create_accept_reject_button_box class Ui_LanguageDialog(object): def setupUi(self, languageDialog): - languageDialog.setObjectName("LanugageDialog") + languageDialog.setObjectName(u'LanugageDialog') languageDialog.resize(400, 175) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.MinimumExpanding) @@ -42,25 +42,25 @@ class Ui_LanguageDialog(object): languageDialog.setSizePolicy(sizePolicy) self.widget = QtGui.QWidget(languageDialog) self.widget.setGeometry(QtCore.QRect(10, 15, 381, 151)) - self.widget.setObjectName("widget") + self.widget.setObjectName(u'widget') self.verticalLayout = QtGui.QVBoxLayout(self.widget) - self.verticalLayout.setObjectName("verticalLayout") + self.verticalLayout.setObjectName(u'verticalLayout') self.headlineLabel = QtGui.QLabel(self.widget) font = QtGui.QFont() - font.setFamily("Arial") + font.setFamily(u'Arial') font.setPointSize(11) font.setWeight(75) font.setBold(True) self.headlineLabel.setFont(font) - self.headlineLabel.setObjectName("HeadlineLabel") + self.headlineLabel.setObjectName(u'HeadlineLabel') self.verticalLayout.addWidget(self.headlineLabel) self.infoLabel = QtGui.QLabel(self.widget) - self.infoLabel.setObjectName("InfoLabel") + self.infoLabel.setObjectName(u'InfoLabel') self.verticalLayout.addWidget(self.infoLabel) self.formLayout = QtGui.QFormLayout() - self.formLayout.setObjectName("formLayout") + self.formLayout.setObjectName(u'formLayout') self.requestLabel = QtGui.QLabel(self.widget) - self.requestLabel.setObjectName("RequestLabel") + self.requestLabel.setObjectName(u'RequestLabel') self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.requestLabel) self.requestComboBox = QtGui.QComboBox(self.widget) @@ -71,7 +71,7 @@ class Ui_LanguageDialog(object): sizePolicy.setHeightForWidth(self.requestComboBox.sizePolicy() .hasHeightForWidth()) self.requestComboBox.setSizePolicy(sizePolicy) - self.requestComboBox.setObjectName("RequestComboBox") + self.requestComboBox.setObjectName(u'RequestComboBox') self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.requestComboBox) self.verticalLayout.addLayout(self.formLayout) @@ -85,10 +85,10 @@ class Ui_LanguageDialog(object): def retranslateUi(self, languageDialog): languageDialog.setWindowTitle( - translate("BiblesPlugin.LanguageDialog", "Choose Language")) + translate('BiblesPlugin.LanguageDialog', 'Choose Language')) self.headlineLabel.setText( - translate("BiblesPlugin.LanguageDialog", "Choose Language:")) - self.infoLabel.setText(translate("BiblesPlugin.LanguageDialog", - "Please choose the language the bible is.")) - self.requestLabel.setText(translate("BiblesPlugin.languageDialog", - "Language:")) + translate('BiblesPlugin.LanguageDialog', 'Choose Language:')) + self.infoLabel.setText(translate('BiblesPlugin.LanguageDialog', + 'Please choose the language the bible is.')) + self.requestLabel.setText(translate('BiblesPlugin.languageDialog', + 'Language:')) diff --git a/openlp/plugins/bibles/forms/languageform.py b/openlp/plugins/bibles/forms/languageform.py index 220e28271..f074a9dc5 100644 --- a/openlp/plugins/bibles/forms/languageform.py +++ b/openlp/plugins/bibles/forms/languageform.py @@ -41,7 +41,7 @@ log = logging.getLogger(__name__) class LanguageForm(QDialog, Ui_LanguageDialog): """ - Class documentation goes here. + Class to manage a dialog which ask the user for a language. """ log.info(u'LanguageForm loaded') @@ -61,7 +61,7 @@ class LanguageForm(QDialog, Ui_LanguageDialog): return QDialog.exec_(self) def accept(self): - if self.requestComboBox.currentText() == u"": + if self.requestComboBox.currentText() == u'': critical_error_message_box( message=translate('BiblesPlugin.LanguageForm', 'You need to choose a language.')) diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index 1c53383ac..2e1accb45 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -139,7 +139,7 @@ class CSVBible(BibleDB): self.wizard.progressBar.setMinimum(0) self.wizard.progressBar.setMaximum(66) success = True - language = self.parent.mediaItem.languageDialog() + language = self.parent.manager.import_wizard.languageDialog() if not language: log.exception(u'Importing books from %s " '\ 'failed' % self.booksfile) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index e1abecd89..6cfb48c21 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -785,7 +785,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): ``name`` The name or abbreviation of the language. """ - log.debug(u'BiblesResourcesDB.get_language("%s", "%s")', name) + log.debug(u'BiblesResourcesDB.get_language("%s")', name) if not isinstance(name, unicode): name = unicode(name) name = name.title() diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index dc751052a..d0a911b32 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -414,7 +414,7 @@ class HTTPBible(BibleDB): if bible[u'language_id']: language_id = bible[u'language_id'] else: - language = self.parent.mediaItem.languageDialog() + language = self.parent.manager.import_wizard.languageDialog() if not language: log.exception(u'Importing books from %s - download name: "%s" '\ 'failed' % (self.download_source, self.download_name)) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 0e6cc1e3a..7cca6f4a0 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -348,7 +348,7 @@ class BibleManager(object): book_id = self.alternative_book_names_cache.get_book_reference_id( book, language_id) else: - book_ref = self.parent.mediaItem.bookNameDialog(book) + book_ref = self.import_wizard.bookNameDialog(book) log.debug(book_ref) book_temp = BiblesResourcesDB.get_book(book_ref) log.debug(book_temp) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index e55d4fe14..e0d2a031c 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -33,8 +33,7 @@ from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \ from openlp.core.lib.searchedit import SearchEdit from openlp.core.lib.ui import UiStrings, add_widget_completer, \ media_item_combo_box, critical_error_message_box -from openlp.plugins.bibles.forms import BibleImportForm, BookNameForm, \ - LanguageForm +from openlp.plugins.bibles.forms import BibleImportForm from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, \ VerseReferenceList, get_reference_match @@ -287,16 +286,6 @@ class BibleMediaItem(MediaManagerItem): if self.import_wizard.exec_(): self.reloadBibles() - def bookNameDialog(self, name): - self.book_name = BookNameForm(self) - if self.book_name.exec_(name): - return unicode(self.book_name.requestComboBox.currentText()) - - def languageDialog(self): - self.language = LanguageForm(self) - if self.language.exec_(): - return unicode(self.language.requestComboBox.currentText()) - def loadBibles(self): log.debug(u'Loading Bibles') self.quickVersionComboBox.clear() diff --git a/openlp/plugins/bibles/lib/openlp1.py b/openlp/plugins/bibles/lib/openlp1.py index 7a6ebbece..bc3624479 100644 --- a/openlp/plugins/bibles/lib/openlp1.py +++ b/openlp/plugins/bibles/lib/openlp1.py @@ -58,7 +58,7 @@ class OpenLP1Bible(BibleDB): except: return False #Create the bible language - language = self.parent.mediaItem.languageDialog() + language = self.parent.manager.import_wizard.languageDialog() if not language: log.exception(u'Importing books from %s " '\ 'failed' % self.filename) diff --git a/openlp/plugins/bibles/lib/opensong.py b/openlp/plugins/bibles/lib/opensong.py index 55f83c33a..6e4c4826f 100644 --- a/openlp/plugins/bibles/lib/opensong.py +++ b/openlp/plugins/bibles/lib/opensong.py @@ -62,7 +62,7 @@ class OpenSongBible(BibleDB): file = open(self.filename, u'r') opensong = objectify.parse(file) bible = opensong.getroot() - language = self.parent.mediaItem.languageDialog() + language = self.parent.manager.import_wizard.languageDialog() if not language: log.exception(u'Importing books from %s " '\ 'failed' % self.filename) diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index 83a5a2974..cd006bb78 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -107,7 +107,7 @@ class OSISBible(BibleDB): if detect_file: detect_file.close() # Set meta language_id - language = self.parent.mediaItem.languageDialog() + language = self.parent.manager.import_wizard.languageDialog() if not language: log.exception(u'Importing books from %s " '\ 'failed' % self.filename) From fbce21baaa2884fdc3bfde9bb2bf810eac13a5fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sat, 2 Apr 2011 22:22:35 +0200 Subject: [PATCH 14/97] new function get_language in BibleDB which ask for the language a bible is and return a language_id --- openlp/plugins/bibles/lib/csvbible.py | 11 ++++------- openlp/plugins/bibles/lib/db.py | 16 ++++++++++++++++ openlp/plugins/bibles/lib/http.py | 15 ++++++--------- openlp/plugins/bibles/lib/manager.py | 2 -- openlp/plugins/bibles/lib/openlp1.py | 7 ++----- openlp/plugins/bibles/lib/opensong.py | 7 ++----- openlp/plugins/bibles/lib/osis.py | 7 ++----- 7 files changed, 32 insertions(+), 33 deletions(-) diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index 2e1accb45..389ee1aac 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -139,14 +139,11 @@ class CSVBible(BibleDB): self.wizard.progressBar.setMinimum(0) self.wizard.progressBar.setMaximum(66) success = True - language = self.parent.manager.import_wizard.languageDialog() - if not language: - log.exception(u'Importing books from %s " '\ - 'failed' % self.booksfile) + language_id = self.get_language() + if not language_id: + log.exception(u'Importing books from %s " '\ + 'failed' % self.filename) return False - language = BiblesResourcesDB.get_language(language) - language_id = language[u'id'] - self.create_meta(u'language_id', language_id) books_file = None book_list = {} # Populate the Tables diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 6cfb48c21..1960e155b 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -489,6 +489,22 @@ class BibleDB(QtCore.QObject, Manager): else: return count + def get_language(self): + """ + Return the language of a bible. + + ``book`` + The language the bible is. + """ + log.debug(u'BibleDB.get_language()') + language = self.bible_plugin.manager.import_wizard.languageDialog() + if not language: + return False + language = BiblesResourcesDB.get_language(language) + language_id = language[u'id'] + self.create_meta(u'language_id', language_id) + return language_id + def dump_bible(self): """ Utility debugging method to dump the contents of a bible. diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index d0a911b32..75f2c37fc 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -413,16 +413,13 @@ class HTTPBible(BibleDB): self.download_source.lower()) if bible[u'language_id']: language_id = bible[u'language_id'] + self.create_meta(u'language_id', language_id) else: - language = self.parent.manager.import_wizard.languageDialog() - if not language: - log.exception(u'Importing books from %s - download name: "%s" '\ - 'failed' % (self.download_source, self.download_name)) - return False - language = BiblesResourcesDB.get_language(language) - language_id = language[u'id'] - # Store the language_id. - self.create_meta(u'language_id', language_id) + language_id = self.get_language() + if not language_id: + log.exception(u'Importing books from %s " '\ + 'failed' % self.filename) + return False for book in books: self.wizard.incrementProgressBar(unicode(translate( 'BiblesPlugin.HTTPBible', 'Importing %s...', diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 7cca6f4a0..aef00e61b 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -349,9 +349,7 @@ class BibleManager(object): book, language_id) else: book_ref = self.import_wizard.bookNameDialog(book) - log.debug(book_ref) book_temp = BiblesResourcesDB.get_book(book_ref) - log.debug(book_temp) if book_temp: book_id = book_temp[u'id'] else: diff --git a/openlp/plugins/bibles/lib/openlp1.py b/openlp/plugins/bibles/lib/openlp1.py index bc3624479..23c456dda 100644 --- a/openlp/plugins/bibles/lib/openlp1.py +++ b/openlp/plugins/bibles/lib/openlp1.py @@ -58,14 +58,11 @@ class OpenLP1Bible(BibleDB): except: return False #Create the bible language - language = self.parent.manager.import_wizard.languageDialog() - if not language: + language_id = self.get_language() + if not language_id: log.exception(u'Importing books from %s " '\ 'failed' % self.filename) return False - language = BiblesResourcesDB.get_language(language) - language_id = language[u'id'] - self.create_meta(u'language_id', language_id) # Create all books. cursor.execute(u'SELECT id, testament_id, name, abbreviation FROM book') books = cursor.fetchall() diff --git a/openlp/plugins/bibles/lib/opensong.py b/openlp/plugins/bibles/lib/opensong.py index 6e4c4826f..714f021cc 100644 --- a/openlp/plugins/bibles/lib/opensong.py +++ b/openlp/plugins/bibles/lib/opensong.py @@ -62,14 +62,11 @@ class OpenSongBible(BibleDB): file = open(self.filename, u'r') opensong = objectify.parse(file) bible = opensong.getroot() - language = self.parent.manager.import_wizard.languageDialog() - if not language: + language_id = self.get_language() + if not language_id: log.exception(u'Importing books from %s " '\ 'failed' % self.filename) return False - language = BiblesResourcesDB.get_language(language) - language_id = language[u'id'] - self.create_meta(u'language_id', language_id) for book in bible.b: if self.stop_import_flag: break diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index cd006bb78..4938e505a 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -107,14 +107,11 @@ class OSISBible(BibleDB): if detect_file: detect_file.close() # Set meta language_id - language = self.parent.manager.import_wizard.languageDialog() - if not language: + language_id = self.get_language() + if not language_id: log.exception(u'Importing books from %s " '\ 'failed' % self.filename) return False - language = BiblesResourcesDB.get_language(language) - language_id = language[u'id'] - self.create_meta(u'language_id', language_id) try: osis = codecs.open(self.filename, u'r', details['encoding']) for file_record in osis: From 3d184f89a40a630a5403278a4aedbac9e6b9ebbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sun, 3 Apr 2011 20:44:08 +0200 Subject: [PATCH 15/97] moved languageDialog() into BIBLEDB.get_language() --- openlp/plugins/bibles/forms/bibleimportform.py | 7 +------ openlp/plugins/bibles/lib/csvbible.py | 2 ++ openlp/plugins/bibles/lib/db.py | 11 +++++++++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index ea7156193..c406c4db3 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -40,7 +40,7 @@ from openlp.core.ui.wizard import OpenLPWizard, WizardStrings from openlp.core.utils import AppLocation, string_is_unicode from openlp.plugins.bibles.lib.manager import BibleFormat from openlp.plugins.bibles.lib.db import BiblesResourcesDB -from openlp.plugins.bibles.forms import BookNameForm, LanguageForm +from openlp.plugins.bibles.forms import BookNameForm log = logging.getLogger(__name__) @@ -764,8 +764,3 @@ class BibleImportForm(OpenLPWizard): self.book_name = BookNameForm(self) if self.book_name.exec_(name): return unicode(self.book_name.requestComboBox.currentText()) - - def languageDialog(self): - self.language = LanguageForm(self) - if self.language.exec_(): - return unicode(self.language.requestComboBox.currentText()) diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index 389ee1aac..407c90d2f 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -78,6 +78,8 @@ class CSVBible(BibleDB): """ This class provides a specialisation for importing of CSV Bibles. """ + log.info(u'CSVBible loaded') + def __init__(self, parent, **kwargs): """ Loads a Bible from a set of CVS files. diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 1960e155b..3f50bed47 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -168,6 +168,7 @@ class BibleDB(QtCore.QObject, Manager): methods, but benefit from the database methods in here via inheritance, rather than depending on yet another object. """ + log.info(u'BibleDB loaded') def __init__(self, parent, **kwargs): """ @@ -491,13 +492,19 @@ class BibleDB(QtCore.QObject, Manager): def get_language(self): """ - Return the language of a bible. + If no language is given it calls a dialog window where the user could + choose the bible language. + Return the language id of a bible. ``book`` The language the bible is. """ log.debug(u'BibleDB.get_language()') - language = self.bible_plugin.manager.import_wizard.languageDialog() + from openlp.plugins.bibles.forms import LanguageForm + language = None + lang = LanguageForm(self.wizard) + if lang.exec_(): + language = unicode(lang.requestComboBox.currentText()) if not language: return False language = BiblesResourcesDB.get_language(language) From a9c87798ebf9bbc64cc6ce9611cb0000e7808469 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sun, 3 Apr 2011 22:09:18 +0200 Subject: [PATCH 16/97] moved get_book_ref_id_by_name() from BibleManager to BibleDB moved content from BookNameDialog() from bibleimport.py in BibleDB.get_book_ref_id_by_name(). --- .../plugins/bibles/forms/bibleimportform.py | 6 --- openlp/plugins/bibles/forms/languageform.py | 2 +- openlp/plugins/bibles/lib/csvbible.py | 2 +- openlp/plugins/bibles/lib/db.py | 39 ++++++++++++++ openlp/plugins/bibles/lib/http.py | 3 +- openlp/plugins/bibles/lib/manager.py | 54 +------------------ openlp/plugins/bibles/lib/openlp1.py | 3 +- openlp/plugins/bibles/lib/opensong.py | 2 +- openlp/plugins/bibles/lib/osis.py | 3 +- 9 files changed, 46 insertions(+), 68 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index c406c4db3..fd6690888 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -40,7 +40,6 @@ from openlp.core.ui.wizard import OpenLPWizard, WizardStrings from openlp.core.utils import AppLocation, string_is_unicode from openlp.plugins.bibles.lib.manager import BibleFormat from openlp.plugins.bibles.lib.db import BiblesResourcesDB -from openlp.plugins.bibles.forms import BookNameForm log = logging.getLogger(__name__) @@ -759,8 +758,3 @@ class BibleImportForm(OpenLPWizard): 'BiblesPlugin.ImportWizardForm', 'Your Bible import failed.')) del self.manager.db_cache[importer.name] delete_database(self.plugin.settingsSection, importer.file) - - def bookNameDialog(self, name): - self.book_name = BookNameForm(self) - if self.book_name.exec_(name): - return unicode(self.book_name.requestComboBox.currentText()) diff --git a/openlp/plugins/bibles/forms/languageform.py b/openlp/plugins/bibles/forms/languageform.py index f074a9dc5..e96a005c2 100644 --- a/openlp/plugins/bibles/forms/languageform.py +++ b/openlp/plugins/bibles/forms/languageform.py @@ -25,7 +25,7 @@ ############################################################################### """ -Module implementing BookNameForm. +Module implementing LanguageForm. """ import logging diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index 407c90d2f..f0abb9a1d 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -159,7 +159,7 @@ class CSVBible(BibleDB): self.wizard.incrementProgressBar(unicode( translate('BibleDB.Wizard', 'Importing books... %s')) % unicode(line[2], details['encoding'])) - book_ref_id = self.parent.manager.get_book_ref_id_by_name( + book_ref_id = self.get_book_ref_id_by_name( unicode(line[2], details['encoding']), language_id) if not book_ref_id: log.exception(u'Importing books from %s " '\ diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 3f50bed47..191d18d65 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -202,6 +202,8 @@ class BibleDB(QtCore.QObject, Manager): Manager.__init__(self, u'bibles/bibles', init_schema, self.file) if u'file' in kwargs: self.get_name() + if u'path' in kwargs: + self.path = kwargs[u'path'] self.wizard = None QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_import) @@ -383,6 +385,43 @@ class BibleDB(QtCore.QObject, Manager): Book.book_reference_id.like(id)) return db_book + def get_book_ref_id_by_name(self, book, language_id=None): + log.debug(u'BibleManager.get_book_ref_id_by_name:("%s", "%s")', book, + language_id) + self.alternative_book_names_cache = AlternativeBookNamesDB(self.bible_plugin, + path=self.path) + if BiblesResourcesDB.get_book(book): + book_temp = BiblesResourcesDB.get_book(book) + book_id = book_temp[u'id'] + elif BiblesResourcesDB.get_alternative_book_name(book, language_id): + book_id = BiblesResourcesDB.get_alternative_book_name(book, + language_id) + elif self.alternative_book_names_cache.get_book_reference_id(book, + language_id): + book_id = self.alternative_book_names_cache.get_book_reference_id( + book, language_id) + else: + from openlp.plugins.bibles.forms import BookNameForm + book_ref = None + book_name = BookNameForm(self.wizard) + if book_name.exec_(book): + book_ref = unicode(book_name.requestComboBox.currentText()) + if not book_ref: + return None + else: + book_temp = BiblesResourcesDB.get_book(book_ref) + if book_temp: + book_id = book_temp[u'id'] + else: + return None + if book_id: + self.alternative_book_names_cache.create_alternative_book_name( + book, book_id, language_id) + if book_id: + return book_id + else: + return None + def get_verses(self, reference_list): """ This is probably the most used function. It retrieves the list of diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 75f2c37fc..85f7405a6 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -424,8 +424,7 @@ class HTTPBible(BibleDB): self.wizard.incrementProgressBar(unicode(translate( 'BiblesPlugin.HTTPBible', 'Importing %s...', 'Importing ...')) % book) - book_ref_id = self.parent.manager.get_book_ref_id_by_name(book, - language_id) + book_ref_id = self.get_book_ref_id_by_name(book, language_id) if not book_ref_id: log.exception(u'Importing books from %s - download name: "%s" '\ 'failed' % (self.download_source, self.download_name)) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index aef00e61b..e1e32cc80 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -33,8 +33,7 @@ from openlp.core.lib import Receiver, SettingsManager, translate from openlp.core.lib.ui import critical_error_message_box from openlp.core.utils import AppLocation, delete_file from openlp.plugins.bibles.lib import parse_reference -from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta, \ - AlternativeBookNamesDB, BiblesResourcesDB +from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta from csvbible import CSVBible from http import HTTPBible from opensong import OpenSongBible @@ -170,19 +169,6 @@ class BibleManager(object): self.db_cache[name] = web_bible log.debug(u'Bibles reloaded') - #TODO: Delete unused code - ''' - def reload_alternative_book_names(self): - """ - Reloads the alternative book names from the local alternative book names - database on disk. - """ - log.debug(u'Reload AlternativeBookNames') - self.alternative_book_names_cache = AlternativeBookNamesDB(self.parent, - path=self.path) - log.debug(u'AlternativeBookNames reloaded') - ''' - def set_process_dialog(self, wizard): """ Sets the reference to the dialog with the progress bar on it. @@ -324,44 +310,6 @@ class BibleManager(object): }) return None - def get_book_ref(self, book, language_id=None): - log.debug(u'BibleManager.get_book_ref("%s", "%s")', book, language_id) - book_id = self.get_book_ref_id_by_name(book, language_id) - book_temp = BiblesResourcesDB.get_book_by_id(book_id) - log.debug(u'BibleManager.get_book_ref("Return: %s")', - book_temp[u'name']) - return book_temp[u'name'] - - def get_book_ref_id_by_name(self, book, language_id=None): - log.debug(u'BibleManager.get_book_ref_id_by_name:("%s", "%s")', book, - language_id) - self.alternative_book_names_cache = AlternativeBookNamesDB(self.parent, - path=self.path) - if BiblesResourcesDB.get_book(book): - book_temp = BiblesResourcesDB.get_book(book) - book_id = book_temp[u'id'] - elif BiblesResourcesDB.get_alternative_book_name(book, language_id): - book_id = BiblesResourcesDB.get_alternative_book_name(book, - language_id) - elif self.alternative_book_names_cache.get_book_reference_id(book, - language_id): - book_id = self.alternative_book_names_cache.get_book_reference_id( - book, language_id) - else: - book_ref = self.import_wizard.bookNameDialog(book) - book_temp = BiblesResourcesDB.get_book(book_ref) - if book_temp: - book_id = book_temp[u'id'] - else: - return None - if book_id: - self.alternative_book_names_cache.create_alternative_book_name( - book, book_id, language_id) - if book_id: - return book_id - else: - return None - def verse_search(self, bible, second_bible, text): """ Does a verse search for the given bible and text. diff --git a/openlp/plugins/bibles/lib/openlp1.py b/openlp/plugins/bibles/lib/openlp1.py index 23c456dda..0de89b4a7 100644 --- a/openlp/plugins/bibles/lib/openlp1.py +++ b/openlp/plugins/bibles/lib/openlp1.py @@ -75,8 +75,7 @@ class OpenLP1Bible(BibleDB): testament_id = int(book[1]) name = unicode(book[2], u'cp1252') abbreviation = unicode(book[3], u'cp1252') - book_ref_id = self.parent.manager.get_book_ref_id_by_name(name, - language_id) + book_ref_id = self.get_book_ref_id_by_name(name, language_id) if not book_ref_id: log.exception(u'Importing books from %s " '\ 'failed' % self.filename) diff --git a/openlp/plugins/bibles/lib/opensong.py b/openlp/plugins/bibles/lib/opensong.py index 714f021cc..37428cc7a 100644 --- a/openlp/plugins/bibles/lib/opensong.py +++ b/openlp/plugins/bibles/lib/opensong.py @@ -70,7 +70,7 @@ class OpenSongBible(BibleDB): for book in bible.b: if self.stop_import_flag: break - book_ref_id = self.parent.manager.get_book_ref_id_by_name( + book_ref_id = self.get_book_ref_id_by_name( unicode(book.attrib[u'n']), language_id) if not book_ref_id: log.exception(u'Importing books from %s " '\ diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index 4938e505a..ba6cf5d63 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -129,8 +129,7 @@ class OSISBible(BibleDB): #TODO: Delete unused code #if book == u'Matt' or book == u'Jdt': # testament += 1 - book_ref_id = self.parent.manager.\ - get_book_ref_id_by_name( + book_ref_id = self.get_book_ref_id_by_name( unicode(self.books[book][0]), language_id) if not book_ref_id: log.exception(u'Importing books from %s " '\ From 7cdf2bc320f00d670c8db5f5818dd8555e66ca23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Mon, 11 Apr 2011 18:21:54 +0200 Subject: [PATCH 17/97] small cleanups --- openlp/plugins/bibles/lib/csvbible.py | 3 ++- openlp/plugins/bibles/lib/db.py | 6 +++--- openlp/plugins/bibles/lib/http.py | 1 - openlp/plugins/bibles/lib/manager.py | 2 -- openlp/plugins/bibles/lib/openlp1.py | 1 - openlp/plugins/bibles/lib/opensong.py | 3 +-- openlp/plugins/bibles/lib/osis.py | 1 - 7 files changed, 6 insertions(+), 11 deletions(-) diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index f0abb9a1d..71af33ca7 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -88,7 +88,6 @@ class CSVBible(BibleDB): """ log.info(self.__class__.__name__) BibleDB.__init__(self, parent, **kwargs) - self.parent = parent #TODO: Delete unused code ''' try: @@ -98,6 +97,8 @@ class CSVBible(BibleDB): ''' self.booksfile = kwargs[u'booksfile'] self.versesfile = kwargs[u'versefile'] + + #TODO: Delete unused code ''' def setup_testaments(self): """ diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 191d18d65..e520aec3f 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -386,10 +386,10 @@ class BibleDB(QtCore.QObject, Manager): return db_book def get_book_ref_id_by_name(self, book, language_id=None): - log.debug(u'BibleManager.get_book_ref_id_by_name:("%s", "%s")', book, + log.debug(u'BibleDB.get_book_ref_id_by_name:("%s", "%s")', book, language_id) - self.alternative_book_names_cache = AlternativeBookNamesDB(self.bible_plugin, - path=self.path) + self.alternative_book_names_cache = AlternativeBookNamesDB( + self.bible_plugin, path=self.path) if BiblesResourcesDB.get_book(book): book_temp = BiblesResourcesDB.get_book(book) book_id = book_temp[u'id'] diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 85f7405a6..bd59d0cc9 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -359,7 +359,6 @@ class HTTPBible(BibleDB): Init confirms the bible exists and stores the database path. """ BibleDB.__init__(self, parent, **kwargs) - self.parent = parent self.download_source = kwargs[u'download_source'] self.download_name = kwargs[u'download_name'] # TODO: Clean up proxy stuff. We probably want one global proxy per diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index e1e32cc80..dd1669b23 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -130,8 +130,6 @@ class BibleManager(object): self.suffix = u'.sqlite' self.import_wizard = None self.reload_bibles() - #TODO: Delete unused code - #self.reload_alternative_book_names() self.media = None def reload_bibles(self): diff --git a/openlp/plugins/bibles/lib/openlp1.py b/openlp/plugins/bibles/lib/openlp1.py index 0de89b4a7..0ef5f95a9 100644 --- a/openlp/plugins/bibles/lib/openlp1.py +++ b/openlp/plugins/bibles/lib/openlp1.py @@ -43,7 +43,6 @@ class OpenLP1Bible(BibleDB): """ log.debug(self.__class__.__name__) BibleDB.__init__(self, parent, **kwargs) - self.parent = parent self.filename = kwargs[u'filename'] def do_import(self): diff --git a/openlp/plugins/bibles/lib/opensong.py b/openlp/plugins/bibles/lib/opensong.py index 37428cc7a..875977bbd 100644 --- a/openlp/plugins/bibles/lib/opensong.py +++ b/openlp/plugins/bibles/lib/opensong.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +song# -*- coding: utf-8 -*- # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 ############################################################################### @@ -43,7 +43,6 @@ class OpenSongBible(BibleDB): """ log.debug(self.__class__.__name__) BibleDB.__init__(self, parent, **kwargs) - self.parent = parent self.filename = kwargs['filename'] def do_import(self): diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index ba6cf5d63..9b65bb8d8 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -46,7 +46,6 @@ class OSISBible(BibleDB): def __init__(self, parent, **kwargs): log.debug(self.__class__.__name__) BibleDB.__init__(self, parent, **kwargs) - self.parent = parent self.filename = kwargs[u'filename'] fbibles = None self.books = {} From 0ad2d851715448af24ad0c2454b36c7bea9c87e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Mon, 11 Apr 2011 22:57:00 +0200 Subject: [PATCH 18/97] small fix --- openlp/plugins/bibles/lib/opensong.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/opensong.py b/openlp/plugins/bibles/lib/opensong.py index 875977bbd..cb971fa99 100644 --- a/openlp/plugins/bibles/lib/opensong.py +++ b/openlp/plugins/bibles/lib/opensong.py @@ -1,4 +1,4 @@ -song# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- # vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 ############################################################################### From 6c047fc83ef2bd95d52240dca7215c55e15a6ade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Tue, 12 Apr 2011 13:33:29 +0200 Subject: [PATCH 19/97] changed content of book drop list in advanced search. If a second bible is choosen the combobox only contains books which both bibles (first and second) contains. changed autocomplete in quick search. If a second bible is choosen it now suggest only books which both bibles contains. --- openlp/plugins/bibles/lib/manager.py | 1 + openlp/plugins/bibles/lib/mediaitem.py | 38 ++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index dd1669b23..75db89af2 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -214,6 +214,7 @@ class BibleManager(object): books.append( { u'name': book.name, + u'book_reference_id': book.book_reference_id, u'chapters': self.db_cache[bible].get_chapter_count(book.book_reference_id) }) return books diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 9f43b99cc..279ecc1cf 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -202,8 +202,14 @@ class BibleMediaItem(MediaManagerItem): # Add the search tab widget to the page layout. self.pageLayout.addWidget(self.searchTabWidget) # Combo Boxes + QtCore.QObject.connect(self.quickVersionComboBox, + QtCore.SIGNAL(u'activated(int)'), self.onQuickVersionComboBox) + QtCore.QObject.connect(self.quickSecondComboBox, + QtCore.SIGNAL(u'activated(int)'), self.onQuickSecondComboBox) QtCore.QObject.connect(self.advancedVersionComboBox, QtCore.SIGNAL(u'activated(int)'), self.onAdvancedVersionComboBox) + QtCore.QObject.connect(self.advancedSecondComboBox, + QtCore.SIGNAL(u'activated(int)'), self.onAdvancedSecondComboBox) QtCore.QObject.connect(self.advancedBookComboBox, QtCore.SIGNAL(u'activated(int)'), self.onAdvancedBookComboBox) QtCore.QObject.connect(self.advancedFromChapter, @@ -346,6 +352,16 @@ class BibleMediaItem(MediaManagerItem): """ log.debug(u'initialiseAdvancedBible %s', bible) book_data = self.parent.manager.get_books(bible) + secondbible = unicode(self.advancedSecondComboBox.currentText()) + if secondbible != u'': + secondbook_data = self.parent.manager.get_books(secondbible) + book_data_temp = [] + for book in book_data: + for secondbook in secondbook_data: + if book['book_reference_id'] == \ + secondbook['book_reference_id']: + book_data_temp.append(book) + book_data = book_data_temp self.advancedBookComboBox.clear() first = True for book in book_data: @@ -395,16 +411,38 @@ class BibleMediaItem(MediaManagerItem): bible = unicode(self.quickVersionComboBox.currentText()) if bible: book_data = bibles[bible].get_books() + secondbible = unicode(self.quickSecondComboBox.currentText()) + if secondbible != u'': + secondbook_data = bibles[secondbible].get_books() + book_data_temp = [] + for book in book_data: + for secondbook in secondbook_data: + if book.book_reference_id == \ + secondbook.book_reference_id: + book_data_temp.append(book) + book_data = book_data_temp books = [book.name for book in book_data] books.sort() add_widget_completer(books, self.quickSearchEdit) + def onQuickVersionComboBox(self): + self.updateAutoCompleter() + + def onQuickSecondComboBox(self): + self.updateAutoCompleter() + def onAdvancedVersionComboBox(self): QtCore.QSettings().setValue(self.settingsSection + u'/advanced bible', QtCore.QVariant(self.advancedVersionComboBox.currentText())) self.initialiseAdvancedBible( unicode(self.advancedVersionComboBox.currentText())) + def onAdvancedSecondComboBox(self): + QtCore.QSettings().setValue(self.settingsSection + u'/advanced bible', + QtCore.QVariant(self.advancedVersionComboBox.currentText())) + self.initialiseAdvancedBible( + unicode(self.advancedVersionComboBox.currentText())) + def onAdvancedBookComboBox(self): item = int(self.advancedBookComboBox.currentIndex()) self.initialiseChapterVerse( From df0d9244ebe1e6dfd44abe4354a364fde2af9797 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Thu, 14 Apr 2011 10:40:30 +0200 Subject: [PATCH 20/97] Changed layout of AlternativeBookNamesDB from sqlalchemy to sqlite3 --- openlp/plugins/bibles/lib/db.py | 155 +++++++++++++++----------------- 1 file changed, 70 insertions(+), 85 deletions(-) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index e520aec3f..a0780e7b8 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -70,13 +70,6 @@ class Verse(BaseModel): """ pass -class AlternativeBookNames(BaseModel): - """ - Alternative Book Names model - """ - pass - - def init_schema(url): """ Setup a bible database connection and initialise the database schema. @@ -136,30 +129,6 @@ def init_schema(url): metadata.create_all(checkfirst=True) return session -def init_schema_alternative_book_names(url): - """ - Setup a alternative book names database connection and initialise the - database schema. - - ``url`` - The database to setup. - """ - session, metadata = init_db(url) - - alternative_book_names_table = Table(u'alternative_book_names', metadata, - Column(u'id', types.Integer, primary_key=True), - Column(u'book_reference_id', types.Integer), - Column(u'language_id', types.Integer), - Column(u'name', types.Unicode(50), index=True), - ) - - try: - class_mapper(AlternativeBookNames) - except UnmappedClassError: - mapper(AlternativeBookNames, alternative_book_names_table) - - metadata.create_all(checkfirst=True) - return session class BibleDB(QtCore.QObject, Manager): """ @@ -388,17 +357,15 @@ class BibleDB(QtCore.QObject, Manager): def get_book_ref_id_by_name(self, book, language_id=None): log.debug(u'BibleDB.get_book_ref_id_by_name:("%s", "%s")', book, language_id) - self.alternative_book_names_cache = AlternativeBookNamesDB( - self.bible_plugin, path=self.path) if BiblesResourcesDB.get_book(book): book_temp = BiblesResourcesDB.get_book(book) book_id = book_temp[u'id'] elif BiblesResourcesDB.get_alternative_book_name(book, language_id): book_id = BiblesResourcesDB.get_alternative_book_name(book, language_id) - elif self.alternative_book_names_cache.get_book_reference_id(book, + elif AlternativeBookNamesDB.get_book_reference_id(book, language_id): - book_id = self.alternative_book_names_cache.get_book_reference_id( + book_id = AlternativeBookNamesDB.get_book_reference_id( book, language_id) else: from openlp.plugins.bibles.forms import BookNameForm @@ -415,7 +382,7 @@ class BibleDB(QtCore.QObject, Manager): else: return None if book_id: - self.alternative_book_names_cache.create_alternative_book_name( + AlternativeBookNamesDB.create_alternative_book_name( book, book_id, language_id) if book_id: return book_id @@ -822,6 +789,12 @@ class BiblesResourcesDB(QtCore.QObject, Manager): def get_alternative_book_name(name, language_id=None): """ Return a book_reference_id if the name matches. + + ``name`` + The name to search the id. + + ``language_id`` + The language_id for which language should be searched """ log.debug(u'BiblesResourcesDB.get_alternative_book_name("%s", "%s")', name, language_id) @@ -898,73 +871,85 @@ class BiblesResourcesDB(QtCore.QObject, Manager): }) return testament_list + class AlternativeBookNamesDB(QtCore.QObject, Manager): """ This class represents a database-bound alternative book names system. """ + cursor = None + conn = None - def __init__(self, parent, **kwargs): + @staticmethod + def get_cursor(): """ - The constructor loads up the database and creates and initialises the - tables if the database doesn't exist. - - **Required keyword arguments:** - - ``path`` - The path to the bible database file. - - ``name`` - The name of the database. This is also used as the file name for - SQLite databases. + Return the cursor object. Instantiate one if it doesn't exist yet. + If necessary loads up the database and creates the tables if the + database doesn't exist. """ - log.info(u'AlternativeBookNamesDB loaded') - QtCore.QObject.__init__(self) - self.bible_plugin = parent - if u'path' not in kwargs: - raise KeyError(u'Missing keyword argument "path".') - self.stop_import_flag = False - self.name = u'alternative_book_names.sqlite' - if not isinstance(self.name, unicode): - self.name = unicode(self.name, u'utf-8') - self.file = self.name - Manager.__init__(self, u'bibles/resources', - init_schema_alternative_book_names, self.file) - self.wizard = None - QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_import) + if AlternativeBookNamesDB.cursor is None: + filepath = os.path.join( + AppLocation.get_directory(AppLocation.DataDir), u'bibles', + u'resources', u'alternative_book_names.sqlite') + log.debug(u'Filepath: %s' % filepath) + if not os.path.exists(filepath): + #create new DB, create table alternative_book_names + AlternativeBookNamesDB.conn = sqlite3.connect(filepath) + AlternativeBookNamesDB.conn.execute(u'CREATE TABLE ' + u'alternative_book_names(id INTEGER NOT NULL, ' + u'book_reference_id INTEGER, language_id INTEGER, name ' + u'VARCHAR(50), PRIMARY KEY (id))') + else: + #use existing DB + AlternativeBookNamesDB.conn = sqlite3.connect(filepath) + AlternativeBookNamesDB.cursor = AlternativeBookNamesDB.conn.cursor() + return AlternativeBookNamesDB.cursor - def stop_import(self): + @staticmethod + def run_sql(query, parameters=(), commit=None): """ - Stops the import of the Bible. - """ - log.debug(u'Stopping import') - self.stop_import_flag = True + Run an SQL query on the database, returning the results. - def get_book_reference_id(self, name, language=None): + ``query`` + The actual SQL query to run. + + ``parameters`` + Any variable parameters to add to the query + + ``commit`` + If a commit statement is necessary this should be True. """ - Return the book_reference_id of a book by name. + cursor = AlternativeBookNamesDB.get_cursor() + cursor.execute(query, parameters) + if commit: + AlternativeBookNamesDB.conn.commit() + return cursor.fetchall() + + @staticmethod + def get_book_reference_id(name, language_id=None): + """ + Return a book_reference_id if the name matches. ``name`` The name to search the id. - ``language`` - The language for which should be searched + ``language_id`` + The language_id for which language should be searched """ - log.debug(u'AlternativeBookNamesDB.get_book_reference_id("%s")', name) - if language: - id = self.session.query(AlternativeBookNames.book_reference_id)\ - .filter(AlternativeBookNames.name.like(name))\ - .filter(AlternativeBookNames.language_id.like(language)).first() + log.debug(u'AlternativeBookNamesDB.get_book_reference_id("%s", "%s")', + name, language_id) + if language_id: + id = AlternativeBookNamesDB.run_sql(u'SELECT book_reference_id FROM ' + u'alternative_book_names WHERE name = ? AND language_id = ?', (name, language_id)) else: - id = self.get_object_filtered(AlternativeBookNames.book_reference_id, - AlternativeBookNames.name.like(name)) + id = AlternativeBookNamesDB.run_sql(u'SELECT book_reference_id FROM ' + u'alternative_book_names WHERE name = ?', name) if not id: return None else: - return id[0] + return id[0][0] - def create_alternative_book_name(self, name, book_reference_id, - language_id): + @staticmethod + def create_alternative_book_name(name, book_reference_id, language_id): """ Add an alternative book name to the database. @@ -979,7 +964,7 @@ class AlternativeBookNamesDB(QtCore.QObject, Manager): """ log.debug(u'AlternativeBookNamesDB.create_alternative_book_name("%s", ' '"%s", "%s"', name, book_reference_id, language_id) - alternative_book_name = AlternativeBookNames.populate(name=name, - book_reference_id=book_reference_id, language_id=language_id) - self.save_object(alternative_book_name) + alternative_book_name = AlternativeBookNamesDB.run_sql(u'INSERT INTO ' + u'alternative_book_names(book_reference_id, language_id, name) ' + u'VALUES (?, ?, ?)', (book_reference_id, language_id, name), True) return alternative_book_name From fbace696541325e810a11b09e9ed225e3c32b279 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Thu, 14 Apr 2011 11:08:58 +0200 Subject: [PATCH 21/97] remove bibleimportrequestdialog.ui --- resources/forms/bibleimportrequestdialog.ui | 137 -------------------- 1 file changed, 137 deletions(-) delete mode 100644 resources/forms/bibleimportrequestdialog.ui diff --git a/resources/forms/bibleimportrequestdialog.ui b/resources/forms/bibleimportrequestdialog.ui deleted file mode 100644 index 5795300f9..000000000 --- a/resources/forms/bibleimportrequestdialog.ui +++ /dev/null @@ -1,137 +0,0 @@ - - - BibleImportRequest - - - - 0 - 0 - 400 - 175 - - - - - 0 - 0 - - - - Dialog - - - - - 10 - 15 - 381 - 151 - - - - - - - - Arial - 12 - 75 - true - - - - Choose Book: - - - - - - - The following books cannot be clearly attributed. -Please choose the book it is. - - - - - - - - - Book: - - - - - - - - 0 - 0 - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - - BibleImportRequestButtonBox - accepted() - BibleImportRequest - accept() - - - 248 - 254 - - - 157 - 274 - - - - - BibleImportRequestButtonBox - rejected() - BibleImportRequest - reject() - - - 316 - 260 - - - 286 - 274 - - - - - From 77f43e32b993708c41cc251ac797ae627451536d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Thu, 14 Apr 2011 22:18:23 +0200 Subject: [PATCH 22/97] small cleanups --- openlp/plugins/bibles/lib/db.py | 9 +++++---- openlp/plugins/bibles/lib/http.py | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index a0780e7b8..d3c93cdfa 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -938,11 +938,12 @@ class AlternativeBookNamesDB(QtCore.QObject, Manager): log.debug(u'AlternativeBookNamesDB.get_book_reference_id("%s", "%s")', name, language_id) if language_id: - id = AlternativeBookNamesDB.run_sql(u'SELECT book_reference_id FROM ' - u'alternative_book_names WHERE name = ? AND language_id = ?', (name, language_id)) + id = AlternativeBookNamesDB.run_sql(u'SELECT book_reference_id FROM' + u' alternative_book_names WHERE name = ? AND language_id = ?', + (name, language_id)) else: - id = AlternativeBookNamesDB.run_sql(u'SELECT book_reference_id FROM ' - u'alternative_book_names WHERE name = ?', name) + id = AlternativeBookNamesDB.run_sql(u'SELECT book_reference_id FROM' + u' alternative_book_names WHERE name = ?', name) if not id: return None else: diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index bd59d0cc9..a9f31a3ea 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -42,7 +42,7 @@ from openlp.core.lib.ui import critical_error_message_box from openlp.core.utils import AppLocation, get_web_page from openlp.plugins.bibles.lib import SearchResults from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB, \ - Book, BibleMeta + Book log = logging.getLogger(__name__) From e8202924f7650062be5f4863ec97b3bd101694fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Thu, 14 Apr 2011 22:33:02 +0200 Subject: [PATCH 23/97] delete unused testament stuff --- .../plugins/bibles/forms/bibleimportform.py | 60 +------------------ openlp/plugins/bibles/lib/csvbible.py | 45 +------------- openlp/plugins/bibles/lib/db.py | 36 +---------- openlp/plugins/bibles/lib/osis.py | 5 -- 4 files changed, 3 insertions(+), 143 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index a18e3a4e1..ebf8a6c30 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -124,10 +124,6 @@ class BibleImportForm(OpenLPWizard): QtCore.QObject.connect(self.osisBrowseButton, QtCore.SIGNAL(u'clicked()'), self.onOsisBrowseButtonClicked) - #TODO: Delete unused code - #QtCore.QObject.connect(self.csvTestamentsButton, - # QtCore.SIGNAL(u'clicked()'), - # self.onCsvTestamentsBrowseButtonClicked) QtCore.QObject.connect(self.csvBooksButton, QtCore.SIGNAL(u'clicked()'), self.onCsvBooksBrowseButtonClicked) @@ -188,22 +184,6 @@ class BibleImportForm(OpenLPWizard): self.csvLayout = QtGui.QFormLayout(self.csvWidget) self.csvLayout.setMargin(0) self.csvLayout.setObjectName(u'CsvLayout') - #TODO: Delete unused code - ''' - self.csvTestamentsLabel = QtGui.QLabel(self.csvWidget) - self.csvTestamentsLabel.setObjectName(u'CsvTestamentsLabel') - self.csvTestamentsLayout = QtGui.QHBoxLayout() - self.csvTestamentsLayout.setObjectName(u'CsvTestamentsLayout') - self.csvTestamentsEdit = QtGui.QLineEdit(self.csvWidget) - self.csvTestamentsEdit.setObjectName(u'CsvTestamentsEdit') - self.csvTestamentsLayout.addWidget(self.csvTestamentsEdit) - - self.csvTestamentsButton = QtGui.QToolButton(self.csvWidget) - self.csvTestamentsButton.setIcon(self.openIcon) - self.csvTestamentsButton.setObjectName(u'CsvTestamentsButton') - self.csvTestamentsLayout.addWidget(self.csvTestamentsButton) - self.csvLayout.addRow(self.csvTestamentsLabel, self.csvTestamentsLayout) - ''' self.csvBooksLabel = QtGui.QLabel(self.csvWidget) self.csvBooksLabel.setObjectName(u'CsvBooksLabel') self.csvBooksLayout = QtGui.QHBoxLayout() @@ -388,9 +368,6 @@ class BibleImportForm(OpenLPWizard): translate('BiblesPlugin.ImportWizardForm', 'Bible file:')) self.osisFileLabel.setText( translate('BiblesPlugin.ImportWizardForm', 'Bible file:')) - #TODO: Delete unused code - #self.csvTestamentsLabel.setText( - # translate('BiblesPlugin.ImportWizardForm', 'Testaments file:')) self.csvBooksLabel.setText( translate('BiblesPlugin.ImportWizardForm', 'Books file:')) self.csvVersesLabel.setText( @@ -441,8 +418,6 @@ class BibleImportForm(OpenLPWizard): # Align all QFormLayouts towards each other. labelWidth = max(self.formatLabel.minimumSizeHint().width(), self.osisFileLabel.minimumSizeHint().width(), - #TODO: Delete unused code - #self.csvTestamentsLabel.minimumSizeHint().width(), self.csvBooksLabel.minimumSizeHint().width(), self.csvVersesLabel.minimumSizeHint().width(), self.openSongFileLabel.minimumSizeHint().width(), @@ -464,17 +439,6 @@ class BibleImportForm(OpenLPWizard): self.osisFileEdit.setFocus() return False elif self.field(u'source_format').toInt()[0] == BibleFormat.CSV: - #TODO: Delete unused code - ''' - if not self.field(u'csv_testamentsfile').toString(): - answer = critical_error_message_box(UiStrings.NFSs, - translate('BiblesPlugin.ImportWizardForm', - 'You have not specified a testaments file. Do you ' - 'want to proceed with the import?'), question=True) - if answer == QtGui.QMessageBox.No: - self.csvTestamentsEdit.setFocus() - return False - ''' if not self.field(u'csv_booksfile').toString(): critical_error_message_box(UiStrings.NFSs, translate('BiblesPlugin.ImportWizardForm', @@ -551,16 +515,7 @@ class BibleImportForm(OpenLPWizard): """ self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.OSIS, self.osisFileEdit) - #TODO: Delete unused code - ''' - def onCsvTestamentsBrowseButtonClicked(self): - """ - Show the file open dialog for the testaments CSV file. - """ - self.getFileName(WizardStrings.OpenTypeFile % WizardStrings.CSV, - self.csvTestamentsEdit, u'%s (*.csv)' - % translate('BiblesPlugin.ImportWizardForm', 'CSV File')) - ''' + def onCsvBooksBrowseButtonClicked(self): """ Show the file open dialog for the books CSV file. @@ -599,9 +554,6 @@ class BibleImportForm(OpenLPWizard): """ self.selectPage.registerField(u'source_format', self.formatComboBox) self.selectPage.registerField(u'osis_location', self.osisFileEdit) - #TODO: Delete unused code - #self.selectPage.registerField( - # u'csv_testamentsfile', self.csvTestamentsEdit) self.selectPage.registerField(u'csv_booksfile', self.csvBooksEdit) self.selectPage.registerField(u'csv_versefile', self.csvVersesEdit) self.selectPage.registerField(u'opensong_file', self.openSongFileEdit) @@ -630,8 +582,6 @@ class BibleImportForm(OpenLPWizard): self.cancelButton.setVisible(True) self.setField(u'source_format', QtCore.QVariant(0)) self.setField(u'osis_location', QtCore.QVariant('')) - #TODO: Delete unused code - #self.setField(u'csv_testamentsfile', QtCore.QVariant('')) self.setField(u'csv_booksfile', QtCore.QVariant('')) self.setField(u'csv_versefile', QtCore.QVariant('')) self.setField(u'opensong_file', QtCore.QVariant('')) @@ -712,14 +662,6 @@ class BibleImportForm(OpenLPWizard): ) elif bible_type == BibleFormat.CSV: # Import a CSV bible. - #TODO: Delete unused code - ''' - importer = self.manager.import_bible(BibleFormat.CSV, - name=license_version, testamentsfile=unicode( - self.field(u'csv_testamentsfile').toString()), - booksfile=unicode(self.field(u'csv_booksfile').toString()), - versefile=unicode(self.field(u'csv_versefile').toString()) - ''' importer = self.manager.import_bible(BibleFormat.CSV, name=license_version, booksfile=unicode(self.field(u'csv_booksfile').toString()), diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index 71af33ca7..be45bfeb9 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -88,52 +88,9 @@ class CSVBible(BibleDB): """ log.info(self.__class__.__name__) BibleDB.__init__(self, parent, **kwargs) - #TODO: Delete unused code - ''' - try: - self.testamentsfile = kwargs[u'testamentsfile'] - except KeyError: - self.testamentsfile = None - ''' self.booksfile = kwargs[u'booksfile'] self.versesfile = kwargs[u'versefile'] - - #TODO: Delete unused code - ''' - def setup_testaments(self): - """ - Overrides parent method so we can handle importing a testament file. - """ - if self.testamentsfile: - self.wizard.progressBar.setMinimum(0) - self.wizard.progressBar.setMaximum(2) - self.wizard.progressBar.setValue(0) - testaments_file = None - try: - details = get_file_encoding(self.testamentsfile) - testaments_file = open(self.testamentsfile, 'rb') - testaments_reader = csv.reader(testaments_file, delimiter=',', - quotechar='"') - for line in testaments_reader: - if self.stop_import_flag: - break - self.wizard.incrementProgressBar(unicode( - translate('BibleDB.Wizard', - 'Importing testaments... %s')) % - unicode(line[1], details['encoding']), 0) - self.save_object(Testament.populate( - name=unicode(line[1], details['encoding']))) - Receiver.send_message(u'openlp_process_events') - except (IOError, IndexError): - log.exception(u'Loading testaments from file failed') - finally: - if testaments_file: - testaments_file.close() - self.wizard.incrementProgressBar(unicode(translate( - 'BibleDB.Wizard', 'Importing testaments... done.')), 2) - else: - BibleDB.setup_testaments(self) - ''' + def do_import(self): """ Import the bible books and verses. diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index d3c93cdfa..4afc5bccf 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -48,14 +48,6 @@ class BibleMeta(BaseModel): """ pass -#TODO: Delete unused code -''' -class Testament(BaseModel): - """ - Bible Testaments - """ - pass -''' class Book(BaseModel): """ @@ -83,13 +75,7 @@ def init_schema(url): Column(u'key', types.Unicode(255), primary_key=True, index=True), Column(u'value', types.Unicode(255)), ) - #TODO: Delete unused code - ''' - testament_table = Table(u'testament', metadata, - Column(u'id', types.Integer, primary_key=True), - Column(u'name', types.Unicode(50)), - ) - ''' + book_table = Table(u'book', metadata, Column(u'id', types.Integer, primary_key=True), Column(u'book_reference_id', types.Integer), @@ -109,13 +95,6 @@ def init_schema(url): class_mapper(BibleMeta) except UnmappedClassError: mapper(BibleMeta, meta_table) - #TODO: Delete unused code - ''' - try: - class_mapper(Testament) - except UnmappedClassError: - mapper(Testament, testament_table) - ''' try: class_mapper(Book) except UnmappedClassError: @@ -220,21 +199,8 @@ class BibleDB(QtCore.QObject, Manager): """ self.wizard = wizard self.create_meta(u'dbversion', u'2') - #TODO: Delete unused code - #self.setup_testaments() return self.name - #TODO: Delete unused code - ''' - def setup_testaments(self): - """ - Initialise the testaments section of a bible with suitable defaults. - """ - self.save_object(Testament.populate(name=u'Old Testament')) - self.save_object(Testament.populate(name=u'New Testament')) - self.save_object(Testament.populate(name=u'Apocrypha')) - ''' - def create_book(self, name, bk_ref_id, testament=1): """ Add a book to the database. diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index 9b65bb8d8..47f512961 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -91,8 +91,6 @@ class OSISBible(BibleDB): osis = None success = True last_chapter = 0 - #TODO: Delete unused code - #testament = 1 match_count = 0 self.wizard.incrementProgressBar(translate('BiblesPlugin.OsisImport', 'Detecting encoding (this may take a few minutes)...')) @@ -125,9 +123,6 @@ class OSISBible(BibleDB): verse_text = match.group(4) if not db_book or db_book.name != self.books[book][0]: log.debug(u'New book: "%s"' % self.books[book][0]) - #TODO: Delete unused code - #if book == u'Matt' or book == u'Jdt': - # testament += 1 book_ref_id = self.get_book_ref_id_by_name( unicode(self.books[book][0]), language_id) if not book_ref_id: From 23c8ea867948f24b1e752aae0dbbc853d4186338 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sat, 16 Apr 2011 13:52:20 +0200 Subject: [PATCH 24/97] small cleanups --- openlp/plugins/bibles/lib/csvbible.py | 4 ++-- openlp/plugins/bibles/lib/db.py | 7 ++++--- openlp/plugins/bibles/lib/http.py | 4 ++-- openlp/plugins/bibles/lib/manager.py | 5 +++-- openlp/plugins/bibles/lib/openlp1.py | 4 ++-- openlp/plugins/bibles/lib/opensong.py | 4 ++-- openlp/plugins/bibles/lib/osis.py | 4 ++-- 7 files changed, 17 insertions(+), 15 deletions(-) diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index be45bfeb9..80216a73e 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -101,7 +101,7 @@ class CSVBible(BibleDB): success = True language_id = self.get_language() if not language_id: - log.exception(u'Importing books from %s " '\ + log.exception(u'Importing books from "%s" '\ 'failed' % self.filename) return False books_file = None @@ -120,7 +120,7 @@ class CSVBible(BibleDB): book_ref_id = self.get_book_ref_id_by_name( unicode(line[2], details['encoding']), language_id) if not book_ref_id: - log.exception(u'Importing books from %s " '\ + log.exception(u'Importing books from "%s" '\ 'failed' % self.booksfile) return False book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 4afc5bccf..617832d33 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -618,7 +618,8 @@ class BiblesResourcesDB(QtCore.QObject, Manager): ``chapter`` The chapter number. """ - log.debug(u'BiblesResourcesDB.get_chapter("%s", "%s")', book_id, chapter) + log.debug(u'BiblesResourcesDB.get_chapter("%s", "%s")', book_id, + chapter) if not isinstance(chapter, int): chapter = int(chapter) chapters = BiblesResourcesDB.run_sql(u'SELECT id, book_reference_id, ' @@ -770,8 +771,8 @@ class BiblesResourcesDB(QtCore.QObject, Manager): u'= ? ORDER BY id', (name, language_id)) else: id = BiblesResourcesDB.run_sql(u'SELECT book_reference_id ' - u'FROM alternative_book_names WHERE name = ? ORDER BY id', ( - name, )) + u'FROM alternative_book_names WHERE name = ? ORDER BY id', + (name, )) if id: return int(id[0][0]) else: diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index a9f31a3ea..9795b0120 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -147,8 +147,8 @@ class BGExtract(object): return None page_source = page.read() page_source = unicode(page_source, 'utf8') - page_source_temp = re.search(u'.*?
', \ - page_source, re.DOTALL) + page_source_temp = re.search(u'.*?
', \ + page_source, re.DOTALL) if page_source_temp: soup = page_source_temp.group(0) else: diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index dd1669b23..cab665179 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -214,7 +214,8 @@ class BibleManager(object): books.append( { u'name': book.name, - u'chapters': self.db_cache[bible].get_chapter_count(book.book_reference_id) + u'chapters': self.db_cache[bible].get_chapter_count( + book.book_reference_id) }) return books @@ -222,7 +223,7 @@ class BibleManager(object): """ Returns the number of Chapters for a given book. """ - log.debug(u'BibleManager.get_book_chapter_count ("%s", "%s")', bible, + log.debug(u'BibleManager.get_book_chapter_count ("%s", "%s")', bible, book) return self.db_cache[bible].get_chapter_count(book) diff --git a/openlp/plugins/bibles/lib/openlp1.py b/openlp/plugins/bibles/lib/openlp1.py index 0ef5f95a9..0ed22797e 100644 --- a/openlp/plugins/bibles/lib/openlp1.py +++ b/openlp/plugins/bibles/lib/openlp1.py @@ -59,7 +59,7 @@ class OpenLP1Bible(BibleDB): #Create the bible language language_id = self.get_language() if not language_id: - log.exception(u'Importing books from %s " '\ + log.exception(u'Importing books from "%s " '\ 'failed' % self.filename) return False # Create all books. @@ -76,7 +76,7 @@ class OpenLP1Bible(BibleDB): abbreviation = unicode(book[3], u'cp1252') book_ref_id = self.get_book_ref_id_by_name(name, language_id) if not book_ref_id: - log.exception(u'Importing books from %s " '\ + log.exception(u'Importing books from "%s" '\ 'failed' % self.filename) return False book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) diff --git a/openlp/plugins/bibles/lib/opensong.py b/openlp/plugins/bibles/lib/opensong.py index cb971fa99..fd79cd440 100644 --- a/openlp/plugins/bibles/lib/opensong.py +++ b/openlp/plugins/bibles/lib/opensong.py @@ -63,7 +63,7 @@ class OpenSongBible(BibleDB): bible = opensong.getroot() language_id = self.get_language() if not language_id: - log.exception(u'Importing books from %s " '\ + log.exception(u'Importing books from "%s" '\ 'failed' % self.filename) return False for book in bible.b: @@ -72,7 +72,7 @@ class OpenSongBible(BibleDB): book_ref_id = self.get_book_ref_id_by_name( unicode(book.attrib[u'n']), language_id) if not book_ref_id: - log.exception(u'Importing books from %s " '\ + log.exception(u'Importing books from "%s" '\ 'failed' % self.filename) return False book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index 47f512961..e3dea40ce 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -106,7 +106,7 @@ class OSISBible(BibleDB): # Set meta language_id language_id = self.get_language() if not language_id: - log.exception(u'Importing books from %s " '\ + log.exception(u'Importing books from "%s" '\ 'failed' % self.filename) return False try: @@ -126,7 +126,7 @@ class OSISBible(BibleDB): book_ref_id = self.get_book_ref_id_by_name( unicode(self.books[book][0]), language_id) if not book_ref_id: - log.exception(u'Importing books from %s " '\ + log.exception(u'Importing books from "%s" '\ 'failed' % self.filename) return False book_details = BiblesResourcesDB.get_book_by_id( From e8c2d7e805c79d4191409582495c214bde301f10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Tue, 19 Apr 2011 22:25:27 +0200 Subject: [PATCH 25/97] add reimportwizard for older bible databases --- openlp/plugins/bibles/bibleplugin.py | 33 +- openlp/plugins/bibles/forms/__init__.py | 1 + .../plugins/bibles/forms/biblereimportform.py | 697 ++++++++++++++++++ openlp/plugins/bibles/lib/db.py | 122 +++ openlp/plugins/bibles/lib/mediaitem.py | 12 +- resources/images/bibles_reimport_alert.png | Bin 0 -> 762 bytes 6 files changed, 862 insertions(+), 3 deletions(-) create mode 100644 openlp/plugins/bibles/forms/biblereimportform.py create mode 100644 resources/images/bibles_reimport_alert.png diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 5a631bf00..13b5924d7 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -58,6 +58,7 @@ class BiblePlugin(Plugin): #action_list.add_action(self.exportBibleItem, UiStrings().Export) # Set to invisible until we can export bibles self.exportBibleItem.setVisible(False) + self.toolsReimportItem.setVisible(True) def finalise(self): """ @@ -87,6 +88,36 @@ class BiblePlugin(Plugin): export_menu.addAction(self.exportBibleItem) self.exportBibleItem.setVisible(False) + def addToolsMenuItem(self, tools_menu): + """ + Give the alerts plugin the opportunity to add items to the + **Tools** menu. + + ``tools_menu`` + The actual **Tools** menu item, so that your actions can + use it as their parent. + """ + log.info(u'add tools menu') + self.toolsReimportItem = QtGui.QAction(tools_menu) + self.toolsReimportItem.setObjectName(u'toolsReimportItem') + self.toolsReimportItem.setText( + translate('BiblePlugin', 'Re-&import older bible databases')) + self.toolsReimportItem.setStatusTip( + translate('BiblePlugin', 'Re-import the bible databases to addapt ' + 'the database scheme.')) + tools_menu.addAction(self.toolsReimportItem) + QtCore.QObject.connect(self.toolsReimportItem, + QtCore.SIGNAL(u'triggered()'), self.onToolsReimportItemTriggered) + self.toolsReimportItem.setVisible(False) + + def onToolsReimportItemTriggered(self): + """ + Re-import older bible databases. + """ + #self.manager.import_old_bible_databases() + if self.mediaItem: + self.mediaItem.onReImportClick() + def onBibleImportClick(self): if self.mediaItem: self.mediaItem.onImportClick() @@ -146,4 +177,4 @@ class BiblePlugin(Plugin): u'service': translate('BiblesPlugin', 'Add the selected Bible to the service') } - self.setPluginUiTextStrings(tooltips) \ No newline at end of file + self.setPluginUiTextStrings(tooltips) diff --git a/openlp/plugins/bibles/forms/__init__.py b/openlp/plugins/bibles/forms/__init__.py index 561944563..bd7ba3828 100644 --- a/openlp/plugins/bibles/forms/__init__.py +++ b/openlp/plugins/bibles/forms/__init__.py @@ -53,5 +53,6 @@ from the .ui files later if necessary. from booknameform import BookNameForm from languageform import LanguageForm from bibleimportform import BibleImportForm +from biblereimportform import BibleReImportForm __all__ = ['BibleImportForm'] diff --git a/openlp/plugins/bibles/forms/biblereimportform.py b/openlp/plugins/bibles/forms/biblereimportform.py new file mode 100644 index 000000000..5a311f017 --- /dev/null +++ b/openlp/plugins/bibles/forms/biblereimportform.py @@ -0,0 +1,697 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2011 Raoul Snyman # +# Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael # +# Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin Köhler, # +# Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund # +# --------------------------------------------------------------------------- # +# 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 # +############################################################################### +""" +The bible import functions for OpenLP +""" +import logging +import os +import os.path +import re + +from PyQt4 import QtCore, QtGui + +from openlp.core.lib import Receiver, SettingsManager, translate +from openlp.core.lib.db import delete_database +from openlp.core.lib.ui import UiStrings, critical_error_message_box +from openlp.core.ui.wizard import OpenLPWizard, WizardStrings +from openlp.core.utils import AppLocation, delete_file +from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta, OldBibleDB,\ + BiblesResourcesDB +from openlp.plugins.bibles.lib.http import BSExtract, BGExtract, CWExtract + +log = logging.getLogger(__name__) + + +class BibleReImportForm(OpenLPWizard): + """ + This is the Bible ReImport Wizard, which allows easy importing of Bibles + into OpenLP from older OpenLP2 database versions. + """ + log.info(u'BibleReImportForm loaded') + + def __init__(self, parent, manager, bibleplugin): + """ + Instantiate the wizard, and run any extra setup we need to. + + ``parent`` + The QWidget-derived parent of the wizard. + + ``manager`` + The Bible manager. + + ``bibleplugin`` + The Bible plugin. + """ + self.manager = manager + self.parent = parent + self.suffix = u'.sqlite' + self.settingsSection = u'bibles/bibles' + self.oldsettingsSection = u'bibles' + self.oldpath = AppLocation.get_section_data_path( + self.oldsettingsSection) + self.newpath = AppLocation.get_section_data_path( + self.settingsSection) + self.files = SettingsManager.get_files(self.oldsettingsSection, + self.suffix) + self.success = {} + self.newbibles = {} + self.maxBibles = len(self.files) + self.stop_import_flag = False + OpenLPWizard.__init__(self, parent, bibleplugin, u'bibleImportWizard', + u':/wizards/wizard_importbible.bmp') + + def setupUi(self, image): + """ + Set up the UI for the bible wizard. + """ + OpenLPWizard.setupUi(self, image) + QtCore.QObject.connect(Receiver.get_receiver(), + QtCore.SIGNAL(u'openlp_stop_wizard'), self.stop_import) + + def stop_import(self): + """ + Stops the import of the Bible. + """ + log.debug(u'Stopping import') + self.stop_import_flag = True + + def clean_filename(self, old_filename): + """ + Clean up the version name of the Bible and convert it into a valid + file name. + + ``old_filename`` + The "dirty" file name or version name. + """ + if not isinstance(old_filename, unicode): + old_filename = unicode(old_filename, u'utf-8') + old_filename = re.sub(r'[^\w]+', u'_', old_filename).strip(u'_') + return old_filename + u'.sqlite' + + def onCheckBoxIndexChanged(self, index): + ''' + Some cleanup while finishing + ''' + for number, filename in enumerate(self.files): + if not self.checkBox[number].checkState() == 2: + self.verticalWidget[number].hide() + self.formWidget[number].hide() + else: + if os.path.exists(os.path.join(self.newpath, filename)): + self.verticalWidget[number].setVisible(1) + self.formWidget[number].setVisible(1) + + def reject(self): + """ + Stop the wizard on cancel button, close button or ESC key. + """ + log.debug(u'Wizard cancelled by user') + if self.currentPage() == self.progressPage: + Receiver.send_message(u'openlp_stop_wizard') + for bible in self.newbibles.itervalues(): + delete_database(self.newpath, bible.clean_filename( + bible.get_name())) + self.done(QtGui.QDialog.Rejected) + + def onCurrentIdChanged(self, pageId): + """ + Perform necessary functions depending on which wizard page is active. + """ + if self.page(pageId) == self.progressPage: + self.preWizard() + self.performWizard() + self.postWizard() + elif self.page(pageId) == self.selectPage and self.maxBibles == 0: + self.next() + + def onFinishButton(self): + ''' + Some cleanup while finishing + ''' + if self.deleteCheckBox.checkState() == 2 or \ + self.deleteAllCheckBox.checkState() == 2: + for number, filename in enumerate(self.files): + if self.deleteAllCheckBox.checkState() == 2 or \ + (self.checkBox[number].checkState() == 2 and \ + self.success[number] == True): + delete_file(os.path.join(self.oldpath, filename)) + + def customInit(self): + """ + Perform any custom initialisation for bible importing. + """ + self.manager.set_process_dialog(self) + self.restart() + + def customSignals(self): + """ + Set up the signals used in the bible importer. + """ + for number, filename in enumerate(self.files): + QtCore.QObject.connect(self.checkBox[number], + QtCore.SIGNAL(u'stateChanged(int)'), + self.onCheckBoxIndexChanged) + QtCore.QObject.connect(self.finishButton, + QtCore.SIGNAL(u'clicked()'), self.onFinishButton) + + def addCustomPages(self): + """ + Add the bible import specific wizard pages. + """ + self.selectPage = QtGui.QWizardPage() + self.selectPage.setObjectName(u'SelectPage') + self.pageLayout = QtGui.QVBoxLayout(self.selectPage) + self.pageLayout.setObjectName(u'pageLayout') + self.scrollArea = QtGui.QScrollArea(self.selectPage) + self.scrollArea.setWidgetResizable(True) + self.scrollArea.setObjectName(u'scrollArea') + self.scrollArea.setHorizontalScrollBarPolicy( + QtCore.Qt.ScrollBarAlwaysOff) + self.scrollAreaContents = QtGui.QWidget(self.scrollArea) + self.scrollAreaContents.setObjectName(u'scrollAreaContents') + self.formLayout = QtGui.QVBoxLayout(self.scrollAreaContents) + self.formLayout.setSpacing(2) + self.formLayout.setObjectName(u'formLayout') + self.addScrollArea() + self.pageLayout.addWidget(self.scrollArea) + self.addPage(self.selectPage) + + def addScrollArea(self): + """ + Add the content to the scrollArea. + """ + self.checkBox = {} + self.versionNameEdit = {} + self.versionNameLabel = {} + self.versionInfoLabel = {} + self.versionInfoPixmap = {} + self.verticalWidget = {} + self.horizontalLayout = {} + self.formWidget = {} + self.formLayoutAttention = {} + for number, filename in enumerate(self.files): + bible = OldBibleDB(self.parent, path=self.oldpath, file=filename) + self.checkBox[number] = QtGui.QCheckBox(self.scrollAreaContents) + checkBoxName = u'checkBox['+unicode(number)+u']' + self.checkBox[number].setObjectName(checkBoxName) + self.checkBox[number].setText(bible.get_name()) + self.checkBox[number].setCheckState(2) + self.formLayout.addWidget(self.checkBox[number]) + self.verticalWidget[number] = QtGui.QWidget(self.scrollAreaContents) + verticalWidgetName = u'verticalWidget['+unicode(number)+u']' + self.verticalWidget[number].setObjectName(verticalWidgetName) + self.horizontalLayout[number] = QtGui.QHBoxLayout( + self.verticalWidget[number]) + self.horizontalLayout[number].setContentsMargins(25, 0, 0, 0) + horizontalLayoutName = u'horizontalLayout['+unicode(number)+u']' + self.horizontalLayout[number].setObjectName(horizontalLayoutName) + self.versionInfoPixmap[number] = QtGui.QLabel( + self.verticalWidget[number]) + versionInfoPixmapName = u'versionInfoPixmap['+unicode(number)+u']' + self.versionInfoPixmap[number].setObjectName(versionInfoPixmapName) + self.versionInfoPixmap[number].setPixmap(QtGui.QPixmap( + u':/plugins/plugin_alerts.png')) + #u':/bibles/bibles_reimport_alert.png')) + self.versionInfoPixmap[number].setAlignment(QtCore.Qt.AlignRight) + self.horizontalLayout[number].addWidget( + self.versionInfoPixmap[number]) + self.versionInfoLabel[number] = QtGui.QLabel( + self.verticalWidget[number]) + versionInfoLabelName = u'versionInfoLabel['+unicode(number)+u']' + self.versionInfoLabel[number].setObjectName(versionInfoLabelName) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, + QtGui.QSizePolicy.Preferred) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth( + self.versionInfoLabel[number].sizePolicy().hasHeightForWidth()) + self.versionInfoLabel[number].setSizePolicy(sizePolicy) + self.horizontalLayout[number].addWidget( + self.versionInfoLabel[number]) + self.formLayout.addWidget(self.verticalWidget[number]) + self.formWidget[number] = QtGui.QWidget(self.scrollAreaContents) + formWidgetName = u'formWidget['+unicode(number)+u']' + self.formWidget[number].setObjectName(formWidgetName) + self.formLayoutAttention[number] = QtGui.QFormLayout( + self.formWidget[number]) + self.formLayoutAttention[number].setContentsMargins(25, 0, 0, 5) + formLayoutAttentionName = u'formLayoutAttention['+unicode(number)+\ + u']' + self.formLayoutAttention[number].setObjectName( + formLayoutAttentionName) + self.versionNameLabel[number] = QtGui.QLabel( + self.formWidget[number]) + self.versionNameLabel[number].setObjectName(u'VersionNameLabel') + self.formLayoutAttention[number].setWidget(0, + QtGui.QFormLayout.LabelRole, self.versionNameLabel[number]) + self.versionNameEdit[number] = QtGui.QLineEdit( + self.formWidget[number]) + self.versionNameEdit[number].setObjectName(u'VersionNameEdit') + self.formLayoutAttention[number].setWidget(0, + QtGui.QFormLayout.FieldRole, self.versionNameEdit[number]) + self.versionNameEdit[number].setText(bible.get_name()) + self.formLayout.addWidget(self.formWidget[number]) + self.spacerItem = QtGui.QSpacerItem(20, 5, QtGui.QSizePolicy.Minimum, + QtGui.QSizePolicy.Expanding) + self.formLayout.addItem(self.spacerItem) + self.scrollArea.setWidget(self.scrollAreaContents) + + def clearScrollArea(self): + """ + Remove the content from the scrollArea. + """ + for number, filename in enumerate(self.files): + self.formLayout.removeWidget(self.checkBox[number]) + self.checkBox[number].setParent(None) + self.horizontalLayout[number].removeWidget( + self.versionInfoPixmap[number]) + self.versionInfoPixmap[number].setParent(None) + self.horizontalLayout[number].removeWidget( + self.versionInfoLabel[number]) + self.versionInfoLabel[number].setParent(None) + self.formLayout.removeWidget(self.verticalWidget[number]) + self.verticalWidget[number].setParent(None) + self.formLayoutAttention[number].removeWidget( + self.versionNameLabel[number]) + self.versionNameLabel[number].setParent(None) + self.formLayoutAttention[number].removeWidget( + self.versionNameEdit[number]) + self.formLayoutAttention[number].deleteLater() + self.versionNameEdit[number].setParent(None) + self.formLayout.removeWidget(self.formWidget[number]) + self.formWidget[number].setParent(None) + self.formLayout.removeItem(self.spacerItem) + + def addProgressPage(self): + """ + Add the progress page for the wizard. This page informs the user how + the wizard is progressing with its task. + """ + OpenLPWizard.addProgressPage(self) + self.progressLayout.setContentsMargins(48, 30, 48, 30) + self.progressLabelAfter = QtGui.QLabel(self.progressPage) + self.progressLabelAfter.setObjectName(u'progressLabelAfter') + self.progressLayout.addWidget(self.progressLabelAfter) + self.deleteCheckBox = QtGui.QCheckBox(self.progressPage) + self.deleteCheckBox.setObjectName(u'deleteCheckBox') + self.progressLayout.addWidget(self.deleteCheckBox) + self.deleteAllCheckBox = QtGui.QCheckBox(self.progressPage) + self.deleteAllCheckBox.setObjectName(u'deleteAllCheckBox') + self.progressLayout.addWidget(self.deleteAllCheckBox) + + def retranslateUi(self): + """ + Allow for localisation of the bible import wizard. + """ + self.setWindowTitle(translate('BiblesPlugin.ReImportWizardForm', + 'Bible ReImport Wizard')) + self.titleLabel.setText(WizardStrings.HeaderStyle % + translate('OpenLP.Ui', 'Welcome to the Bible ReImport Wizard')) + self.informationLabel.setText( + translate('BiblesPlugin.ReImportWizardForm', + 'This wizard will help you to reimport your existing Bibles from a ' + 'prior version of OpenLP 2. Click the next button below to start ' + 'the process by selecting the bibles to reimport.')) + self.selectPage.setTitle( + translate('BiblesPlugin.ReImportWizardForm', + 'Please choose')) + self.selectPage.setSubTitle( + translate('BiblesPlugin.ReImportWizardForm', + 'Please choose the bibles which should be reimported')) + for number, bible in enumerate(self.files): + self.versionNameLabel[number].setText( + translate('BiblesPlugin.ReImportWizardForm', 'Version name:')) + self.versionInfoLabel[number].setText( + translate('BiblesPlugin.ReImportWizardForm', 'This ' + 'bible still exists. Please change the name or uncheck it.')) + self.progressPage.setTitle(WizardStrings.Importing) + self.progressPage.setSubTitle( + translate('BiblesPlugin.ReImportWizardForm', + 'Please wait while your Bibles are imported.')) + self.progressLabel.setText(WizardStrings.Ready) + self.progressBar.setFormat(u'%p%') + self.deleteCheckBox.setText( + translate('BiblesPlugin.ReImportWizardForm', 'Delete old bible ' + 'database(s) from bibles which was imported\nsucessful right now')) + self.deleteAllCheckBox.setText( + translate('BiblesPlugin.ReImportWizardForm', 'Delete all old bible ' + 'database(s) (including not imported bibles)')) + self.progressLabelAfter.setText( + translate('BiblesPlugin.ReImportWizardForm', '\nIf OpenLP should ' + 'delete the old bible databases please choose:')) + + def validateCurrentPage(self): + """ + Validate the current page before moving on to the next page. + """ + if self.currentPage() == self.welcomePage: + return True + elif self.currentPage() == self.selectPage: + for number, filename in enumerate(self.files): + if not self.checkBox[number].checkState() == 2: + continue + version_name = unicode(self.versionNameEdit[number].text()) + oldbible = OldBibleDB(self.parent, path=self.oldpath, + file=filename) + oldname = oldbible.get_name() + if not version_name: + critical_error_message_box(UiStrings().EmptyField, + translate('BiblesPlugin.ReImportWizardForm', + 'You need to specify a version name for your Bible.')) + self.versionNameEdit[number].setFocus() + return False + elif self.manager.exists(version_name): + critical_error_message_box( + translate('BiblesPlugin.ReImportWizardForm', + 'Bible Exists'), + translate('BiblesPlugin.ReImportWizardForm', + 'This Bible already exists. Please import ' + 'a different Bible, delete the existing one or ' + 'uncheck.')) + self.versionNameEdit[number].setFocus() + return False + elif os.path.exists(os.path.join(self.newpath, filename)) and \ + version_name == oldname: + critical_error_message_box( + translate('BiblesPlugin.ReImportWizardForm', + 'Bible Exists'), + translate('BiblesPlugin.ReImportWizardForm', + 'This Bible already exists. Please import ' + 'a different Bible, delete the existing one or ' + 'uncheck.')) + self.versionNameEdit[number].setFocus() + return False + elif os.path.exists(os.path.join(self.newpath, + self.clean_filename(version_name))): + critical_error_message_box( + translate('BiblesPlugin.ReImportWizardForm', + 'Bible Exists'), + translate('BiblesPlugin.ReImportWizardForm', + 'This Bible already exists. Please import ' + 'a different Bible, delete the existing one or ' + 'uncheck.')) + self.versionNameEdit[number].setFocus() + return False + return True + if self.currentPage() == self.progressPage: + return True + + def setDefaults(self): + """ + Set default values for the wizard pages. + """ + log.debug(u'BibleReImport setDefaults') + settings = QtCore.QSettings() + settings.beginGroup(self.plugin.settingsSection) + self.stop_import_flag = False + self.success.clear() + self.newbibles.clear() + self.clearScrollArea() + self.files = SettingsManager.get_files(self.oldsettingsSection, + self.suffix) + self.addScrollArea() + self.customSignals() + self.retranslateUi() + self.maxBibles = len(self.files) + self.finishButton.setVisible(False) + self.cancelButton.setVisible(True) + for number, filename in enumerate(self.files): + self.checkBox[number].setCheckState(2) + if os.path.exists(os.path.join(self.newpath, filename)): + self.verticalWidget[number].setVisible(1) + self.formWidget[number].setVisible(1) + else: + self.verticalWidget[number].hide() + self.formWidget[number].hide() + self.progressLabelAfter.hide() + self.deleteCheckBox.hide() + self.deleteCheckBox.setCheckState(0) + self.deleteAllCheckBox.hide() + self.deleteAllCheckBox.setCheckState(0) + self.restart() + settings.endGroup() + + def preWizard(self): + """ + Prepare the UI for the import. + """ + OpenLPWizard.preWizard(self) + self.progressLabel.setText(translate( + 'BiblesPlugin.ImportWizardForm', + 'Starting Importing bible...')) + Receiver.send_message(u'openlp_process_events') + + def performWizard(self): + """ + Perform the actual import. + """ + include_webbible = False + proxy_server = None + if self.maxBibles == 0: + self.progressLabel.setText( + translate('BiblesPlugin.ReImportWizardForm', 'Sorry, but OpenLP' + ' could not find a Bible to reimport.')) + self.progressBar.hide() + return + self.maxBibles = 0 + for number, file in enumerate(self.files): + if self.checkBox[number].checkState() == 2: + self.maxBibles += 1 + number = 0 + for biblenumber, filename in enumerate(self.files): + bible_failed = False + self.success[biblenumber] = False + if not self.checkBox[biblenumber].checkState() == 2: + continue + self.progressBar.reset() + oldbible = OldBibleDB(self.parent, path=self.oldpath, file=filename) + name = oldbible.get_name() + if name is None: + delete_file(os.path.join(self.oldpath, filename)) + self.incrementProgressBar(unicode(translate( + 'BiblesPlugin.ReImportWizardForm', + 'Reimporting Bible %s of %s: "%s"\nFailed')) % + (number+1, self.maxBibles, name), + self.progressBar.maximum()-self.progressBar.value()) + number += 1 + continue + self.progressLabel.setText(unicode(translate( + 'BiblesPlugin.ReImportWizardForm', + 'Reimporting Bible %s of %s: "%s"\nImporting ...')) % + (number+1, self.maxBibles, name)) + if os.path.exists(os.path.join(self.newpath, filename)): + name = unicode(self.versionNameEdit[biblenumber].text()) + self.newbibles[number] = BibleDB(self.parent, path=self.oldpath, + name=name) + metadata = oldbible.get_metadata() + webbible = False + meta_data = {} + for meta in metadata: + meta_data[meta[u'key']] = meta[u'value'] + if not meta[u'key'] == u'Version': + self.newbibles[number].create_meta(meta[u'key'], + meta[u'value']) + else: + self.newbibles[number].create_meta(meta[u'key'], name) + if meta[u'key'] == u'download source': + webbible = True + include_webbible = True + if meta.has_key(u'proxy server'): + proxy_server = meta[u'proxy server'] + if webbible: + if meta_data[u'download source'].lower() == u'crosswalk': + handler = CWExtract(proxy_server) + elif meta_data[u'download source'].lower() == u'biblegateway': + handler = BGExtract(proxy_server) + elif meta_data[u'download source'].lower() == u'bibleserver': + handler = BSExtract(proxy_server) + books = handler.get_books_from_http(meta_data[u'download name']) + if not books: + log.exception(u'Importing books from %s - download '\ + u'name: "%s" failed' % ( + meta_data[u'download source'], + meta_data[u'download name'])) + delete_database(self.newpath, self.newbibles[number].\ + clean_filename(self.newbibles[number].get_name())) + del self.newbibles[number] + critical_error_message_box( + translate('BiblesPlugin.ReImportWizardForm', + 'Download Error'), + translate('BiblesPlugin.ReImportWizardForm', + 'To Re-Import your webbibles a Internet connection is ' + 'necessary. Please check your Internet connection, and ' + 'if this error continues to occur please consider ' + 'reporting a bug.')) + self.incrementProgressBar(unicode(translate( + 'BiblesPlugin.ReImportWizardForm', + 'Reimporting Bible %s of %s: "%s"\nFailed')) % + (number+1, self.maxBibles, name), + self.progressBar.maximum()-self.progressBar.value()) + number += 1 + continue + bible = BiblesResourcesDB.get_webbible( + meta_data[u'download name'], + meta_data[u'download source'].lower()) + if bible[u'language_id']: + language_id = bible[u'language_id'] + self.newbibles[number].create_meta(u'language_id', + language_id) + else: + language_id = self.newbibles[number].get_language() + if not language_id: + log.exception(u'Re-Importing from "%s" '\ + 'failed' % filename) + delete_database(self.newpath, self.newbibles[number].\ + clean_filename(self.newbibles[number].get_name())) + del self.newbibles[number] + self.incrementProgressBar(unicode(translate( + 'BiblesPlugin.ReImportWizardForm', + 'Reimporting Bible %s of %s: "%s"\nFailed')) % + (number+1, self.maxBibles, name), + self.progressBar.maximum()-self.progressBar.value()) + number += 1 + continue + self.progressBar.setMaximum(len(books)) + for book in books: + self.incrementProgressBar(unicode(translate( + 'BiblesPlugin.ReImportWizardForm', + 'Reimporting Bible %s of %s: "%s"\n' + 'Importing %s ...')) % + (number+1, self.maxBibles, name, book)) + book_ref_id = self.newbibles[number].\ + get_book_ref_id_by_name(book, language_id) + if not book_ref_id: + log.exception(u'Importing books from %s - download '\ + u'name: "%s" aborted by user' % ( + meta_data[u'download source'], + meta_data[u'download name'])) + delete_database(self.newpath, self.newbibles[number].\ + clean_filename(self.newbibles[number].get_name())) + del self.newbibles[number] + bible_failed = True + break + book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) + self.newbibles[number].create_book(book, book_ref_id, + book_details[u'testament_id']) + else: + language_id = self.newbibles[number].get_object(BibleMeta, + u'language_id') + if not language_id: + language_id = self.newbibles[number].get_language() + if not language_id: + log.exception(u'Importing books from "%s" '\ + 'failed' % name) + delete_database(self.newpath, self.newbibles[number].\ + clean_filename(self.newbibles[number].get_name())) + del self.newbibles[number] + self.incrementProgressBar(unicode(translate( + 'BiblesPlugin.ReImportWizardForm', + 'Reimporting Bible %s of %s: "%s"\nFailed')) % + (number+1, self.maxBibles, name), + self.progressBar.maximum()-self.progressBar.value()) + number += 1 + continue + books = oldbible.get_books() + self.progressBar.setMaximum(len(books)) + for book in books: + self.incrementProgressBar(unicode(translate( + 'BiblesPlugin.ReImportWizardForm', + 'Reimporting Bible %s of %s: "%s"\n' + 'Importing %s ...')) % + (number+1, self.maxBibles, name, book[u'name'])) + book_ref_id = self.newbibles[number].\ + get_book_ref_id_by_name(book[u'name'], language_id) + if not book_ref_id: + log.exception(u'Importing books from %s " '\ + 'failed - aborted by user' % name) + delete_database(self.newpath, self.newbibles[number].\ + clean_filename(self.newbibles[number].get_name())) + del self.newbibles[number] + bible_failed = True + break + book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) + db_book = self.newbibles[number].create_book(book[u'name'], + book_ref_id, book_details[u'testament_id']) + verses = oldbible.get_verses(book[u'id']) + for verse in verses: + self.newbibles[number].create_verse(db_book.id, + int(verse[u'chapter']), + int(verse[u'verse']), unicode(verse[u'text'])) + Receiver.send_message(u'openlp_process_events') + if not bible_failed: + self.incrementProgressBar(unicode(translate( + 'BiblesPlugin.ReImportWizardForm', + 'Reimporting Bible %s of %s: "%s"\n' + 'Done')) % + (number+1, self.maxBibles, name)) + self.success[biblenumber] = True + else: + self.incrementProgressBar(unicode(translate( + 'BiblesPlugin.ReImportWizardForm', + 'Reimporting Bible %s of %s: "%s"\nFailed')) % + (number+1, self.maxBibles, name), + self.progressBar.maximum()-self.progressBar.value()) + number += 1 + self.parent.reloadBibles() + successful_import = 0 + failed_import = 0 + for number, success in self.success.iteritems(): + if success == True: + successful_import += 1 + elif success == False and self.checkBox[number].checkState() == 2: + failed_import += 1 + if failed_import > 0: + failed_import_text = u' And ' + unicode(failed_import) + \ + u' reimport fails.' + else: + failed_import_text = u'' + if successful_import > 0: + if include_webbible: + self.progressLabel.setText(unicode( + translate('BiblesPlugin.ReImportWizardForm', 'Reimport %s ' + 'bibles successful.%s\nPlease note, that verses from ' + 'webbibles will be downloaded\non demand and thus an ' + 'internet connection is required.')) % + (successful_import, failed_import_text)) + else: + self.progressLabel.setText(unicode( + translate('BiblesPlugin.ReImportWizardForm', 'Reimport %s ' + 'bibles successful.%s')) % (successful_import, + failed_import_text)) + self.deleteCheckBox.setVisible(1) + bibles = u'' + for bible in self.newbibles.itervalues(): + name = bible.get_name() + bibles += u'\n"' + name + u'"' + self.deleteCheckBox.setToolTip(unicode(translate( + 'BiblesPlugin.ReImportWizardForm', + 'Sucessful imported bible(s):%s')) % bibles) + else: + self.progressLabel.setText( + translate('BiblesPlugin.ReImportWizardForm', 'Reimport ' + 'failed.')) + self.progressLabelAfter.setVisible(1) + self.deleteAllCheckBox.setVisible(1) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 7b22b9483..6dd7b3cbc 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -931,3 +931,125 @@ class AlternativeBookNamesDB(QtCore.QObject, Manager): u'alternative_book_names(book_reference_id, language_id, name) ' u'VALUES (?, ?, ?)', (book_reference_id, language_id, name), True) return alternative_book_name + + +class OldBibleDB(QtCore.QObject, Manager): + """ + This class conects to the old bible databases to reimport them to the new + database scheme. + """ + cursor = None + + def __init__(self, parent, **kwargs): + """ + The constructor loads up the database and creates and initialises the + tables if the database doesn't exist. + + **Required keyword arguments:** + + ``path`` + The path to the bible database file. + + ``name`` + The name of the database. This is also used as the file name for + SQLite databases. + """ + log.info(u'OldBibleDB loaded') + QtCore.QObject.__init__(self) + if u'path' not in kwargs: + raise KeyError(u'Missing keyword argument "path".') + if u'file' not in kwargs: + raise KeyError(u'Missing keyword argument "file".') + if u'path' in kwargs: + self.path = kwargs[u'path'] + if u'file' in kwargs: + self.file = kwargs[u'file'] + + def get_cursor(self): + """ + Return the cursor object. Instantiate one if it doesn't exist yet. + """ + if self.cursor is None: + filepath = os.path.join(self.path, self.file) + conn = sqlite3.connect(filepath) + self.cursor = conn.cursor() + return self.cursor + + def run_sql(self, query, parameters=()): + """ + Run an SQL query on the database, returning the results. + + ``query`` + The actual SQL query to run. + + ``parameters`` + Any variable parameters to add to the query. + """ + cursor = self.get_cursor() + cursor.execute(query, parameters) + return cursor.fetchall() + + def get_name(self): + """ + Returns the version name of the Bible. + """ + version_name = self.run_sql(u'SELECT value FROM ' + u'metadata WHERE key = "Version"') + if version_name: + self.name = version_name[0][0] + else: + self.name = None + return self.name + + def get_metadata(self): + """ + Returns the metadata of the Bible. + """ + metadata = self.run_sql(u'SELECT key, value FROM metadata ' + u'ORDER BY rowid') + if metadata: + metadata_list = [] + for meta in metadata: + metadata_list.append({ + u'key': unicode(meta[0]), + u'value': unicode(meta[1]) + }) + else: + metadata_list = None + return metadata_list + + def get_books(self): + """ + Returns the books of the Bible. + """ + books = self.run_sql(u'SELECT name, id FROM book ORDER BY id') + if books: + book_list = [] + for book in books: + book_list.append({ + u'name': unicode(book[0]), + u'id':int(book[1]) + }) + else: + book_list = None + return book_list + + def get_verses(self, book_id): + """ + Returns the verses of the Bible. + """ + verses = self.run_sql(u'SELECT book_id, chapter, verse, text FROM ' + u'verse WHERE book_id = ? ORDER BY id', (book_id, )) + if verses: + verse_list = [] + for verse in verses: + verse_list.append({ + u'book_id': int(verse[0]), + u'chapter': int(verse[1]), + u'verse': int(verse[2]), + u'text': unicode(verse[3]) + }) + else: + verse_list = None + return verse_list + diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index bd7a5ae85..1b7bf90ce 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -33,7 +33,7 @@ from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \ from openlp.core.lib.searchedit import SearchEdit from openlp.core.lib.ui import UiStrings, add_widget_completer, \ media_item_combo_box, critical_error_message_box, find_and_set_in_combo_box -from openlp.plugins.bibles.forms import BibleImportForm +from openlp.plugins.bibles.forms import BibleImportForm, BibleReImportForm from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, \ VerseReferenceList, get_reference_match @@ -310,6 +310,14 @@ class BibleMediaItem(MediaManagerItem): if self.import_wizard.exec_(): self.reloadBibles() + def onReImportClick(self): + if not hasattr(self, u'import_wizard'): + self.import_wizard = BibleReImportForm(self, self.parent.manager, + self.parent) + # If the import was not cancelled then reload. + if self.import_wizard.exec_(): + self.reloadBibles() + def loadBibles(self): log.debug(u'Loading Bibles') self.quickVersionComboBox.clear() @@ -849,4 +857,4 @@ class BibleMediaItem(MediaManagerItem): self.settings.layout_style) QtCore.QSettings().setValue( self.settingsSection + u'/verse layout style', - QtCore.QVariant(self.settings.layout_style)) \ No newline at end of file + QtCore.QVariant(self.settings.layout_style)) diff --git a/resources/images/bibles_reimport_alert.png b/resources/images/bibles_reimport_alert.png new file mode 100644 index 0000000000000000000000000000000000000000..331aa268725a4edff3fa6cab7dfaf5af24708c2c GIT binary patch literal 762 zcmVz8xpUII{8&=iH{wnUDxx6o*XQpr9@S zFA7f~5wyArj)7engn2gzstbkiqQW4^o2U%CF~JzoO$Y@oEjOFGxwX#D=9!*z-Y(o0 zQwbk<`S`x?dETGrWkiIXV2m*U4FEj(r*8lvv=^C(b_IaeKp-$7%W^`Nt(9kFmQEb*nE7Psy^?IqR ztBayjPKwQXiHJy&qz3@_5)S~tZnyVDm%lIP5+5is35raDTrL;6T(06>jn7at{N)#b z6NTa?0O;-Qt@Qi-eRcKC_36+(fN|S~@H}|_-^lXUJE&`DvkeRkTqt;90$|BxGRLp` z`_FAAgHTsr1Ed20I-3=AHY>#hx%don>+f;v=GF56+8JZu1VM0DR8;s+oj!Xq`ROt= zB~%pnI#Td;q)OJLXMdu$eUO)BITH*9=a|Ri@x7aV`>56uZi>(Ll#p-S-98`QF5Pu? z_YC6M`lSYE%SBUFRn<|4v#}`^ewD>Op@g67c8A+32*R;4RaJ9_VQ3cj;Fel`NG<2K z4it!wpY0ZJYUYhH+a;BVtcGD|0MIfrGV&yqO2ufONT<`uv9Yli0FE#K41f(l8-N-B s|?9jsO4v literal 0 HcmV?d00001 From 81fe6f13e31c198f2d98190eb13c2e966d6cfaa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Wed, 20 Apr 2011 09:25:16 +0200 Subject: [PATCH 26/97] add attention picture --- openlp/plugins/bibles/forms/biblereimportform.py | 3 +-- resources/images/openlp-2.qrc | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/bibles/forms/biblereimportform.py b/openlp/plugins/bibles/forms/biblereimportform.py index 5a311f017..48af1c558 100644 --- a/openlp/plugins/bibles/forms/biblereimportform.py +++ b/openlp/plugins/bibles/forms/biblereimportform.py @@ -233,8 +233,7 @@ class BibleReImportForm(OpenLPWizard): versionInfoPixmapName = u'versionInfoPixmap['+unicode(number)+u']' self.versionInfoPixmap[number].setObjectName(versionInfoPixmapName) self.versionInfoPixmap[number].setPixmap(QtGui.QPixmap( - u':/plugins/plugin_alerts.png')) - #u':/bibles/bibles_reimport_alert.png')) + u':/bibles/bibles_reimport_alert.png')) self.versionInfoPixmap[number].setAlignment(QtCore.Qt.AlignRight) self.horizontalLayout[number].addWidget( self.versionInfoPixmap[number]) diff --git a/resources/images/openlp-2.qrc b/resources/images/openlp-2.qrc index 0d3191eff..f3bfd100e 100644 --- a/resources/images/openlp-2.qrc +++ b/resources/images/openlp-2.qrc @@ -24,6 +24,7 @@ bibles_search_text.png bibles_search_reference.png + bibles_reimport_alert.png plugin_alerts.png From b0b127022cc1e7c48b0d4558d505341615c606b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Wed, 20 Apr 2011 11:00:29 +0200 Subject: [PATCH 27/97] bug fixes add some additional Apocrypha books --- .../plugins/bibles/forms/bibleimportform.py | 24 ++++++++++++++++++ .../plugins/bibles/forms/biblereimportform.py | 11 ++++---- openlp/plugins/bibles/forms/booknameform.py | 3 +-- openlp/plugins/bibles/lib/mediaitem.py | 6 ++--- .../bibles/resources/bibles_resources.sqlite | Bin 101376 -> 101376 bytes 5 files changed, 34 insertions(+), 10 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 57a38538f..a85230611 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -30,6 +30,7 @@ import csv import logging import os import os.path +import re from PyQt4 import QtCore, QtGui @@ -471,6 +472,7 @@ class BibleImportForm(OpenLPWizard): license_version = unicode(self.field(u'license_version').toString()) license_copyright = \ unicode(self.field(u'license_copyright').toString()) + path = AppLocation.get_section_data_path(u'bibles/bibles') if not license_version: critical_error_message_box(UiStrings().EmptyField, translate('BiblesPlugin.ImportWizardForm', @@ -492,10 +494,32 @@ class BibleImportForm(OpenLPWizard): 'a different Bible or first delete the existing one.')) self.versionNameEdit.setFocus() return False + elif os.path.exists(os.path.join(path, self.clean_filename( + license_version))): + critical_error_message_box( + translate('BiblesPlugin.ImportWizardForm', 'Bible Exists'), + translate('BiblesPlugin.ImportWizardForm', + 'This Bible already exists. Please import ' + 'a different Bible or first delete the existing one.')) + self.versionNameEdit.setFocus() + return False return True if self.currentPage() == self.progressPage: return True + def clean_filename(self, old_filename): + """ + Clean up the version name of the Bible and convert it into a valid + file name. + + ``old_filename`` + The "dirty" file name or version name. + """ + if not isinstance(old_filename, unicode): + old_filename = unicode(old_filename, u'utf-8') + old_filename = re.sub(r'[^\w]+', u'_', old_filename).strip(u'_') + return old_filename + u'.sqlite' + def onWebSourceComboBoxIndexChanged(self, index): """ Setup the list of Bibles when you select a different source on the web diff --git a/openlp/plugins/bibles/forms/biblereimportform.py b/openlp/plugins/bibles/forms/biblereimportform.py index 48af1c558..5895f710a 100644 --- a/openlp/plugins/bibles/forms/biblereimportform.py +++ b/openlp/plugins/bibles/forms/biblereimportform.py @@ -310,7 +310,7 @@ class BibleReImportForm(OpenLPWizard): the wizard is progressing with its task. """ OpenLPWizard.addProgressPage(self) - self.progressLayout.setContentsMargins(48, 30, 48, 30) + self.progressLayout.setContentsMargins(48, 48, 48, 30) self.progressLabelAfter = QtGui.QLabel(self.progressPage) self.progressLabelAfter.setObjectName(u'progressLabelAfter') self.progressLayout.addWidget(self.progressLabelAfter) @@ -663,22 +663,23 @@ class BibleReImportForm(OpenLPWizard): elif success == False and self.checkBox[number].checkState() == 2: failed_import += 1 if failed_import > 0: - failed_import_text = u' And ' + unicode(failed_import) + \ - u' reimport fails.' + failed_import_text = unicode(translate( + 'BiblesPlugin.ReImportWizardForm', + ' - %s reimport fail')) % failed_import else: failed_import_text = u'' if successful_import > 0: if include_webbible: self.progressLabel.setText(unicode( translate('BiblesPlugin.ReImportWizardForm', 'Reimport %s ' - 'bibles successful.%s\nPlease note, that verses from ' + 'bible(s) successful%s.\nPlease note, that verses from ' 'webbibles will be downloaded\non demand and thus an ' 'internet connection is required.')) % (successful_import, failed_import_text)) else: self.progressLabel.setText(unicode( translate('BiblesPlugin.ReImportWizardForm', 'Reimport %s ' - 'bibles successful.%s')) % (successful_import, + 'bible(s) successful.%s')) % (successful_import, failed_import_text)) self.deleteCheckBox.setVisible(1) bibles = u'' diff --git a/openlp/plugins/bibles/forms/booknameform.py b/openlp/plugins/bibles/forms/booknameform.py index 58603226c..b8bdbb493 100644 --- a/openlp/plugins/bibles/forms/booknameform.py +++ b/openlp/plugins/bibles/forms/booknameform.py @@ -56,8 +56,7 @@ class BookNameForm(QDialog, Ui_BookNameDialog): def exec_(self, name): items = [] self.requestComboBox.addItem(u'') - self.requestLabel.setText( - translate('BiblesPlugin.BookNameForm', name)) + self.requestLabel.setText(name) items = BiblesResourcesDB.get_books() for item in items: self.requestComboBox.addItem(item[u'name']) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 1b7bf90ce..ec65a37d0 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -311,11 +311,11 @@ class BibleMediaItem(MediaManagerItem): self.reloadBibles() def onReImportClick(self): - if not hasattr(self, u'import_wizard'): - self.import_wizard = BibleReImportForm(self, self.parent.manager, + if not hasattr(self, u'reimport_wizard'): + self.reimport_wizard = BibleReImportForm(self, self.parent.manager, self.parent) # If the import was not cancelled then reload. - if self.import_wizard.exec_(): + if self.reimport_wizard.exec_(): self.reloadBibles() def loadBibles(self): diff --git a/openlp/plugins/bibles/resources/bibles_resources.sqlite b/openlp/plugins/bibles/resources/bibles_resources.sqlite index 23c89b5df80e39da39e81eb94cc6a0e9b8dd1474..4645fcf9ca76a4d0aecb2a5d227198e2f2a696bc 100644 GIT binary patch delta 1861 zcma)6du)?c6hDt{LtMugg>Bthx~&`C?7FslF(6|_!O^iN4q1YM!G=S|Fyo;i12@ru z2F==Q$YO}X0>MXQx)LL(iTEJkAAo=hiG&d}5J01dAx2R=x9uhp{;g-@W+dXUZL+Xg#9cqf%g4n9g#byL^j4C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CM- z2mCXhz+s-eQ6s#*#reSxap`^o+UgRSPWahg_x~H=6sr-MA2*ceY0;YBMqF5L7RM`0 zUaZ4xi=Fd`L!{?xryT&z)+OS(K}lcjad$|?HQNBRJj|lKWwRuq^t_C+_r(`w+`uio8OHfFzA!p`*o;TQ`L#|7)dDA) zBMIl!R;!$+m=^**GZJu{fq<*c;mHO(*VA%4JG@y+uJz^i0*7BHm6H3JcB(a-d1G^| z-fO;I?<(Ula9ziuZA4his`_fvAgi?AV)mtYB&{MH5Z4Ak2FmjWlIDDYwruEm4<=M%{&>sIbTYr;i}|(;T4zBGHE)UVy+I+6l5T~;})SxXsE@C zwYDXFOTiR#Y@g5U*;i?{$i7@wa9@R)zRzVY?yX*1$emCNR{;M)3uv|6H@4D)v>V^2 zr}z{dqc`b1eW>LoW227eb349*{~|wJ;Q{^%Hp%VcEq;Q(iJfSu1XH++-{lX@aJY0@ z9JnfJgP5ln&2wQ_eH`+t5*b*FVXZVxovS)N9)egFj)QG(qYakV6q}c074Ep8b(p2f zBQ~gU7UOD>=o72tj$#sx0cM+G>^Wvj^7aZzgz33Up3f@h%-qv4)dRPs z-%UnWO)V6zTFN(556mg#Mk<$1wS?Q#3lAK@(F65<)vZY;*e1{(t8y!}FJw^GB_bUf zdxX;8`r6&Rw1yS|wNZyu{D55R9-}dOj*io-l6=3S3A#l8V3xV);Q-H-EADc>le=h< z^utHwdN|65`9(gNZu`y|`Ety%ewAd7mP Date: Thu, 21 Apr 2011 16:32:04 +0200 Subject: [PATCH 28/97] little bug fix add check if openlp/bibles/resources directory exists and mkdir if not --- openlp/plugins/bibles/forms/biblereimportform.py | 1 + openlp/plugins/bibles/lib/db.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/openlp/plugins/bibles/forms/biblereimportform.py b/openlp/plugins/bibles/forms/biblereimportform.py index 5895f710a..3ca4966ba 100644 --- a/openlp/plugins/bibles/forms/biblereimportform.py +++ b/openlp/plugins/bibles/forms/biblereimportform.py @@ -445,6 +445,7 @@ class BibleReImportForm(OpenLPWizard): else: self.verticalWidget[number].hide() self.formWidget[number].hide() + self.progressBar.show() self.progressLabelAfter.hide() self.deleteCheckBox.hide() self.deleteCheckBox.setCheckState(0) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 6dd7b3cbc..c2b2fa1b1 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -849,6 +849,12 @@ class AlternativeBookNamesDB(QtCore.QObject, Manager): database doesn't exist. """ if AlternativeBookNamesDB.cursor is None: + if not os.path.exists(os.path.join( + AppLocation.get_directory(AppLocation.DataDir), u'bibles', + u'resources')): + os.mkdir(os.path.join( + AppLocation.get_directory(AppLocation.DataDir), u'bibles', + u'resources')) filepath = os.path.join( AppLocation.get_directory(AppLocation.DataDir), u'bibles', u'resources', u'alternative_book_names.sqlite') From d7dc4def5345639ed54ce6a75b9561243785eee2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Tue, 26 Apr 2011 20:18:13 +0200 Subject: [PATCH 29/97] change name from reimport to upgrade fix speed problem while changing the advanced bible change some "for" loops --- openlp/plugins/bibles/bibleplugin.py | 38 ++-- openlp/plugins/bibles/forms/__init__.py | 5 +- ...blereimportform.py => bibleupgradeform.py} | 169 +++++++++--------- openlp/plugins/bibles/lib/db.py | 154 ++++++++-------- openlp/plugins/bibles/lib/http.py | 15 +- openlp/plugins/bibles/lib/manager.py | 24 +-- openlp/plugins/bibles/lib/mediaitem.py | 10 +- ...ort_alert.png => bibles_upgrade_alert.png} | Bin resources/images/openlp-2.qrc | 2 +- 9 files changed, 207 insertions(+), 210 deletions(-) rename openlp/plugins/bibles/forms/{biblereimportform.py => bibleupgradeform.py} (84%) rename resources/images/{bibles_reimport_alert.png => bibles_upgrade_alert.png} (100%) diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 13b5924d7..a8a8fdf79 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -32,6 +32,7 @@ from openlp.core.lib import Plugin, StringContent, build_icon, translate from openlp.core.lib.ui import base_action, UiStrings from openlp.core.utils.actions import ActionList from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem +from openlp.plugins.bibles.forms import BibleUpgradeForm log = logging.getLogger(__name__) @@ -58,7 +59,7 @@ class BiblePlugin(Plugin): #action_list.add_action(self.exportBibleItem, UiStrings().Export) # Set to invisible until we can export bibles self.exportBibleItem.setVisible(False) - self.toolsReimportItem.setVisible(True) + self.toolsUpgradeItem.setVisible(True) def finalise(self): """ @@ -90,7 +91,7 @@ class BiblePlugin(Plugin): def addToolsMenuItem(self, tools_menu): """ - Give the alerts plugin the opportunity to add items to the + Give the bible plugin the opportunity to add items to the **Tools** menu. ``tools_menu`` @@ -98,25 +99,28 @@ class BiblePlugin(Plugin): use it as their parent. """ log.info(u'add tools menu') - self.toolsReimportItem = QtGui.QAction(tools_menu) - self.toolsReimportItem.setObjectName(u'toolsReimportItem') - self.toolsReimportItem.setText( - translate('BiblePlugin', 'Re-&import older bible databases')) - self.toolsReimportItem.setStatusTip( - translate('BiblePlugin', 'Re-import the bible databases to addapt ' + self.toolsUpgradeItem = QtGui.QAction(tools_menu) + self.toolsUpgradeItem.setObjectName(u'toolsUpgradeItem') + self.toolsUpgradeItem.setText( + translate('BiblePlugin', '&Upgrade older bible databases')) + self.toolsUpgradeItem.setStatusTip( + translate('BiblePlugin', 'Upgrade the bible databases to addapt ' 'the database scheme.')) - tools_menu.addAction(self.toolsReimportItem) - QtCore.QObject.connect(self.toolsReimportItem, - QtCore.SIGNAL(u'triggered()'), self.onToolsReimportItemTriggered) - self.toolsReimportItem.setVisible(False) + tools_menu.addAction(self.toolsUpgradeItem) + QtCore.QObject.connect(self.toolsUpgradeItem, + QtCore.SIGNAL(u'triggered()'), self.onToolsUpgradeItemTriggered) + self.toolsUpgradeItem.setVisible(False) - def onToolsReimportItemTriggered(self): + def onToolsUpgradeItemTriggered(self): """ - Re-import older bible databases. + Upgrade older bible databases. """ - #self.manager.import_old_bible_databases() - if self.mediaItem: - self.mediaItem.onReImportClick() + if not hasattr(self, u'upgrade_wizard'): + self.upgrade_wizard = BibleUpgradeForm(self.formparent, + self.manager, self) + # If the import was not cancelled then reload. + if self.upgrade_wizard.exec_(): + self.mediaItem.reloadBibles() def onBibleImportClick(self): if self.mediaItem: diff --git a/openlp/plugins/bibles/forms/__init__.py b/openlp/plugins/bibles/forms/__init__.py index bd7ba3828..2838a5101 100644 --- a/openlp/plugins/bibles/forms/__init__.py +++ b/openlp/plugins/bibles/forms/__init__.py @@ -53,6 +53,7 @@ from the .ui files later if necessary. from booknameform import BookNameForm from languageform import LanguageForm from bibleimportform import BibleImportForm -from biblereimportform import BibleReImportForm +from bibleupgradeform import BibleUpgradeForm -__all__ = ['BibleImportForm'] +__all__ = [u'BookNameForm', u'LanguageForm', u'BibleImportForm', + u'BibleUpgradeForm'] diff --git a/openlp/plugins/bibles/forms/biblereimportform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py similarity index 84% rename from openlp/plugins/bibles/forms/biblereimportform.py rename to openlp/plugins/bibles/forms/bibleupgradeform.py index 3ca4966ba..b64231195 100644 --- a/openlp/plugins/bibles/forms/biblereimportform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -45,12 +45,12 @@ from openlp.plugins.bibles.lib.http import BSExtract, BGExtract, CWExtract log = logging.getLogger(__name__) -class BibleReImportForm(OpenLPWizard): +class BibleUpgradeForm(OpenLPWizard): """ - This is the Bible ReImport Wizard, which allows easy importing of Bibles + This is the Bible Upgrade Wizard, which allows easy importing of Bibles into OpenLP from older OpenLP2 database versions. """ - log.info(u'BibleReImportForm loaded') + log.info(u'BibleUpgradeForm loaded') def __init__(self, parent, manager, bibleplugin): """ @@ -66,7 +66,7 @@ class BibleReImportForm(OpenLPWizard): The Bible plugin. """ self.manager = manager - self.parent = parent + self.mediaItem = bibleplugin.mediaItem self.suffix = u'.sqlite' self.settingsSection = u'bibles/bibles' self.oldsettingsSection = u'bibles' @@ -80,7 +80,7 @@ class BibleReImportForm(OpenLPWizard): self.newbibles = {} self.maxBibles = len(self.files) self.stop_import_flag = False - OpenLPWizard.__init__(self, parent, bibleplugin, u'bibleImportWizard', + OpenLPWizard.__init__(self, parent, bibleplugin, u'bibleUpgradeWizard', u':/wizards/wizard_importbible.bmp') def setupUi(self, image): @@ -113,7 +113,7 @@ class BibleReImportForm(OpenLPWizard): def onCheckBoxIndexChanged(self, index): ''' - Some cleanup while finishing + Show/ Hide warnings if CheckBox state has changed ''' for number, filename in enumerate(self.files): if not self.checkBox[number].checkState() == 2: @@ -121,8 +121,8 @@ class BibleReImportForm(OpenLPWizard): self.formWidget[number].hide() else: if os.path.exists(os.path.join(self.newpath, filename)): - self.verticalWidget[number].setVisible(1) - self.formWidget[number].setVisible(1) + self.verticalWidget[number].show() + self.formWidget[number].show() def reject(self): """ @@ -161,7 +161,7 @@ class BibleReImportForm(OpenLPWizard): def customInit(self): """ - Perform any custom initialisation for bible importing. + Perform any custom initialisation for bible upgrading. """ self.manager.set_process_dialog(self) self.restart() @@ -213,7 +213,7 @@ class BibleReImportForm(OpenLPWizard): self.formWidget = {} self.formLayoutAttention = {} for number, filename in enumerate(self.files): - bible = OldBibleDB(self.parent, path=self.oldpath, file=filename) + bible = OldBibleDB(self.mediaItem, path=self.oldpath, file=filename) self.checkBox[number] = QtGui.QCheckBox(self.scrollAreaContents) checkBoxName = u'checkBox['+unicode(number)+u']' self.checkBox[number].setObjectName(checkBoxName) @@ -233,7 +233,7 @@ class BibleReImportForm(OpenLPWizard): versionInfoPixmapName = u'versionInfoPixmap['+unicode(number)+u']' self.versionInfoPixmap[number].setObjectName(versionInfoPixmapName) self.versionInfoPixmap[number].setPixmap(QtGui.QPixmap( - u':/bibles/bibles_reimport_alert.png')) + u':/bibles/bibles_upgrade_alert.png')) self.versionInfoPixmap[number].setAlignment(QtCore.Qt.AlignRight) self.horizontalLayout[number].addWidget( self.versionInfoPixmap[number]) @@ -325,41 +325,41 @@ class BibleReImportForm(OpenLPWizard): """ Allow for localisation of the bible import wizard. """ - self.setWindowTitle(translate('BiblesPlugin.ReImportWizardForm', - 'Bible ReImport Wizard')) + self.setWindowTitle(translate('BiblesPlugin.UpgradeWizardForm', + 'Bible Upgrade Wizard')) self.titleLabel.setText(WizardStrings.HeaderStyle % - translate('OpenLP.Ui', 'Welcome to the Bible ReImport Wizard')) + translate('OpenLP.Ui', 'Welcome to the Bible Upgrade Wizard')) self.informationLabel.setText( - translate('BiblesPlugin.ReImportWizardForm', - 'This wizard will help you to reimport your existing Bibles from a ' + translate('BiblesPlugin.UpgradeWizardForm', + 'This wizard will help you to upgrade your existing Bibles from a ' 'prior version of OpenLP 2. Click the next button below to start ' - 'the process by selecting the bibles to reimport.')) + 'the process by selecting the bibles to upgrade.')) self.selectPage.setTitle( - translate('BiblesPlugin.ReImportWizardForm', + translate('BiblesPlugin.UpgradeWizardForm', 'Please choose')) self.selectPage.setSubTitle( - translate('BiblesPlugin.ReImportWizardForm', - 'Please choose the bibles which should be reimported')) + translate('BiblesPlugin.UpgradeWizardForm', + 'Please choose the bibles which should be upgraded')) for number, bible in enumerate(self.files): self.versionNameLabel[number].setText( - translate('BiblesPlugin.ReImportWizardForm', 'Version name:')) + translate('BiblesPlugin.UpgradeWizardForm', 'Version name:')) self.versionInfoLabel[number].setText( - translate('BiblesPlugin.ReImportWizardForm', 'This ' + translate('BiblesPlugin.UpgradeWizardForm', 'This ' 'bible still exists. Please change the name or uncheck it.')) self.progressPage.setTitle(WizardStrings.Importing) self.progressPage.setSubTitle( - translate('BiblesPlugin.ReImportWizardForm', - 'Please wait while your Bibles are imported.')) + translate('BiblesPlugin.UpgradeWizardForm', + 'Please wait while your Bibles are upgraded.')) self.progressLabel.setText(WizardStrings.Ready) self.progressBar.setFormat(u'%p%') self.deleteCheckBox.setText( - translate('BiblesPlugin.ReImportWizardForm', 'Delete old bible ' - 'database(s) from bibles which was imported\nsucessful right now')) + translate('BiblesPlugin.UpgradeWizardForm', 'Delete old bible ' + 'database(s) from bibles which was upgraded\nsucessful right now')) self.deleteAllCheckBox.setText( - translate('BiblesPlugin.ReImportWizardForm', 'Delete all old bible ' - 'database(s) (including not imported bibles)')) + translate('BiblesPlugin.UpgradeWizardForm', 'Delete all old bible ' + 'database(s) (including not upgraded bibles)')) self.progressLabelAfter.setText( - translate('BiblesPlugin.ReImportWizardForm', '\nIf OpenLP should ' + translate('BiblesPlugin.UpgradeWizardForm', '\nIf OpenLP should ' 'delete the old bible databases please choose:')) def validateCurrentPage(self): @@ -373,21 +373,21 @@ class BibleReImportForm(OpenLPWizard): if not self.checkBox[number].checkState() == 2: continue version_name = unicode(self.versionNameEdit[number].text()) - oldbible = OldBibleDB(self.parent, path=self.oldpath, + oldbible = OldBibleDB(self.mediaItem, path=self.oldpath, file=filename) oldname = oldbible.get_name() if not version_name: critical_error_message_box(UiStrings().EmptyField, - translate('BiblesPlugin.ReImportWizardForm', + translate('BiblesPlugin.UpgradeWizardForm', 'You need to specify a version name for your Bible.')) self.versionNameEdit[number].setFocus() return False elif self.manager.exists(version_name): critical_error_message_box( - translate('BiblesPlugin.ReImportWizardForm', + translate('BiblesPlugin.UpgradeWizardForm', 'Bible Exists'), - translate('BiblesPlugin.ReImportWizardForm', - 'This Bible already exists. Please import ' + translate('BiblesPlugin.UpgradeWizardForm', + 'This Bible already exists. Please upgrade ' 'a different Bible, delete the existing one or ' 'uncheck.')) self.versionNameEdit[number].setFocus() @@ -395,10 +395,10 @@ class BibleReImportForm(OpenLPWizard): elif os.path.exists(os.path.join(self.newpath, filename)) and \ version_name == oldname: critical_error_message_box( - translate('BiblesPlugin.ReImportWizardForm', + translate('BiblesPlugin.UpgradeWizardForm', 'Bible Exists'), - translate('BiblesPlugin.ReImportWizardForm', - 'This Bible already exists. Please import ' + translate('BiblesPlugin.UpgradeWizardForm', + 'This Bible already exists. Please upgrade ' 'a different Bible, delete the existing one or ' 'uncheck.')) self.versionNameEdit[number].setFocus() @@ -406,10 +406,10 @@ class BibleReImportForm(OpenLPWizard): elif os.path.exists(os.path.join(self.newpath, self.clean_filename(version_name))): critical_error_message_box( - translate('BiblesPlugin.ReImportWizardForm', + translate('BiblesPlugin.UpgradeWizardForm', 'Bible Exists'), - translate('BiblesPlugin.ReImportWizardForm', - 'This Bible already exists. Please import ' + translate('BiblesPlugin.UpgradeWizardForm', + 'This Bible already exists. Please upgrade ' 'a different Bible, delete the existing one or ' 'uncheck.')) self.versionNameEdit[number].setFocus() @@ -422,7 +422,7 @@ class BibleReImportForm(OpenLPWizard): """ Set default values for the wizard pages. """ - log.debug(u'BibleReImport setDefaults') + log.debug(u'BibleUpgrade setDefaults') settings = QtCore.QSettings() settings.beginGroup(self.plugin.settingsSection) self.stop_import_flag = False @@ -440,8 +440,8 @@ class BibleReImportForm(OpenLPWizard): for number, filename in enumerate(self.files): self.checkBox[number].setCheckState(2) if os.path.exists(os.path.join(self.newpath, filename)): - self.verticalWidget[number].setVisible(1) - self.formWidget[number].setVisible(1) + self.verticalWidget[number].show() + self.formWidget[number].show() else: self.verticalWidget[number].hide() self.formWidget[number].hide() @@ -456,24 +456,24 @@ class BibleReImportForm(OpenLPWizard): def preWizard(self): """ - Prepare the UI for the import. + Prepare the UI for the upgrade. """ OpenLPWizard.preWizard(self) self.progressLabel.setText(translate( - 'BiblesPlugin.ImportWizardForm', - 'Starting Importing bible...')) + 'BiblesPlugin.UpgradeWizardForm', + 'Starting upgrading bible(s)...')) Receiver.send_message(u'openlp_process_events') def performWizard(self): """ - Perform the actual import. + Perform the actual upgrade. """ include_webbible = False proxy_server = None if self.maxBibles == 0: self.progressLabel.setText( - translate('BiblesPlugin.ReImportWizardForm', 'Sorry, but OpenLP' - ' could not find a Bible to reimport.')) + translate('BiblesPlugin.UpgradeWizardForm', 'Sorry, but OpenLP' + ' could not find a Bible to upgrade.')) self.progressBar.hide() return self.maxBibles = 0 @@ -487,24 +487,25 @@ class BibleReImportForm(OpenLPWizard): if not self.checkBox[biblenumber].checkState() == 2: continue self.progressBar.reset() - oldbible = OldBibleDB(self.parent, path=self.oldpath, file=filename) + oldbible = OldBibleDB(self.mediaItem, path=self.oldpath, + file=filename) name = oldbible.get_name() if name is None: delete_file(os.path.join(self.oldpath, filename)) self.incrementProgressBar(unicode(translate( - 'BiblesPlugin.ReImportWizardForm', - 'Reimporting Bible %s of %s: "%s"\nFailed')) % + 'BiblesPlugin.UpgradeWizardForm', + 'Upgrading Bible %s of %s: "%s"\nFailed')) % (number+1, self.maxBibles, name), self.progressBar.maximum()-self.progressBar.value()) number += 1 continue self.progressLabel.setText(unicode(translate( - 'BiblesPlugin.ReImportWizardForm', - 'Reimporting Bible %s of %s: "%s"\nImporting ...')) % + 'BiblesPlugin.UpgradeWizardForm', + 'Upgrading Bible %s of %s: "%s"\nImporting ...')) % (number+1, self.maxBibles, name)) if os.path.exists(os.path.join(self.newpath, filename)): name = unicode(self.versionNameEdit[biblenumber].text()) - self.newbibles[number] = BibleDB(self.parent, path=self.oldpath, + self.newbibles[number] = BibleDB(self.mediaItem, path=self.oldpath, name=name) metadata = oldbible.get_metadata() webbible = False @@ -538,16 +539,16 @@ class BibleReImportForm(OpenLPWizard): clean_filename(self.newbibles[number].get_name())) del self.newbibles[number] critical_error_message_box( - translate('BiblesPlugin.ReImportWizardForm', + translate('BiblesPlugin.UpgradeWizardForm', 'Download Error'), - translate('BiblesPlugin.ReImportWizardForm', - 'To Re-Import your webbibles a Internet connection is ' + translate('BiblesPlugin.UpgradeWizardForm', + 'To upgrade your webbibles a Internet connection is ' 'necessary. Please check your Internet connection, and ' 'if this error continues to occur please consider ' 'reporting a bug.')) self.incrementProgressBar(unicode(translate( - 'BiblesPlugin.ReImportWizardForm', - 'Reimporting Bible %s of %s: "%s"\nFailed')) % + 'BiblesPlugin.UpgradeWizardForm', + 'Upgrading Bible %s of %s: "%s"\nFailed')) % (number+1, self.maxBibles, name), self.progressBar.maximum()-self.progressBar.value()) number += 1 @@ -562,14 +563,14 @@ class BibleReImportForm(OpenLPWizard): else: language_id = self.newbibles[number].get_language() if not language_id: - log.exception(u'Re-Importing from "%s" '\ + log.exception(u'Upgrading from "%s" '\ 'failed' % filename) delete_database(self.newpath, self.newbibles[number].\ clean_filename(self.newbibles[number].get_name())) del self.newbibles[number] self.incrementProgressBar(unicode(translate( - 'BiblesPlugin.ReImportWizardForm', - 'Reimporting Bible %s of %s: "%s"\nFailed')) % + 'BiblesPlugin.UpgradeWizardForm', + 'Upgrading Bible %s of %s: "%s"\nFailed')) % (number+1, self.maxBibles, name), self.progressBar.maximum()-self.progressBar.value()) number += 1 @@ -577,8 +578,8 @@ class BibleReImportForm(OpenLPWizard): self.progressBar.setMaximum(len(books)) for book in books: self.incrementProgressBar(unicode(translate( - 'BiblesPlugin.ReImportWizardForm', - 'Reimporting Bible %s of %s: "%s"\n' + 'BiblesPlugin.UpgradeWizardForm', + 'Upgrading Bible %s of %s: "%s"\n' 'Importing %s ...')) % (number+1, self.maxBibles, name, book)) book_ref_id = self.newbibles[number].\ @@ -608,8 +609,8 @@ class BibleReImportForm(OpenLPWizard): clean_filename(self.newbibles[number].get_name())) del self.newbibles[number] self.incrementProgressBar(unicode(translate( - 'BiblesPlugin.ReImportWizardForm', - 'Reimporting Bible %s of %s: "%s"\nFailed')) % + 'BiblesPlugin.UpgradeWizardForm', + 'Upgrading Bible %s of %s: "%s"\nFailed')) % (number+1, self.maxBibles, name), self.progressBar.maximum()-self.progressBar.value()) number += 1 @@ -618,8 +619,8 @@ class BibleReImportForm(OpenLPWizard): self.progressBar.setMaximum(len(books)) for book in books: self.incrementProgressBar(unicode(translate( - 'BiblesPlugin.ReImportWizardForm', - 'Reimporting Bible %s of %s: "%s"\n' + 'BiblesPlugin.UpgradeWizardForm', + 'Upgrading Bible %s of %s: "%s"\n' 'Importing %s ...')) % (number+1, self.maxBibles, name, book[u'name'])) book_ref_id = self.newbibles[number].\ @@ -643,19 +644,19 @@ class BibleReImportForm(OpenLPWizard): Receiver.send_message(u'openlp_process_events') if not bible_failed: self.incrementProgressBar(unicode(translate( - 'BiblesPlugin.ReImportWizardForm', - 'Reimporting Bible %s of %s: "%s"\n' + 'BiblesPlugin.UpgradeWizardForm', + 'Upgrading Bible %s of %s: "%s"\n' 'Done')) % (number+1, self.maxBibles, name)) self.success[biblenumber] = True else: self.incrementProgressBar(unicode(translate( - 'BiblesPlugin.ReImportWizardForm', - 'Reimporting Bible %s of %s: "%s"\nFailed')) % + 'BiblesPlugin.UpgradeWizardForm', + 'Upgrading Bible %s of %s: "%s"\nFailed')) % (number+1, self.maxBibles, name), self.progressBar.maximum()-self.progressBar.value()) number += 1 - self.parent.reloadBibles() + self.mediaItem.reloadBibles() successful_import = 0 failed_import = 0 for number, success in self.success.iteritems(): @@ -665,34 +666,34 @@ class BibleReImportForm(OpenLPWizard): failed_import += 1 if failed_import > 0: failed_import_text = unicode(translate( - 'BiblesPlugin.ReImportWizardForm', - ' - %s reimport fail')) % failed_import + 'BiblesPlugin.UpgradeWizardForm', + ' - %s upgrade fail')) % failed_import else: failed_import_text = u'' if successful_import > 0: if include_webbible: self.progressLabel.setText(unicode( - translate('BiblesPlugin.ReImportWizardForm', 'Reimport %s ' + translate('BiblesPlugin.UpgradeWizardForm', 'Upgrade %s ' 'bible(s) successful%s.\nPlease note, that verses from ' 'webbibles will be downloaded\non demand and thus an ' 'internet connection is required.')) % (successful_import, failed_import_text)) else: self.progressLabel.setText(unicode( - translate('BiblesPlugin.ReImportWizardForm', 'Reimport %s ' + translate('BiblesPlugin.UpgradeWizardForm', 'Upgrade %s ' 'bible(s) successful.%s')) % (successful_import, failed_import_text)) - self.deleteCheckBox.setVisible(1) + self.deleteCheckBox.show() bibles = u'' for bible in self.newbibles.itervalues(): name = bible.get_name() bibles += u'\n"' + name + u'"' self.deleteCheckBox.setToolTip(unicode(translate( - 'BiblesPlugin.ReImportWizardForm', - 'Sucessful imported bible(s):%s')) % bibles) + 'BiblesPlugin.UpgradeWizardForm', + 'Sucessful upgraded bible(s):%s')) % bibles) else: self.progressLabel.setText( - translate('BiblesPlugin.ReImportWizardForm', 'Reimport ' + translate('BiblesPlugin.UpgradeWizardForm', 'Upgrade ' 'failed.')) - self.progressLabelAfter.setVisible(1) - self.deleteAllCheckBox.setVisible(1) + self.progressLabelAfter.show() + self.deleteAllCheckBox.show() diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index c2b2fa1b1..8e0eec849 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -35,7 +35,7 @@ from sqlalchemy import Column, ForeignKey, or_, Table, types from sqlalchemy.orm import class_mapper, mapper, relation from sqlalchemy.orm.exc import UnmappedClassError -from openlp.core.lib import Receiver, translate +from openlp.core.lib import Receiver, translate, check_directory_exists from openlp.core.lib.db import BaseModel, init_db, Manager from openlp.core.lib.ui import critical_error_message_box from openlp.core.utils import AppLocation @@ -295,14 +295,14 @@ class BibleDB(QtCore.QObject, Manager): The name of the book to return. """ log.debug(u'BibleDB.get_book("%s")', book) - db_book = self.get_object_filtered(Book, Book.name.like(book + u'%')) - return db_book + return self.get_object_filtered(Book, Book.name.like(book + u'%')) def get_books(self): """ A wrapper so both local and web bibles have a get_books() method that manager can call. Used in the media manager advanced search tab. """ + log.debug(u'BibleDB.get_books()') return self.get_all_objects(Book, order_by_ref=Book.id) def get_book_by_book_ref_id(self, id): @@ -313,9 +313,7 @@ class BibleDB(QtCore.QObject, Manager): The reference id of the book to return. """ log.debug(u'BibleDB.get_book_by_book_ref_id("%s")', id) - db_book = self.get_object_filtered(Book, - Book.book_reference_id.like(id)) - return db_book + return self.get_object_filtered(Book, Book.book_reference_id.like(id)) def get_book_ref_id_by_name(self, book, language_id=None): log.debug(u'BibleDB.get_book_ref_id_by_name:("%s", "%s")', book, @@ -421,16 +419,16 @@ class BibleDB(QtCore.QObject, Manager): verses = verses.all() return verses - def get_chapter_count(self, book_id): + def get_chapter_count(self, book): """ Return the number of chapters in a book. ``book`` - The book to get the chapter count for. + The book object to get the chapter count for. """ - log.debug(u'BibleDB.get_chapter_count("%s")', book_id) + log.debug(u'BibleDB.get_chapter_count("%s")', book.name) count = self.session.query(Verse.chapter).join(Book)\ - .filter(Book.book_reference_id==book_id)\ + .filter(Book.name==book.name)\ .distinct().count() if not count: return 0 @@ -541,16 +539,16 @@ class BiblesResourcesDB(QtCore.QObject, Manager): log.debug(u'BiblesResourcesDB.get_books()') books = BiblesResourcesDB.run_sql(u'SELECT id, testament_id, name, ' u'abbreviation, chapters FROM book_reference ORDER BY id') - book_list = [] - for book in books: - book_list.append({ - u'id': book[0], - u'testament_id': book[1], - u'name': unicode(book[2]), - u'abbreviation': unicode(book[3]), - u'chapters': book[4] - }) - return book_list + return [ + { + u'id': book[0], + u'testament_id': book[1], + u'name': unicode(book[2]), + u'abbreviation': unicode(book[3]), + u'chapters': book[4] + } + for book in books + ] @staticmethod def get_book(name): @@ -700,16 +698,16 @@ class BiblesResourcesDB(QtCore.QObject, Manager): u'language_id, download_source_id FROM webbibles WHERE ' u'download_source_id = ?', (source[u'id'],)) if bibles: - bibles_temp = [] - for bible in bibles: - bibles_temp.append({ - u'id': bible[0], - u'name': bible[1], - u'abbreviation': bible[2], - u'language_id': bible[3], - u'download_source_id': bible[4] - }) - return bibles_temp + return [ + { + u'id': bible[0], + u'name': bible[1], + u'abbreviation': bible[2], + u'language_id': bible[3], + u'download_source_id': bible[4] + } + for bible in bibles + ] else: return None @@ -736,14 +734,13 @@ class BiblesResourcesDB(QtCore.QObject, Manager): u'download_source_id = ? AND abbreviation = ?', (source[u'id'], abbreviation)) if bible: - bibles_temp = { + return { u'id': bible[0][0], u'name': bible[0][1], u'abbreviation': bible[0][2], u'language_id': bible[0][3], u'download_source_id': bible[0][4] } - return bibles_temp else: return None @@ -806,14 +803,14 @@ class BiblesResourcesDB(QtCore.QObject, Manager): languages = BiblesResourcesDB.run_sql(u'SELECT id, name, code FROM ' u'language ORDER by name') if languages: - languages_temp = [] - for language in languages: - languages_temp.append({ - u'id': language[0], - u'name': unicode(language[1]), - u'code': unicode(language[2]) - }) - return languages_temp + return [ + { + u'id': language[0], + u'name': unicode(language[1]), + u'code': unicode(language[2]) + } + for language in languages + ] else: return None @@ -825,13 +822,13 @@ class BiblesResourcesDB(QtCore.QObject, Manager): log.debug(u'BiblesResourcesDB.get_testament_reference()') testaments = BiblesResourcesDB.run_sql(u'SELECT id, name FROM ' u'testament_reference ORDER BY id') - testament_list = [] - for testament in testaments: - testament_list.append({ - u'id': testament[0], - u'name': unicode(testament[1]) - }) - return testament_list + return [ + { + u'id': testament[0], + u'name': unicode(testament[1]) + } + for testament in testaments + ] class AlternativeBookNamesDB(QtCore.QObject, Manager): @@ -849,12 +846,8 @@ class AlternativeBookNamesDB(QtCore.QObject, Manager): database doesn't exist. """ if AlternativeBookNamesDB.cursor is None: - if not os.path.exists(os.path.join( - AppLocation.get_directory(AppLocation.DataDir), u'bibles', - u'resources')): - os.mkdir(os.path.join( - AppLocation.get_directory(AppLocation.DataDir), u'bibles', - u'resources')) + check_directory_exists(os.path.join(AppLocation.get_directory( + AppLocation.DataDir), u'bibles', u'resources')) filepath = os.path.join( AppLocation.get_directory(AppLocation.DataDir), u'bibles', u'resources', u'alternative_book_names.sqlite') @@ -933,10 +926,9 @@ class AlternativeBookNamesDB(QtCore.QObject, Manager): """ log.debug(u'AlternativeBookNamesDB.create_alternative_book_name("%s", ' '"%s", "%s"', name, book_reference_id, language_id) - alternative_book_name = AlternativeBookNamesDB.run_sql(u'INSERT INTO ' + return AlternativeBookNamesDB.run_sql(u'INSERT INTO ' u'alternative_book_names(book_reference_id, language_id, name) ' u'VALUES (?, ?, ?)', (book_reference_id, language_id, name), True) - return alternative_book_name class OldBibleDB(QtCore.QObject, Manager): @@ -1014,15 +1006,15 @@ class OldBibleDB(QtCore.QObject, Manager): metadata = self.run_sql(u'SELECT key, value FROM metadata ' u'ORDER BY rowid') if metadata: - metadata_list = [] - for meta in metadata: - metadata_list.append({ - u'key': unicode(meta[0]), - u'value': unicode(meta[1]) - }) + return [ + { + u'key': unicode(meta[0]), + u'value': unicode(meta[1]) + } + for meta in metadata + ] else: - metadata_list = None - return metadata_list + return None def get_books(self): """ @@ -1030,15 +1022,16 @@ class OldBibleDB(QtCore.QObject, Manager): """ books = self.run_sql(u'SELECT name, id FROM book ORDER BY id') if books: + return [ + { + u'name': unicode(book[0]), + u'id':int(book[1]) + } + for book in books + ] book_list = [] - for book in books: - book_list.append({ - u'name': unicode(book[0]), - u'id':int(book[1]) - }) else: - book_list = None - return book_list + return None def get_verses(self, book_id): """ @@ -1047,15 +1040,14 @@ class OldBibleDB(QtCore.QObject, Manager): verses = self.run_sql(u'SELECT book_id, chapter, verse, text FROM ' u'verse WHERE book_id = ? ORDER BY id', (book_id, )) if verses: - verse_list = [] - for verse in verses: - verse_list.append({ - u'book_id': int(verse[0]), - u'chapter': int(verse[1]), - u'verse': int(verse[2]), - u'text': unicode(verse[3]) - }) + return [ + { + u'book_id': int(verse[0]), + u'chapter': int(verse[1]), + u'verse': int(verse[2]), + u'text': unicode(verse[3]) + } + for verse in verses + ] else: - verse_list = None - return verse_list - + return None diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 9795b0120..b799f24a9 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -241,10 +241,10 @@ class BSExtract(object): send_error_message(u'parse') return None content = content.findAll(u'li') - books = [] - for book in content: + return [ books.append(book.contents[0].contents[0]) - return books + for book in content + ] class CWExtract(object): @@ -507,12 +507,15 @@ class HTTPBible(BibleDB): log.debug(u'HTTPBible.get_books("%s")', Book.name) return self.get_all_objects(Book, order_by_ref=Book.id) - def get_chapter_count(self, book_id): + def get_chapter_count(self, book): """ Return the number of chapters in a particular book. + + ``book`` + The book object to get the chapter count for. """ - log.debug(u'HTTPBible.get_chapter_count("%s")', book_id) - return BiblesResourcesDB.get_chapter_count(book_id) + log.debug(u'HTTPBible.get_chapter_count("%s")', book.name) + return BiblesResourcesDB.get_chapter_count(book.book_reference_id) def get_verse_count(self, book_id, chapter): """ diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index cab665179..7d8ca77db 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -208,23 +208,27 @@ class BibleManager(object): Unicode. The Bible to get the list of books from. """ log.debug(u'BibleManager.get_books("%s")', bible) - language_id = self.get_meta_data(bible, u'language_id') - books = [] - for book in self.db_cache[bible].get_books(): - books.append( + return [ { - u'name': book.name, - u'chapters': self.db_cache[bible].get_chapter_count( - book.book_reference_id) - }) - return books + u'name': book.name, + u'chapters': self.db_cache[bible].get_chapter_count( + book) + } + for book in self.db_cache[bible].get_books() + ] def get_chapter_count(self, bible, book): """ Returns the number of Chapters for a given book. + + ``bible`` + Unicode. The Bible to get the list of books from. + + ``book`` + The book object to get the chapter count for. """ log.debug(u'BibleManager.get_book_chapter_count ("%s", "%s")', bible, - book) + book.name) return self.db_cache[bible].get_chapter_count(book) def get_verse_count(self, bible, book, chapter): diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index ec65a37d0..d902772b8 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -33,7 +33,7 @@ from openlp.core.lib import MediaManagerItem, Receiver, ItemCapabilities, \ from openlp.core.lib.searchedit import SearchEdit from openlp.core.lib.ui import UiStrings, add_widget_completer, \ media_item_combo_box, critical_error_message_box, find_and_set_in_combo_box -from openlp.plugins.bibles.forms import BibleImportForm, BibleReImportForm +from openlp.plugins.bibles.forms import BibleImportForm from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, \ VerseReferenceList, get_reference_match @@ -310,14 +310,6 @@ class BibleMediaItem(MediaManagerItem): if self.import_wizard.exec_(): self.reloadBibles() - def onReImportClick(self): - if not hasattr(self, u'reimport_wizard'): - self.reimport_wizard = BibleReImportForm(self, self.parent.manager, - self.parent) - # If the import was not cancelled then reload. - if self.reimport_wizard.exec_(): - self.reloadBibles() - def loadBibles(self): log.debug(u'Loading Bibles') self.quickVersionComboBox.clear() diff --git a/resources/images/bibles_reimport_alert.png b/resources/images/bibles_upgrade_alert.png similarity index 100% rename from resources/images/bibles_reimport_alert.png rename to resources/images/bibles_upgrade_alert.png diff --git a/resources/images/openlp-2.qrc b/resources/images/openlp-2.qrc index f3bfd100e..785250ab7 100644 --- a/resources/images/openlp-2.qrc +++ b/resources/images/openlp-2.qrc @@ -24,7 +24,7 @@ bibles_search_text.png bibles_search_reference.png - bibles_reimport_alert.png + bibles_upgrade_alert.png plugin_alerts.png From 3b99f531f33e62e8e4443dac8a350ac61b7ca50e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Tue, 26 Apr 2011 20:39:08 +0200 Subject: [PATCH 30/97] small fixes --- openlp/plugins/bibles/forms/bibleupgradeform.py | 2 +- openlp/plugins/bibles/lib/http.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index b64231195..b08454374 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -359,7 +359,7 @@ class BibleUpgradeForm(OpenLPWizard): translate('BiblesPlugin.UpgradeWizardForm', 'Delete all old bible ' 'database(s) (including not upgraded bibles)')) self.progressLabelAfter.setText( - translate('BiblesPlugin.UpgradeWizardForm', '\nIf OpenLP should ' + translate('BiblesPlugin.UpgradeWizardForm', 'If OpenLP should ' 'delete the old bible databases please choose:')) def validateCurrentPage(self): diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index b799f24a9..fb60a2b1a 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -242,8 +242,7 @@ class BSExtract(object): return None content = content.findAll(u'li') return [ - books.append(book.contents[0].contents[0]) - for book in content + book.contents[0].contents[0] for book in content ] From 2f346ee450310fd117f690d02b40920d8be680be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Tue, 26 Apr 2011 20:55:13 +0200 Subject: [PATCH 31/97] small changes --- openlp/plugins/bibles/lib/db.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 8e0eec849..feeeb9b4f 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -78,7 +78,7 @@ def init_schema(url): book_table = Table(u'book', metadata, Column(u'id', types.Integer, primary_key=True), - Column(u'book_reference_id', types.Integer), + Column(u'book_reference_id', types.Integer, index=True), Column(u'testament_reference_id', types.Integer), Column(u'name', types.Unicode(50), index=True), ) @@ -428,7 +428,7 @@ class BibleDB(QtCore.QObject, Manager): """ log.debug(u'BibleDB.get_chapter_count("%s")', book.name) count = self.session.query(Verse.chapter).join(Book)\ - .filter(Book.name==book.name)\ + .filter(Book.book_reference_id==book.book_reference_id)\ .distinct().count() if not count: return 0 From b4c3d1d5ae5afcbf13d8d4a29a7a4764b7e69ff1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Mon, 2 May 2011 06:21:18 +0200 Subject: [PATCH 32/97] code cleaning --- openlp/plugins/bibles/lib/db.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index feeeb9b4f..abc17b194 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -1029,7 +1029,6 @@ class OldBibleDB(QtCore.QObject, Manager): } for book in books ] - book_list = [] else: return None From 3eca8f6b505b45d8c14f18439083e9c2251afcc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Mon, 2 May 2011 15:45:30 +0200 Subject: [PATCH 33/97] updated bibles_resources.sqlite with some additional apocryph books comparing books with lower() display only which are not added to a bible in BookNameForm small fixes --- .../plugins/bibles/forms/bibleupgradeform.py | 7 +- openlp/plugins/bibles/forms/booknameform.py | 10 ++- openlp/plugins/bibles/lib/db.py | 69 +++++++++++------- .../bibles/resources/bibles_resources.sqlite | Bin 101376 -> 101376 bytes 4 files changed, 57 insertions(+), 29 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index b08454374..92d704690 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -27,7 +27,7 @@ The bible import functions for OpenLP """ import logging -import os +#import os import os.path import re @@ -637,6 +637,11 @@ class BibleUpgradeForm(OpenLPWizard): db_book = self.newbibles[number].create_book(book[u'name'], book_ref_id, book_details[u'testament_id']) verses = oldbible.get_verses(book[u'id']) + if not verses: + log.exception(u'No verses found to import for book ' + u'"%s"', book[u'name']) + self.newbibles[number].delete_book(db_book) + continue for verse in verses: self.newbibles[number].create_verse(db_book.id, int(verse[u'chapter']), diff --git a/openlp/plugins/bibles/forms/booknameform.py b/openlp/plugins/bibles/forms/booknameform.py index b8bdbb493..84e1deb96 100644 --- a/openlp/plugins/bibles/forms/booknameform.py +++ b/openlp/plugins/bibles/forms/booknameform.py @@ -53,13 +53,19 @@ class BookNameForm(QDialog, Ui_BookNameDialog): QDialog.__init__(self, parent) self.setupUi(self) - def exec_(self, name): + def exec_(self, name, books): items = [] self.requestComboBox.addItem(u'') self.requestLabel.setText(name) items = BiblesResourcesDB.get_books() for item in items: - self.requestComboBox.addItem(item[u'name']) + addBook = True + for book in books: + if book.book_reference_id == item[u'id']: + addBook = False + break + if addBook == True: + self.requestComboBox.addItem(item[u'name']) return QDialog.exec_(self) def accept(self): diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index abc17b194..a53413063 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -218,6 +218,18 @@ class BibleDB(QtCore.QObject, Manager): self.save_object(book) return book + def delete_book(self, db_book): + """ + Delete a book from the database. + + ``db_book`` + The book objekt. + """ + log.debug(u'BibleDB.delete_book("%s")', db_book.name) + if self.delete_object(Book, db_book.id): + return True + return False + def create_chapter(self, book_id, chapter, textlist): """ Add a chapter and its verses to a book. @@ -318,8 +330,8 @@ class BibleDB(QtCore.QObject, Manager): def get_book_ref_id_by_name(self, book, language_id=None): log.debug(u'BibleDB.get_book_ref_id_by_name:("%s", "%s")', book, language_id) - if BiblesResourcesDB.get_book(book): - book_temp = BiblesResourcesDB.get_book(book) + if BiblesResourcesDB.get_book(book, True): + book_temp = BiblesResourcesDB.get_book(book, True) book_id = book_temp[u'id'] elif BiblesResourcesDB.get_alternative_book_name(book, language_id): book_id = BiblesResourcesDB.get_alternative_book_name(book, @@ -332,7 +344,7 @@ class BibleDB(QtCore.QObject, Manager): from openlp.plugins.bibles.forms import BookNameForm book_ref = None book_name = BookNameForm(self.wizard) - if book_name.exec_(book): + if book_name.exec_(book, self.get_books()): book_ref = unicode(book_name.requestComboBox.currentText()) if not book_ref: return None @@ -551,7 +563,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): ] @staticmethod - def get_book(name): + def get_book(name, lower=False): """ Return a book by name or abbreviation. @@ -561,9 +573,15 @@ class BiblesResourcesDB(QtCore.QObject, Manager): log.debug(u'BiblesResourcesDB.get_book("%s")', name) if not isinstance(name, unicode): name = unicode(name) - books = BiblesResourcesDB.run_sql(u'SELECT id, testament_id, name, ' - u'abbreviation, chapters FROM book_reference WHERE name = ? OR ' - u'abbreviation = ?', (name, name)) + if lower: + books = BiblesResourcesDB.run_sql(u'SELECT id, testament_id, name, ' + u'abbreviation, chapters FROM book_reference WHERE ' + u'LOWER(name) = ? OR LOWER(abbreviation) = ?', + (name.lower(), name.lower())) + else: + books = BiblesResourcesDB.run_sql(u'SELECT id, testament_id, name, ' + u'abbreviation, chapters FROM book_reference WHERE name = ?' + u' OR abbreviation = ?', (name, name)) if books: return { u'id': books[0][0], @@ -758,17 +776,16 @@ class BiblesResourcesDB(QtCore.QObject, Manager): log.debug(u'BiblesResourcesDB.get_alternative_book_name("%s", "%s")', name, language_id) if language_id: - id = BiblesResourcesDB.run_sql(u'SELECT book_reference_id ' - u'FROM alternative_book_names WHERE name = ? and language_id ' - u'= ? ORDER BY id', (name, language_id)) + books = BiblesResourcesDB.run_sql(u'SELECT book_reference_id, name ' + u'FROM alternative_book_names WHERE language_id = ? ORDER BY ' + u'id', (language_id, )) else: - id = BiblesResourcesDB.run_sql(u'SELECT book_reference_id ' - u'FROM alternative_book_names WHERE name = ? ORDER BY id', - (name, )) - if id: - return int(id[0][0]) - else: - return None + books = BiblesResourcesDB.run_sql(u'SELECT book_reference_id, name ' + u'FROM alternative_book_names ORDER BY id') + for book in books: + if book[1].lower() == name.lower(): + return book[0] + return None @staticmethod def get_language(name): @@ -899,16 +916,16 @@ class AlternativeBookNamesDB(QtCore.QObject, Manager): log.debug(u'AlternativeBookNamesDB.get_book_reference_id("%s", "%s")', name, language_id) if language_id: - id = AlternativeBookNamesDB.run_sql(u'SELECT book_reference_id FROM' - u' alternative_book_names WHERE name = ? AND language_id = ?', - (name, language_id)) + books = AlternativeBookNamesDB.run_sql(u'SELECT book_reference_id, ' + u'name FROM alternative_book_names WHERE language_id = ?', + (language_id, )) else: - id = AlternativeBookNamesDB.run_sql(u'SELECT book_reference_id FROM' - u' alternative_book_names WHERE name = ?', name) - if not id: - return None - else: - return id[0][0] + books = AlternativeBookNamesDB.run_sql(u'SELECT book_reference_id, ' + u'name FROM alternative_book_names') + for book in books: + if book[1].lower() == name.lower(): + return book[0] + return None @staticmethod def create_alternative_book_name(name, book_reference_id, language_id): diff --git a/openlp/plugins/bibles/resources/bibles_resources.sqlite b/openlp/plugins/bibles/resources/bibles_resources.sqlite index 4645fcf9ca76a4d0aecb2a5d227198e2f2a696bc..302c6a1c83ff0b9b7530a7df2ddf34f2737089d9 100644 GIT binary patch delta 2172 zcmai!TWpj?6oAi}+3wDk?F~xrT`0B9ZlU(J-9k(0ozj-l%T@uUNNFpry(KIl7?Ul= zM3{gn854<7RP@2bAi^4Bf)GgX1!IEvAP+_e7<@21kQ!p5F`n}erNkHdcQ)U-pE)!C zKYP+Wd(u6Zn{*ohhG{u}CjvDIx1sb--no&FWU`bGSeq#SmJj8Fc$({u6orxaLyy;m z1LuA2RCS;2$?`tgevuj3EJ0GTEWk}L15p@-A;>$u(v_G*dX(2dUL()TG8`Ik1NIf5 ztb~=&MxG22bNrJcxtXh(XLk5Bv$g!*#d_ zpTWEECN)|t`|#;~bq_3+LE7gi?50jf;Z^FsHdPjpY6$kwGX&#MlrBph#cmQO=-E%J zkOSK(WSUl#yrO_+t}3(HC-bol?8Z~riG@*$7^mM!$l>g5aF9kjLW!avtRf2gV2nKW zLYnba=9=oN>{yOmhpnXBPd2v9P_Y@9fNLd0C{!iN zY;30RN$BUGW(wL%8HcG_JNMc|2|2`Xg<+}{g*9B-TsfLyJ}%Eo&B|U9ZR7RkVtH<0LEl9^Pt$Cp;N#5fx{$fSFPqTZ zD$T(%^HybkW`?Z53bGGS2)D^IIs{>Jy`pdp*Jj(3wY^+}m5a64J6mbc8JjmP7#AB@ z!VR$hLIWH4-mv2T_xVXV2ocj*xkBd2db6t}ds|W>UAPiB1@wOwF2PUmEBpa}p@(i} z5r(lHNANg)is$eu{)oTfybvN&l!$uKFQ&vh;-a`A?n;*|k{e`?+##procu(dm!>b& zUd0`D(5(0-4$<~A`OWNf=FJzcj>pjHT#r#2k>g_yei1gWhttaVNIU6RM#$d8iL9`P z#3*jUdNwLOYSB%;BZM)koUm5uVXJn9l-_MoKBM%IML|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34/97] small changes --- openlp/plugins/bibles/lib/db.py | 14 +++++++------- .../bibles/resources/bibles_resources.sqlite | Bin 101376 -> 104448 bytes 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index a53413063..2311c7f00 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -333,13 +333,10 @@ class BibleDB(QtCore.QObject, Manager): if BiblesResourcesDB.get_book(book, True): book_temp = BiblesResourcesDB.get_book(book, True) book_id = book_temp[u'id'] - elif BiblesResourcesDB.get_alternative_book_name(book, language_id): - book_id = BiblesResourcesDB.get_alternative_book_name(book, - language_id) - elif AlternativeBookNamesDB.get_book_reference_id(book, - language_id): - book_id = AlternativeBookNamesDB.get_book_reference_id( - book, language_id) + elif BiblesResourcesDB.get_alternative_book_name(book): + book_id = BiblesResourcesDB.get_alternative_book_name(book) + elif AlternativeBookNamesDB.get_book_reference_id(book): + book_id = AlternativeBookNamesDB.get_book_reference_id(book) else: from openlp.plugins.bibles.forms import BookNameForm book_ref = None @@ -569,6 +566,9 @@ class BiblesResourcesDB(QtCore.QObject, Manager): ``name`` The name or abbreviation of the book. + + ``lower`` + True if the comparsion should be only lowercase """ log.debug(u'BiblesResourcesDB.get_book("%s")', name) if not isinstance(name, unicode): diff --git a/openlp/plugins/bibles/resources/bibles_resources.sqlite b/openlp/plugins/bibles/resources/bibles_resources.sqlite index 302c6a1c83ff0b9b7530a7df2ddf34f2737089d9..9336918f2d187da2a2e0a96819dfc2ceda31dabe 100644 GIT binary patch delta 2688 zcmZuzOH7nk6u$Sr3?L5yhhZFba7G4ZMi_MvwD_n>f7GfVAS&3_GQ1HObY^JPK7Nz7 ziT9=pn@L*Zvgx96rPaj5HeGblxM)mQT{P*!#x$l)nl4%}O&9&n8BiYbXNI}ocb@m0 zbMJrUdj6GL`PbIF9tj~vJ_+oTk8bxrEh=z@H@j4y%F}8^sp! z3Ye6b7D;du;9h60)Q+#2!Gz!CBeTJE0R$I#SF;m1kC*Xcc%s^uj zI=#%SVx7fIsXk4Nuh8y>YzB#(qII;ucDfPeAR^AdL`qcXlSBmb?IXw_4dH}v>mI^t zU3N1vXlHyF=m|#i?4~7XH>1klz69-J)Z&nzTj+EN2Zklby8u_{<0Kq(S9c1(e(fGQ0E&EP|upN3QhzXGBSzcXB}l-Q_`k^J7) z$Z;`(r-IB4z)%XgCdH@-+-o!PYw47t-ZkQ^P=BhQ)VJyjbycO*8MR9VRFU=6dTjk* z-L-C5SF91M)7oQglC$zx`JMb+8kv%(Ya}PMhg0uFQW=gQ zEj&gL<3x9(1PL_IG{T!f1|H4565VAVhWG%)A9Kn4`h8Mp*~y#RgY2iElgpR%{Q5oS zcd)CKd|1Cre0%e}KDBjPWLxGci^BRHrkd<*Y%b{N%e0DZw~xZXBtB_8)HObRiI{k! z-HB};2RAOx;~~zYFA^7x+igH{#&h`FjBm3Kagh@UnQ*^;i}04M91eL(!CDfmP0A!N z!vb44pTz<>zCve+55~~zv)BvLiRv_AT@7}2@~;|4r)U+c=O!P6`y?L9xXUK=vug-^}+$@ z)*+6J)SL84p&|#3kf7(62Sx-#M&Iq|$IqrV5j`t?Xpw4EjwK^IO=-O5SZe#Mj0m-AIwT zh(h<7NW1N}oL#Nv1eV>{ri{5#4t_be8k{5JCC@Ua7R)fW8(Y#30610d>71_Q7UB##sX{=uY7cwl_>4IUuDIm0^)z1F%kJoSVX%#$x@tnb= z(XqDPxCm?BZ)eM9Jw+yuSNrV7Z24^Et48tiWj(K$&!vtC z^`p9vvFley@EZ1#a@;0N8nuUTf9I~+G%Q9<9id%z^=a&28i7rt69R&6=H-)BZ)!>Q zWCz{~sM#-}h^c3?)Gu`4ZGtrG0|o|$ Date: Tue, 3 May 2011 09:41:03 +0200 Subject: [PATCH 35/97] add a dialog at startup which inform the user that the bible format has changed and provide a possibility to upgrade small cleanup --- openlp.pyw | 15 ++++++++++++++- openlp/plugins/bibles/forms/bibleupgradeform.py | 1 - 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/openlp.pyw b/openlp.pyw index 0d4e8c200..9196186a3 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -37,7 +37,8 @@ from traceback import format_exception from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, check_directory_exists +from openlp.core.lib import Receiver, check_directory_exists, SettingsManager, \ + translate from openlp.core.lib.ui import UiStrings from openlp.core.resources import qInitResources from openlp.core.ui.mainwindow import MainWindow @@ -130,6 +131,18 @@ class OpenLP(QtGui.QApplication): u'general/update check', QtCore.QVariant(True)).toBool() if update_check: VersionThread(self.mainWindow).start() + for plugin in self.mainWindow.pluginManager.plugins: + if plugin.name == u'Bibles' and plugin.isActive() and len( + SettingsManager.get_files(u'bibles/bibles', u'.sqlite')) == 0 \ + and len(SettingsManager.get_files(u'bibles', u'.sqlite')) > 0: + if QtGui.QMessageBox.information(self.mainWindow, + translate('OpenLP', 'Information'), translate('OpenLP', + 'Bible format has changed.\nYou have to upgrade your ' + 'existing bibles.\nShould OpenLP upgrade now?'), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | + QtGui.QMessageBox.No)) == QtGui.QMessageBox.Yes: + plugin.onToolsUpgradeItemTriggered() + break DelayStartThread(self.mainWindow).start() return self.exec_() diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 92d704690..220942b42 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -27,7 +27,6 @@ The bible import functions for OpenLP """ import logging -#import os import os.path import re From d44b42aaff0049ddb318e8a2e530182ab04e7d85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Tue, 3 May 2011 13:44:23 +0200 Subject: [PATCH 36/97] improve BookNameForm (add possibility to reduce the books in the ComboBox and try to autodetect if a bible only contains only parts of a bible, so that only a part of the bible books are displayed at startup) --- .../plugins/bibles/forms/bibleupgradeform.py | 5 +- openlp/plugins/bibles/forms/booknamedialog.py | 33 ++++++++++-- openlp/plugins/bibles/forms/booknameform.py | 51 +++++++++++++++++-- openlp/plugins/bibles/lib/csvbible.py | 2 +- openlp/plugins/bibles/lib/db.py | 4 +- openlp/plugins/bibles/lib/http.py | 3 +- openlp/plugins/bibles/lib/openlp1.py | 3 +- openlp/plugins/bibles/lib/opensong.py | 2 +- openlp/plugins/bibles/lib/osis.py | 4 +- 9 files changed, 89 insertions(+), 18 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 220942b42..4feb4bd90 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -582,7 +582,7 @@ class BibleUpgradeForm(OpenLPWizard): 'Importing %s ...')) % (number+1, self.maxBibles, name, book)) book_ref_id = self.newbibles[number].\ - get_book_ref_id_by_name(book, language_id) + get_book_ref_id_by_name(book, len(books), language_id) if not book_ref_id: log.exception(u'Importing books from %s - download '\ u'name: "%s" aborted by user' % ( @@ -623,7 +623,8 @@ class BibleUpgradeForm(OpenLPWizard): 'Importing %s ...')) % (number+1, self.maxBibles, name, book[u'name'])) book_ref_id = self.newbibles[number].\ - get_book_ref_id_by_name(book[u'name'], language_id) + get_book_ref_id_by_name(book[u'name'], len(books), + language_id) if not book_ref_id: log.exception(u'Importing books from %s " '\ 'failed - aborted by user' % name) diff --git a/openlp/plugins/bibles/forms/booknamedialog.py b/openlp/plugins/bibles/forms/booknamedialog.py index bb48548c0..ad30812bc 100644 --- a/openlp/plugins/bibles/forms/booknamedialog.py +++ b/openlp/plugins/bibles/forms/booknamedialog.py @@ -32,7 +32,7 @@ from openlp.core.lib.ui import create_accept_reject_button_box class Ui_BookNameDialog(object): def setupUi(self, bookNameDialog): bookNameDialog.setObjectName(u'BookNameDialog') - bookNameDialog.resize(400, 175) + bookNameDialog.resize(400, 275) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.MinimumExpanding) sizePolicy.setHorizontalStretch(0) @@ -41,7 +41,7 @@ class Ui_BookNameDialog(object): .hasHeightForWidth()) bookNameDialog.setSizePolicy(sizePolicy) self.widget = QtGui.QWidget(bookNameDialog) - self.widget.setGeometry(QtCore.QRect(10, 15, 381, 151)) + self.widget.setGeometry(QtCore.QRect(10, 15, 381, 251)) self.widget.setObjectName(u'widget') self.verticalLayout = QtGui.QVBoxLayout(self.widget) self.verticalLayout.setObjectName(u'verticalLayout') @@ -75,13 +75,28 @@ class Ui_BookNameDialog(object): self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.requestComboBox) self.verticalLayout.addLayout(self.formLayout) + self.infoLabelTestaments = QtGui.QLabel(self.widget) + self.infoLabelTestaments.setObjectName(u'InfoLabelTestaments') + self.verticalLayout.addWidget(self.infoLabelTestaments) + self.checkBoxOldTestament = QtGui.QCheckBox(self.widget) + self.checkBoxOldTestament.setObjectName(u'OldTestament') + self.checkBoxOldTestament.setCheckState(2) + self.verticalLayout.addWidget(self.checkBoxOldTestament) + self.checkBoxNewTestament = QtGui.QCheckBox(self.widget) + self.checkBoxNewTestament.setObjectName(u'OldTestament') + self.checkBoxNewTestament.setCheckState(2) + self.verticalLayout.addWidget(self.checkBoxNewTestament) + self.checkBoxApocrypha = QtGui.QCheckBox(self.widget) + self.checkBoxApocrypha.setObjectName(u'OldTestament') + self.checkBoxApocrypha.setCheckState(2) + self.verticalLayout.addWidget(self.checkBoxApocrypha) + self.verticalLayout.addWidget( + create_accept_reject_button_box(bookNameDialog)) spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.verticalLayout.addItem(spacerItem) - self.formLayout.addWidget( - create_accept_reject_button_box(bookNameDialog)) self.retranslateUi(bookNameDialog) - QtCore.QMetaObject.connectSlotsByName(bookNameDialog) + QtCore.QMetaObject.connectSlotsByName(self) def retranslateUi(self, bookNameDialog): bookNameDialog.setWindowTitle( @@ -93,3 +108,11 @@ class Ui_BookNameDialog(object): 'Please choose the book it is.')) self.requestLabel.setText(translate('BiblesPlugin.BookNameDialog', 'Book:')) + self.infoLabelTestaments.setText(translate( + 'BiblesPlugin.BookNameDialog', 'Show books from:')) + self.checkBoxOldTestament.setText(translate( + 'BiblesPlugin.BookNameDialog', 'Old Testament')) + self.checkBoxNewTestament.setText(translate( + 'BiblesPlugin.BookNameDialog', 'New Testament')) + self.checkBoxApocrypha.setText(translate('BiblesPlugin.BookNameDialog', + 'Apocrypha')) diff --git a/openlp/plugins/bibles/forms/booknameform.py b/openlp/plugins/bibles/forms/booknameform.py index 84e1deb96..4ad8270e6 100644 --- a/openlp/plugins/bibles/forms/booknameform.py +++ b/openlp/plugins/bibles/forms/booknameform.py @@ -30,6 +30,7 @@ Module implementing BookNameForm. import logging from PyQt4.QtGui import QDialog +from PyQt4 import QtCore from openlp.core.lib import translate from openlp.core.lib.ui import critical_error_message_box @@ -52,20 +53,64 @@ class BookNameForm(QDialog, Ui_BookNameDialog): """ QDialog.__init__(self, parent) self.setupUi(self) + self.customSignals() - def exec_(self, name, books): + def customSignals(self): + """ + Set up the signals used in the booknameform. + """ + QtCore.QObject.connect(self.checkBoxOldTestament, + QtCore.SIGNAL(u'stateChanged(int)'), + self.onCheckBoxIndexChanged) + QtCore.QObject.connect(self.checkBoxNewTestament, + QtCore.SIGNAL(u'stateChanged(int)'), + self.onCheckBoxIndexChanged) + QtCore.QObject.connect(self.checkBoxApocrypha, + QtCore.SIGNAL(u'stateChanged(int)'), + self.onCheckBoxIndexChanged) + + def onCheckBoxIndexChanged(self, index): + ''' + Reload Combobox if CheckBox state has changed + ''' + self.reloadComboBox() + + def reloadComboBox(self): + ''' + Reload the Combobox items + ''' items = [] + self.requestComboBox.clear() self.requestComboBox.addItem(u'') - self.requestLabel.setText(name) items = BiblesResourcesDB.get_books() for item in items: addBook = True - for book in books: + for book in self.books: if book.book_reference_id == item[u'id']: addBook = False break + if self.checkBoxOldTestament.checkState() == 0 and \ + item[u'testament_id'] == 1: + addBook = False + elif self.checkBoxNewTestament.checkState() == 0 and \ + item[u'testament_id'] == 2: + addBook = False + elif self.checkBoxApocrypha.checkState() == 0 and \ + item[u'testament_id'] == 3: + addBook = False if addBook == True: self.requestComboBox.addItem(item[u'name']) + + def exec_(self, name, books, maxbooks): + self.books = books + log.debug(maxbooks) + if maxbooks <= 27: + self.checkBoxOldTestament.setCheckState(0) + self.checkBoxApocrypha.setCheckState(0) + elif maxbooks <= 66: + self.checkBoxApocrypha.setCheckState(0) + self.reloadComboBox() + self.requestLabel.setText(name) return QDialog.exec_(self) def accept(self): diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index 80216a73e..a5fe59ccc 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -118,7 +118,7 @@ class CSVBible(BibleDB): translate('BibleDB.Wizard', 'Importing books... %s')) % unicode(line[2], details['encoding'])) book_ref_id = self.get_book_ref_id_by_name( - unicode(line[2], details['encoding']), language_id) + unicode(line[2], details['encoding']), 67, language_id) if not book_ref_id: log.exception(u'Importing books from "%s" '\ 'failed' % self.booksfile) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 2311c7f00..be3beac2f 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -327,7 +327,7 @@ class BibleDB(QtCore.QObject, Manager): log.debug(u'BibleDB.get_book_by_book_ref_id("%s")', id) return self.get_object_filtered(Book, Book.book_reference_id.like(id)) - def get_book_ref_id_by_name(self, book, language_id=None): + def get_book_ref_id_by_name(self, book, maxbooks, language_id=None): log.debug(u'BibleDB.get_book_ref_id_by_name:("%s", "%s")', book, language_id) if BiblesResourcesDB.get_book(book, True): @@ -341,7 +341,7 @@ class BibleDB(QtCore.QObject, Manager): from openlp.plugins.bibles.forms import BookNameForm book_ref = None book_name = BookNameForm(self.wizard) - if book_name.exec_(book, self.get_books()): + if book_name.exec_(book, self.get_books(), maxbooks): book_ref = unicode(book_name.requestComboBox.currentText()) if not book_ref: return None diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index fb60a2b1a..a7f8d1b7e 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -422,7 +422,8 @@ class HTTPBible(BibleDB): self.wizard.incrementProgressBar(unicode(translate( 'BiblesPlugin.HTTPBible', 'Importing %s...', 'Importing ...')) % book) - book_ref_id = self.get_book_ref_id_by_name(book, language_id) + book_ref_id = self.get_book_ref_id_by_name(book, len(books), + language_id) if not book_ref_id: log.exception(u'Importing books from %s - download name: "%s" '\ 'failed' % (self.download_source, self.download_name)) diff --git a/openlp/plugins/bibles/lib/openlp1.py b/openlp/plugins/bibles/lib/openlp1.py index 0ed22797e..f1104ffc2 100644 --- a/openlp/plugins/bibles/lib/openlp1.py +++ b/openlp/plugins/bibles/lib/openlp1.py @@ -74,7 +74,8 @@ class OpenLP1Bible(BibleDB): testament_id = int(book[1]) name = unicode(book[2], u'cp1252') abbreviation = unicode(book[3], u'cp1252') - book_ref_id = self.get_book_ref_id_by_name(name, language_id) + book_ref_id = self.get_book_ref_id_by_name(name, len(books), + language_id) if not book_ref_id: log.exception(u'Importing books from "%s" '\ 'failed' % self.filename) diff --git a/openlp/plugins/bibles/lib/opensong.py b/openlp/plugins/bibles/lib/opensong.py index fd79cd440..48a6dc6e3 100644 --- a/openlp/plugins/bibles/lib/opensong.py +++ b/openlp/plugins/bibles/lib/opensong.py @@ -70,7 +70,7 @@ class OpenSongBible(BibleDB): if self.stop_import_flag: break book_ref_id = self.get_book_ref_id_by_name( - unicode(book.attrib[u'n']), language_id) + unicode(book.attrib[u'n']), len(bible.b), language_id) if not book_ref_id: log.exception(u'Importing books from "%s" '\ 'failed' % self.filename) diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index 2735648ce..b9039677b 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -128,8 +128,8 @@ class OSISBible(BibleDB): verse_text = match.group(4) if not db_book or db_book.name != self.books[book][0]: log.debug(u'New book: "%s"' % self.books[book][0]) - book_ref_id = self.get_book_ref_id_by_name( - unicode(self.books[book][0]), language_id) + book_ref_id = self.get_book_ref_id_by_name(unicode( + self.books[book][0]), 67, language_id) if not book_ref_id: log.exception(u'Importing books from "%s" '\ 'failed' % self.filename) From 368987bb67461c9393c3a205a0d0401c3432c688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Tue, 3 May 2011 19:09:30 +0200 Subject: [PATCH 37/97] code cleanup --- .../plugins/bibles/forms/bibleimportform.py | 17 ++--------- .../plugins/bibles/forms/bibleupgradeform.py | 30 ++++++------------- openlp/plugins/bibles/lib/csvbible.py | 2 +- openlp/plugins/bibles/lib/db.py | 28 ++++++++--------- 4 files changed, 26 insertions(+), 51 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index a85230611..edecbd89c 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -40,7 +40,7 @@ from openlp.core.lib.ui import UiStrings, critical_error_message_box from openlp.core.ui.wizard import OpenLPWizard, WizardStrings from openlp.core.utils import AppLocation, string_is_unicode from openlp.plugins.bibles.lib.manager import BibleFormat -from openlp.plugins.bibles.lib.db import BiblesResourcesDB +from openlp.plugins.bibles.lib.db import BiblesResourcesDB, clean_filename log = logging.getLogger(__name__) @@ -494,7 +494,7 @@ class BibleImportForm(OpenLPWizard): 'a different Bible or first delete the existing one.')) self.versionNameEdit.setFocus() return False - elif os.path.exists(os.path.join(path, self.clean_filename( + elif os.path.exists(os.path.join(path, clean_filename( license_version))): critical_error_message_box( translate('BiblesPlugin.ImportWizardForm', 'Bible Exists'), @@ -507,19 +507,6 @@ class BibleImportForm(OpenLPWizard): if self.currentPage() == self.progressPage: return True - def clean_filename(self, old_filename): - """ - Clean up the version name of the Bible and convert it into a valid - file name. - - ``old_filename`` - The "dirty" file name or version name. - """ - if not isinstance(old_filename, unicode): - old_filename = unicode(old_filename, u'utf-8') - old_filename = re.sub(r'[^\w]+', u'_', old_filename).strip(u'_') - return old_filename + u'.sqlite' - def onWebSourceComboBoxIndexChanged(self, index): """ Setup the list of Bibles when you select a different source on the web diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 4feb4bd90..52e2651cd 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -38,7 +38,7 @@ from openlp.core.lib.ui import UiStrings, critical_error_message_box from openlp.core.ui.wizard import OpenLPWizard, WizardStrings from openlp.core.utils import AppLocation, delete_file from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta, OldBibleDB,\ - BiblesResourcesDB + BiblesResourcesDB, clean_filename from openlp.plugins.bibles.lib.http import BSExtract, BGExtract, CWExtract log = logging.getLogger(__name__) @@ -97,19 +97,6 @@ class BibleUpgradeForm(OpenLPWizard): log.debug(u'Stopping import') self.stop_import_flag = True - def clean_filename(self, old_filename): - """ - Clean up the version name of the Bible and convert it into a valid - file name. - - ``old_filename`` - The "dirty" file name or version name. - """ - if not isinstance(old_filename, unicode): - old_filename = unicode(old_filename, u'utf-8') - old_filename = re.sub(r'[^\w]+', u'_', old_filename).strip(u'_') - return old_filename + u'.sqlite' - def onCheckBoxIndexChanged(self, index): ''' Show/ Hide warnings if CheckBox state has changed @@ -131,7 +118,7 @@ class BibleUpgradeForm(OpenLPWizard): if self.currentPage() == self.progressPage: Receiver.send_message(u'openlp_stop_wizard') for bible in self.newbibles.itervalues(): - delete_database(self.newpath, bible.clean_filename( + delete_database(self.newpath, clean_filename( bible.get_name())) self.done(QtGui.QDialog.Rejected) @@ -403,7 +390,7 @@ class BibleUpgradeForm(OpenLPWizard): self.versionNameEdit[number].setFocus() return False elif os.path.exists(os.path.join(self.newpath, - self.clean_filename(version_name))): + clean_filename(version_name))): critical_error_message_box( translate('BiblesPlugin.UpgradeWizardForm', 'Bible Exists'), @@ -534,7 +521,7 @@ class BibleUpgradeForm(OpenLPWizard): u'name: "%s" failed' % ( meta_data[u'download source'], meta_data[u'download name'])) - delete_database(self.newpath, self.newbibles[number].\ + delete_database(self.newpath, clean_filename(self.newbibles[number].get_name())) del self.newbibles[number] critical_error_message_box( @@ -564,7 +551,7 @@ class BibleUpgradeForm(OpenLPWizard): if not language_id: log.exception(u'Upgrading from "%s" '\ 'failed' % filename) - delete_database(self.newpath, self.newbibles[number].\ + delete_database(self.newpath, clean_filename(self.newbibles[number].get_name())) del self.newbibles[number] self.incrementProgressBar(unicode(translate( @@ -588,7 +575,7 @@ class BibleUpgradeForm(OpenLPWizard): u'name: "%s" aborted by user' % ( meta_data[u'download source'], meta_data[u'download name'])) - delete_database(self.newpath, self.newbibles[number].\ + delete_database(self.newpath, clean_filename(self.newbibles[number].get_name())) del self.newbibles[number] bible_failed = True @@ -604,7 +591,7 @@ class BibleUpgradeForm(OpenLPWizard): if not language_id: log.exception(u'Importing books from "%s" '\ 'failed' % name) - delete_database(self.newpath, self.newbibles[number].\ + delete_database(self.newpath, clean_filename(self.newbibles[number].get_name())) del self.newbibles[number] self.incrementProgressBar(unicode(translate( @@ -628,7 +615,7 @@ class BibleUpgradeForm(OpenLPWizard): if not book_ref_id: log.exception(u'Importing books from %s " '\ 'failed - aborted by user' % name) - delete_database(self.newpath, self.newbibles[number].\ + delete_database(self.newpath, clean_filename(self.newbibles[number].get_name())) del self.newbibles[number] bible_failed = True @@ -647,6 +634,7 @@ class BibleUpgradeForm(OpenLPWizard): int(verse[u'chapter']), int(verse[u'verse']), unicode(verse[u'text'])) Receiver.send_message(u'openlp_process_events') + self.newbibles[number].session.commit() if not bible_failed: self.incrementProgressBar(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index a5fe59ccc..85b2b27e4 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -70,7 +70,7 @@ import chardet import csv from openlp.core.lib import Receiver, translate -from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB#, Testament +from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB log = logging.getLogger(__name__) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index be3beac2f..d47d01c32 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -62,6 +62,19 @@ class Verse(BaseModel): """ pass +def clean_filename(old_filename): + """ + Clean up the version name of the Bible and convert it into a valid + file name. + + ``old_filename`` + The "dirty" file name or version name. + """ + if not isinstance(old_filename, unicode): + old_filename = unicode(old_filename, u'utf-8') + old_filename = re.sub(r'[^\w]+', u'_', old_filename).strip(u'_') + return old_filename + u'.sqlite' + def init_schema(url): """ Setup a bible database connection and initialise the database schema. @@ -144,7 +157,7 @@ class BibleDB(QtCore.QObject, Manager): self.name = kwargs[u'name'] if not isinstance(self.name, unicode): self.name = unicode(self.name, u'utf-8') - self.file = self.clean_filename(self.name) + self.file = clean_filename(self.name) if u'file' in kwargs: self.file = kwargs[u'file'] Manager.__init__(self, u'bibles/bibles', init_schema, self.file) @@ -171,19 +184,6 @@ class BibleDB(QtCore.QObject, Manager): self.name = version_name.value if version_name else None return self.name - def clean_filename(self, old_filename): - """ - Clean up the version name of the Bible and convert it into a valid - file name. - - ``old_filename`` - The "dirty" file name or version name. - """ - if not isinstance(old_filename, unicode): - old_filename = unicode(old_filename, u'utf-8') - old_filename = re.sub(r'[^\w]+', u'_', old_filename).strip(u'_') - return old_filename + u'.sqlite' - def register(self, wizard): """ This method basically just initialialises the database. It is called From 4ee247c8b176de1601bb73b73f5acce0556c8aef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Tue, 3 May 2011 22:34:39 +0200 Subject: [PATCH 38/97] code cleanup small fixes --- openlp.pyw | 6 +-- .../plugins/bibles/forms/bibleimportform.py | 7 ++-- .../plugins/bibles/forms/bibleupgradeform.py | 37 ++++++++++--------- openlp/plugins/bibles/forms/booknamedialog.py | 6 +-- openlp/plugins/bibles/forms/booknameform.py | 21 +++++------ openlp/plugins/bibles/forms/languageform.py | 1 - openlp/plugins/bibles/lib/db.py | 16 ++++---- openlp/plugins/bibles/lib/http.py | 11 ++++-- 8 files changed, 55 insertions(+), 50 deletions(-) diff --git a/openlp.pyw b/openlp.pyw index 00263ccb6..253f93718 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -132,9 +132,9 @@ class OpenLP(QtGui.QApplication): if update_check: VersionThread(self.mainWindow).start() for plugin in self.mainWindow.pluginManager.plugins: - if plugin.name == u'Bibles' and plugin.isActive() and len( - SettingsManager.get_files(u'bibles/bibles', u'.sqlite')) == 0 \ - and len(SettingsManager.get_files(u'bibles', u'.sqlite')) > 0: + if plugin.name == u'Bibles' and plugin.isActive() and not \ + len(SettingsManager.get_files( u'bibles/bibles', u'.sqlite')) \ + and SettingsManager.get_files(u'bibles', u'.sqlite'): if QtGui.QMessageBox.information(self.mainWindow, translate('OpenLP', 'Information'), translate('OpenLP', 'Bible format has changed.\nYou have to upgrade your ' diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index edecbd89c..8e9073775 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -637,9 +637,9 @@ class BibleImportForm(OpenLPWizard): bibles = BiblesResourcesDB.get_webbibles( WebDownload.Names[download_type]) for bible in bibles: - ver = bible[u'name'] + version = bible[u'name'] name = bible[u'abbreviation'] - self.web_bible_list[download_type][ver] = name.strip() + self.web_bible_list[download_type][version] = name.strip() def preWizard(self): """ @@ -720,4 +720,5 @@ class BibleImportForm(OpenLPWizard): self.progressLabel.setText(translate( 'BiblesPlugin.ImportWizardForm', 'Your Bible import failed.')) del self.manager.db_cache[importer.name] - delete_database(self.plugin.settingsSection, importer.file) + delete_database(AppLocation.get_section_data_path(u'bibles/bibles'), + importer.file) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 52e2651cd..0dad17336 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -98,11 +98,11 @@ class BibleUpgradeForm(OpenLPWizard): self.stop_import_flag = True def onCheckBoxIndexChanged(self, index): - ''' + """ Show/ Hide warnings if CheckBox state has changed - ''' + """ for number, filename in enumerate(self.files): - if not self.checkBox[number].checkState() == 2: + if not self.checkBox[number].checkState() == QtCore.Qt.Checked: self.verticalWidget[number].hide() self.formWidget[number].hide() else: @@ -134,15 +134,15 @@ class BibleUpgradeForm(OpenLPWizard): self.next() def onFinishButton(self): - ''' + """ Some cleanup while finishing - ''' - if self.deleteCheckBox.checkState() == 2 or \ - self.deleteAllCheckBox.checkState() == 2: + """ + if self.deleteCheckBox.checkState() == QtCore.Qt.Checked or \ + self.deleteAllCheckBox.checkState() == QtCore.Qt.Checked: for number, filename in enumerate(self.files): - if self.deleteAllCheckBox.checkState() == 2 or \ - (self.checkBox[number].checkState() == 2 and \ - self.success[number] == True): + if self.deleteAllCheckBox.checkState() == QtCore.Qt.Checked or \ + (self.checkBox[number].checkState() == QtCore.Qt.Checked \ + and self.success[number]): delete_file(os.path.join(self.oldpath, filename)) def customInit(self): @@ -204,7 +204,7 @@ class BibleUpgradeForm(OpenLPWizard): checkBoxName = u'checkBox['+unicode(number)+u']' self.checkBox[number].setObjectName(checkBoxName) self.checkBox[number].setText(bible.get_name()) - self.checkBox[number].setCheckState(2) + self.checkBox[number].setCheckState(QtCore.Qt.Checked) self.formLayout.addWidget(self.checkBox[number]) self.verticalWidget[number] = QtGui.QWidget(self.scrollAreaContents) verticalWidgetName = u'verticalWidget['+unicode(number)+u']' @@ -356,7 +356,7 @@ class BibleUpgradeForm(OpenLPWizard): return True elif self.currentPage() == self.selectPage: for number, filename in enumerate(self.files): - if not self.checkBox[number].checkState() == 2: + if not self.checkBox[number].checkState() == QtCore.Qt.Checked: continue version_name = unicode(self.versionNameEdit[number].text()) oldbible = OldBibleDB(self.mediaItem, path=self.oldpath, @@ -424,7 +424,7 @@ class BibleUpgradeForm(OpenLPWizard): self.finishButton.setVisible(False) self.cancelButton.setVisible(True) for number, filename in enumerate(self.files): - self.checkBox[number].setCheckState(2) + self.checkBox[number].setCheckState(QtCore.Qt.Checked) if os.path.exists(os.path.join(self.newpath, filename)): self.verticalWidget[number].show() self.formWidget[number].show() @@ -434,9 +434,9 @@ class BibleUpgradeForm(OpenLPWizard): self.progressBar.show() self.progressLabelAfter.hide() self.deleteCheckBox.hide() - self.deleteCheckBox.setCheckState(0) + self.deleteCheckBox.setCheckState(QtCore.Qt.Unchecked) self.deleteAllCheckBox.hide() - self.deleteAllCheckBox.setCheckState(0) + self.deleteAllCheckBox.setCheckState(QtCore.Qt.Unchecked) self.restart() settings.endGroup() @@ -464,13 +464,13 @@ class BibleUpgradeForm(OpenLPWizard): return self.maxBibles = 0 for number, file in enumerate(self.files): - if self.checkBox[number].checkState() == 2: + if self.checkBox[number].checkState() == QtCore.Qt.Checked: self.maxBibles += 1 number = 0 for biblenumber, filename in enumerate(self.files): bible_failed = False self.success[biblenumber] = False - if not self.checkBox[biblenumber].checkState() == 2: + if not self.checkBox[biblenumber].checkState() == QtCore.Qt.Checked: continue self.progressBar.reset() oldbible = OldBibleDB(self.mediaItem, path=self.oldpath, @@ -655,7 +655,8 @@ class BibleUpgradeForm(OpenLPWizard): for number, success in self.success.iteritems(): if success == True: successful_import += 1 - elif success == False and self.checkBox[number].checkState() == 2: + elif success == False and self.checkBox[number].checkState() == \ + QtCore.Qt.Checked: failed_import += 1 if failed_import > 0: failed_import_text = unicode(translate( diff --git a/openlp/plugins/bibles/forms/booknamedialog.py b/openlp/plugins/bibles/forms/booknamedialog.py index ad30812bc..027131a39 100644 --- a/openlp/plugins/bibles/forms/booknamedialog.py +++ b/openlp/plugins/bibles/forms/booknamedialog.py @@ -80,15 +80,15 @@ class Ui_BookNameDialog(object): self.verticalLayout.addWidget(self.infoLabelTestaments) self.checkBoxOldTestament = QtGui.QCheckBox(self.widget) self.checkBoxOldTestament.setObjectName(u'OldTestament') - self.checkBoxOldTestament.setCheckState(2) + self.checkBoxOldTestament.setCheckState(QtCore.Qt.Checked) self.verticalLayout.addWidget(self.checkBoxOldTestament) self.checkBoxNewTestament = QtGui.QCheckBox(self.widget) self.checkBoxNewTestament.setObjectName(u'OldTestament') - self.checkBoxNewTestament.setCheckState(2) + self.checkBoxNewTestament.setCheckState(QtCore.Qt.Checked) self.verticalLayout.addWidget(self.checkBoxNewTestament) self.checkBoxApocrypha = QtGui.QCheckBox(self.widget) self.checkBoxApocrypha.setObjectName(u'OldTestament') - self.checkBoxApocrypha.setCheckState(2) + self.checkBoxApocrypha.setCheckState(QtCore.Qt.Checked) self.verticalLayout.addWidget(self.checkBoxApocrypha) self.verticalLayout.addWidget( create_accept_reject_button_box(bookNameDialog)) diff --git a/openlp/plugins/bibles/forms/booknameform.py b/openlp/plugins/bibles/forms/booknameform.py index 4ad8270e6..425e20e41 100644 --- a/openlp/plugins/bibles/forms/booknameform.py +++ b/openlp/plugins/bibles/forms/booknameform.py @@ -79,7 +79,6 @@ class BookNameForm(QDialog, Ui_BookNameDialog): ''' Reload the Combobox items ''' - items = [] self.requestComboBox.clear() self.requestComboBox.addItem(u'') items = BiblesResourcesDB.get_books() @@ -89,26 +88,26 @@ class BookNameForm(QDialog, Ui_BookNameDialog): if book.book_reference_id == item[u'id']: addBook = False break - if self.checkBoxOldTestament.checkState() == 0 and \ - item[u'testament_id'] == 1: + if self.checkBoxOldTestament.checkState() == QtCore.Qt.Unchecked \ + and item[u'testament_id'] == 1: addBook = False - elif self.checkBoxNewTestament.checkState() == 0 and \ - item[u'testament_id'] == 2: + elif self.checkBoxNewTestament.checkState() == QtCore.Qt.Unchecked \ + and item[u'testament_id'] == 2: addBook = False - elif self.checkBoxApocrypha.checkState() == 0 and \ - item[u'testament_id'] == 3: + elif self.checkBoxApocrypha.checkState() == QtCore.Qt.Unchecked \ + and item[u'testament_id'] == 3: addBook = False - if addBook == True: + if addBook: self.requestComboBox.addItem(item[u'name']) def exec_(self, name, books, maxbooks): self.books = books log.debug(maxbooks) if maxbooks <= 27: - self.checkBoxOldTestament.setCheckState(0) - self.checkBoxApocrypha.setCheckState(0) + self.checkBoxOldTestament.setCheckState(QtCore.Qt.Unchecked) + self.checkBoxApocrypha.setCheckState(QtCore.Qt.Unchecked) elif maxbooks <= 66: - self.checkBoxApocrypha.setCheckState(0) + self.checkBoxApocrypha.setCheckState(QtCore.Qt.Unchecked) self.reloadComboBox() self.requestLabel.setText(name) return QDialog.exec_(self) diff --git a/openlp/plugins/bibles/forms/languageform.py b/openlp/plugins/bibles/forms/languageform.py index e96a005c2..6235c6385 100644 --- a/openlp/plugins/bibles/forms/languageform.py +++ b/openlp/plugins/bibles/forms/languageform.py @@ -53,7 +53,6 @@ class LanguageForm(QDialog, Ui_LanguageDialog): self.setupUi(self) def exec_(self): - items = [] self.requestComboBox.addItem(u'') items = BiblesResourcesDB.get_languages() for item in items: diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index d47d01c32..805b0e7ad 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -476,9 +476,9 @@ class BibleDB(QtCore.QObject, Manager): log.debug(u'BibleDB.get_language()') from openlp.plugins.bibles.forms import LanguageForm language = None - lang = LanguageForm(self.wizard) - if lang.exec_(): - language = unicode(lang.requestComboBox.currentText()) + language_form = LanguageForm(self.wizard) + if language_form.exec_(): + language = unicode(language_form.requestComboBox.currentText()) if not language: return False language = BiblesResourcesDB.get_language(language) @@ -550,11 +550,11 @@ class BiblesResourcesDB(QtCore.QObject, Manager): u'abbreviation, chapters FROM book_reference ORDER BY id') return [ { - u'id': book[0], - u'testament_id': book[1], - u'name': unicode(book[2]), - u'abbreviation': unicode(book[3]), - u'chapters': book[4] + u'id': book[0], + u'testament_id': book[1], + u'name': unicode(book[2]), + u'abbreviation': unicode(book[3]), + u'chapters': book[4] } for book in books ] diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index a7f8d1b7e..e0261570e 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -419,9 +419,11 @@ class HTTPBible(BibleDB): 'failed' % self.filename) return False for book in books: + if self.stop_import_flag: + break self.wizard.incrementProgressBar(unicode(translate( - 'BiblesPlugin.HTTPBible', 'Importing %s...', - 'Importing ...')) % book) + 'BiblesPlugin.HTTPBible', 'Importing %s...', + 'Importing ...')) % book) book_ref_id = self.get_book_ref_id_by_name(book, len(books), language_id) if not book_ref_id: @@ -432,7 +434,10 @@ class HTTPBible(BibleDB): log.debug(u'Book details: Name:%s; id:%s; testament_id:%s', book, book_ref_id, book_details[u'testament_id']) self.create_book(book, book_ref_id, book_details[u'testament_id']) - return True + if self.stop_import_flag: + return False + else: + return True def get_verses(self, reference_list): """ From 4ffa5c59d7188d5e27340d074d554671c55132c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Thu, 12 May 2011 22:04:33 +0200 Subject: [PATCH 39/97] change some strings to better english small fixes --- openlp/plugins/bibles/bibleplugin.py | 6 +-- .../plugins/bibles/forms/bibleupgradeform.py | 48 +++++++++---------- openlp/plugins/bibles/forms/booknamedialog.py | 2 +- openlp/plugins/bibles/forms/languagedialog.py | 2 +- openlp/plugins/bibles/lib/db.py | 2 +- 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index b6f1a91ec..bc986e464 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -102,10 +102,10 @@ class BiblePlugin(Plugin): self.toolsUpgradeItem = QtGui.QAction(tools_menu) self.toolsUpgradeItem.setObjectName(u'toolsUpgradeItem') self.toolsUpgradeItem.setText( - translate('BiblePlugin', '&Upgrade older bible databases')) + translate('BiblePlugin', '&Upgrade Bible databases')) self.toolsUpgradeItem.setStatusTip( - translate('BiblePlugin', 'Upgrade the bible databases to addapt ' - 'the database scheme.')) + translate('BiblePlugin', 'Upgrade the Bible databases to the ' + 'latest format')) tools_menu.addAction(self.toolsUpgradeItem) QtCore.QObject.connect(self.toolsUpgradeItem, QtCore.SIGNAL(u'triggered()'), self.onToolsUpgradeItemTriggered) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 0dad17336..f521fffc5 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -296,7 +296,7 @@ class BibleUpgradeForm(OpenLPWizard): the wizard is progressing with its task. """ OpenLPWizard.addProgressPage(self) - self.progressLayout.setContentsMargins(48, 48, 48, 30) + self.progressLayout.setContentsMargins(48, 48, 48, 20) self.progressLabelAfter = QtGui.QLabel(self.progressPage) self.progressLabelAfter.setObjectName(u'progressLabelAfter') self.progressLayout.addWidget(self.progressLabelAfter) @@ -319,19 +319,19 @@ class BibleUpgradeForm(OpenLPWizard): translate('BiblesPlugin.UpgradeWizardForm', 'This wizard will help you to upgrade your existing Bibles from a ' 'prior version of OpenLP 2. Click the next button below to start ' - 'the process by selecting the bibles to upgrade.')) + 'the process by selecting the Bibles to upgrade.')) self.selectPage.setTitle( translate('BiblesPlugin.UpgradeWizardForm', - 'Please choose')) + 'Select Bibles')) self.selectPage.setSubTitle( translate('BiblesPlugin.UpgradeWizardForm', - 'Please choose the bibles which should be upgraded')) + 'Please select the Bibles to upgrade')) for number, bible in enumerate(self.files): self.versionNameLabel[number].setText( translate('BiblesPlugin.UpgradeWizardForm', 'Version name:')) self.versionInfoLabel[number].setText( translate('BiblesPlugin.UpgradeWizardForm', 'This ' - 'bible still exists. Please change the name or uncheck it.')) + 'Bible still exists. Please change the name or uncheck it.')) self.progressPage.setTitle(WizardStrings.Importing) self.progressPage.setSubTitle( translate('BiblesPlugin.UpgradeWizardForm', @@ -339,14 +339,15 @@ class BibleUpgradeForm(OpenLPWizard): self.progressLabel.setText(WizardStrings.Ready) self.progressBar.setFormat(u'%p%') self.deleteCheckBox.setText( - translate('BiblesPlugin.UpgradeWizardForm', 'Delete old bible ' - 'database(s) from bibles which was upgraded\nsucessful right now')) + translate('BiblesPlugin.UpgradeWizardForm', 'Delete those files ' + 'which have been successfully upgraded.')) self.deleteAllCheckBox.setText( - translate('BiblesPlugin.UpgradeWizardForm', 'Delete all old bible ' - 'database(s) (including not upgraded bibles)')) + translate('BiblesPlugin.UpgradeWizardForm', 'Delete all the old ' + 'files, including those which have not been \nupgraded.')) self.progressLabelAfter.setText( - translate('BiblesPlugin.UpgradeWizardForm', 'If OpenLP should ' - 'delete the old bible databases please choose:')) + translate('BiblesPlugin.UpgradeWizardForm', 'A copy of the ' + 'pre-upgraded Bible database files have been made. \nWould you ' + 'like to:')) def validateCurrentPage(self): """ @@ -458,8 +459,8 @@ class BibleUpgradeForm(OpenLPWizard): proxy_server = None if self.maxBibles == 0: self.progressLabel.setText( - translate('BiblesPlugin.UpgradeWizardForm', 'Sorry, but OpenLP' - ' could not find a Bible to upgrade.')) + translate('BiblesPlugin.UpgradeWizardForm', 'There are no ' + 'Bibles available to upgrade.')) self.progressBar.hide() return self.maxBibles = 0 @@ -482,13 +483,13 @@ class BibleUpgradeForm(OpenLPWizard): 'BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\nFailed')) % (number+1, self.maxBibles, name), - self.progressBar.maximum()-self.progressBar.value()) + self.progressBar.maximum() - self.progressBar.value()) number += 1 continue self.progressLabel.setText(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\nImporting ...')) % - (number+1, self.maxBibles, name)) + (number + 1, self.maxBibles, name)) if os.path.exists(os.path.join(self.newpath, filename)): name = unicode(self.versionNameEdit[biblenumber].text()) self.newbibles[number] = BibleDB(self.mediaItem, path=self.oldpath, @@ -528,10 +529,9 @@ class BibleUpgradeForm(OpenLPWizard): translate('BiblesPlugin.UpgradeWizardForm', 'Download Error'), translate('BiblesPlugin.UpgradeWizardForm', - 'To upgrade your webbibles a Internet connection is ' - 'necessary. Please check your Internet connection, and ' - 'if this error continues to occur please consider ' - 'reporting a bug.')) + 'To upgrade your Web Bibles an Internet connection is ' + 'required. If you have a working Internet connection ' + 'and this error still occurs, please report a bug.')) self.incrementProgressBar(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\nFailed')) % @@ -668,14 +668,14 @@ class BibleUpgradeForm(OpenLPWizard): if include_webbible: self.progressLabel.setText(unicode( translate('BiblesPlugin.UpgradeWizardForm', 'Upgrade %s ' - 'bible(s) successful%s.\nPlease note, that verses from ' - 'webbibles will be downloaded\non demand and thus an ' - 'internet connection is required.')) % + 'Bible(s) successful%s.\nPlease note, that verses from ' + 'Web Bibles will be downloaded\non demand and so an ' + 'Internet connection is required.')) % (successful_import, failed_import_text)) else: self.progressLabel.setText(unicode( translate('BiblesPlugin.UpgradeWizardForm', 'Upgrade %s ' - 'bible(s) successful.%s')) % (successful_import, + 'Bible(s) successful.%s')) % (successful_import, failed_import_text)) self.deleteCheckBox.show() bibles = u'' @@ -684,7 +684,7 @@ class BibleUpgradeForm(OpenLPWizard): bibles += u'\n"' + name + u'"' self.deleteCheckBox.setToolTip(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', - 'Sucessful upgraded bible(s):%s')) % bibles) + 'Successfully upgraded Bible(s):%s')) % bibles) else: self.progressLabel.setText( translate('BiblesPlugin.UpgradeWizardForm', 'Upgrade ' diff --git a/openlp/plugins/bibles/forms/booknamedialog.py b/openlp/plugins/bibles/forms/booknamedialog.py index 027131a39..20e96b922 100644 --- a/openlp/plugins/bibles/forms/booknamedialog.py +++ b/openlp/plugins/bibles/forms/booknamedialog.py @@ -105,7 +105,7 @@ class Ui_BookNameDialog(object): translate('BiblesPlugin.BookNameDialog', 'Choose Book:')) self.infoLabel.setText(translate('BiblesPlugin.BookNameDialog', 'The following books cannot be clearly attributed. \n' - 'Please choose the book it is.')) + 'Please choose which book it is.')) self.requestLabel.setText(translate('BiblesPlugin.BookNameDialog', 'Book:')) self.infoLabelTestaments.setText(translate( diff --git a/openlp/plugins/bibles/forms/languagedialog.py b/openlp/plugins/bibles/forms/languagedialog.py index c4ede8e77..7f3580279 100644 --- a/openlp/plugins/bibles/forms/languagedialog.py +++ b/openlp/plugins/bibles/forms/languagedialog.py @@ -89,6 +89,6 @@ class Ui_LanguageDialog(object): self.headlineLabel.setText( translate('BiblesPlugin.LanguageDialog', 'Choose Language:')) self.infoLabel.setText(translate('BiblesPlugin.LanguageDialog', - 'Please choose the language the bible is.')) + 'Please choose the Bible\'s language')) self.requestLabel.setText(translate('BiblesPlugin.languageDialog', 'Language:')) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 805b0e7ad..3ef73e334 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -223,7 +223,7 @@ class BibleDB(QtCore.QObject, Manager): Delete a book from the database. ``db_book`` - The book objekt. + The book object. """ log.debug(u'BibleDB.delete_book("%s")', db_book.name) if self.delete_object(Book, db_book.id): From fbd5349c2f2ce4f1d355667263da88883cb3b8e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sun, 15 May 2011 20:42:08 +0200 Subject: [PATCH 40/97] small bugfixes hide entry in tools menu if there are no bibles to upgrade --- openlp/plugins/bibles/bibleplugin.py | 6 ++++-- openlp/plugins/bibles/forms/bibleupgradeform.py | 10 ++++++++-- openlp/plugins/bibles/lib/db.py | 1 - 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index bc986e464..fd56d9d32 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -28,7 +28,8 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import Plugin, StringContent, build_icon, translate +from openlp.core.lib import Plugin, StringContent, build_icon, translate, \ + SettingsManager from openlp.core.lib.ui import base_action, UiStrings from openlp.core.utils.actions import ActionList from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem @@ -59,7 +60,8 @@ class BiblePlugin(Plugin): #action_list.add_action(self.exportBibleItem, UiStrings().Export) # Set to invisible until we can export bibles self.exportBibleItem.setVisible(False) - self.toolsUpgradeItem.setVisible(True) + if SettingsManager.get_files(u'bibles', u'.sqlite'): + self.toolsUpgradeItem.setVisible(True) def finalise(self): """ diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index f521fffc5..7e55a6c41 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -422,8 +422,6 @@ class BibleUpgradeForm(OpenLPWizard): self.customSignals() self.retranslateUi() self.maxBibles = len(self.files) - self.finishButton.setVisible(False) - self.cancelButton.setVisible(True) for number, filename in enumerate(self.files): self.checkBox[number].setCheckState(QtCore.Qt.Checked) if os.path.exists(os.path.join(self.newpath, filename)): @@ -439,6 +437,8 @@ class BibleUpgradeForm(OpenLPWizard): self.deleteAllCheckBox.hide() self.deleteAllCheckBox.setCheckState(QtCore.Qt.Unchecked) self.restart() + self.finishButton.setVisible(False) + self.cancelButton.setVisible(True) settings.endGroup() def preWizard(self): @@ -469,6 +469,8 @@ class BibleUpgradeForm(OpenLPWizard): self.maxBibles += 1 number = 0 for biblenumber, filename in enumerate(self.files): + if self.stop_import_flag: + break bible_failed = False self.success[biblenumber] = False if not self.checkBox[biblenumber].checkState() == QtCore.Qt.Checked: @@ -563,6 +565,8 @@ class BibleUpgradeForm(OpenLPWizard): continue self.progressBar.setMaximum(len(books)) for book in books: + if self.stop_import_flag: + break self.incrementProgressBar(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\n' @@ -604,6 +608,8 @@ class BibleUpgradeForm(OpenLPWizard): books = oldbible.get_books() self.progressBar.setMaximum(len(books)) for book in books: + if self.stop_import_flag: + break self.incrementProgressBar(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\n' diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 3ef73e334..6452a2fca 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -799,7 +799,6 @@ class BiblesResourcesDB(QtCore.QObject, Manager): log.debug(u'BiblesResourcesDB.get_language("%s")', name) if not isinstance(name, unicode): name = unicode(name) - name = name.title() language = BiblesResourcesDB.run_sql(u'SELECT id, name, code FROM ' u'language WHERE name = ? OR code = ?', (name, name.lower())) if language: From c51d8182a60ea90d9bfb82bb53f58b0df907d6de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Wed, 18 May 2011 20:19:11 +0200 Subject: [PATCH 41/97] delete all sucessfull imported bibles by default remove the possibility to choose which bibles should be deleted after the upgrade --- .../plugins/bibles/forms/bibleupgradeform.py | 52 ++----------------- 1 file changed, 3 insertions(+), 49 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 7e55a6c41..da75d9553 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -137,13 +137,9 @@ class BibleUpgradeForm(OpenLPWizard): """ Some cleanup while finishing """ - if self.deleteCheckBox.checkState() == QtCore.Qt.Checked or \ - self.deleteAllCheckBox.checkState() == QtCore.Qt.Checked: - for number, filename in enumerate(self.files): - if self.deleteAllCheckBox.checkState() == QtCore.Qt.Checked or \ - (self.checkBox[number].checkState() == QtCore.Qt.Checked \ - and self.success[number]): - delete_file(os.path.join(self.oldpath, filename)) + for number, filename in enumerate(self.files): + if self.success[number]: + delete_file(os.path.join(self.oldpath, filename)) def customInit(self): """ @@ -290,23 +286,6 @@ class BibleUpgradeForm(OpenLPWizard): self.formWidget[number].setParent(None) self.formLayout.removeItem(self.spacerItem) - def addProgressPage(self): - """ - Add the progress page for the wizard. This page informs the user how - the wizard is progressing with its task. - """ - OpenLPWizard.addProgressPage(self) - self.progressLayout.setContentsMargins(48, 48, 48, 20) - self.progressLabelAfter = QtGui.QLabel(self.progressPage) - self.progressLabelAfter.setObjectName(u'progressLabelAfter') - self.progressLayout.addWidget(self.progressLabelAfter) - self.deleteCheckBox = QtGui.QCheckBox(self.progressPage) - self.deleteCheckBox.setObjectName(u'deleteCheckBox') - self.progressLayout.addWidget(self.deleteCheckBox) - self.deleteAllCheckBox = QtGui.QCheckBox(self.progressPage) - self.deleteAllCheckBox.setObjectName(u'deleteAllCheckBox') - self.progressLayout.addWidget(self.deleteAllCheckBox) - def retranslateUi(self): """ Allow for localisation of the bible import wizard. @@ -338,16 +317,6 @@ class BibleUpgradeForm(OpenLPWizard): 'Please wait while your Bibles are upgraded.')) self.progressLabel.setText(WizardStrings.Ready) self.progressBar.setFormat(u'%p%') - self.deleteCheckBox.setText( - translate('BiblesPlugin.UpgradeWizardForm', 'Delete those files ' - 'which have been successfully upgraded.')) - self.deleteAllCheckBox.setText( - translate('BiblesPlugin.UpgradeWizardForm', 'Delete all the old ' - 'files, including those which have not been \nupgraded.')) - self.progressLabelAfter.setText( - translate('BiblesPlugin.UpgradeWizardForm', 'A copy of the ' - 'pre-upgraded Bible database files have been made. \nWould you ' - 'like to:')) def validateCurrentPage(self): """ @@ -431,11 +400,6 @@ class BibleUpgradeForm(OpenLPWizard): self.verticalWidget[number].hide() self.formWidget[number].hide() self.progressBar.show() - self.progressLabelAfter.hide() - self.deleteCheckBox.hide() - self.deleteCheckBox.setCheckState(QtCore.Qt.Unchecked) - self.deleteAllCheckBox.hide() - self.deleteAllCheckBox.setCheckState(QtCore.Qt.Unchecked) self.restart() self.finishButton.setVisible(False) self.cancelButton.setVisible(True) @@ -683,17 +647,7 @@ class BibleUpgradeForm(OpenLPWizard): translate('BiblesPlugin.UpgradeWizardForm', 'Upgrade %s ' 'Bible(s) successful.%s')) % (successful_import, failed_import_text)) - self.deleteCheckBox.show() - bibles = u'' - for bible in self.newbibles.itervalues(): - name = bible.get_name() - bibles += u'\n"' + name + u'"' - self.deleteCheckBox.setToolTip(unicode(translate( - 'BiblesPlugin.UpgradeWizardForm', - 'Successfully upgraded Bible(s):%s')) % bibles) else: self.progressLabel.setText( translate('BiblesPlugin.UpgradeWizardForm', 'Upgrade ' 'failed.')) - self.progressLabelAfter.show() - self.deleteAllCheckBox.show() From d05c349f41319dd483394297e0f04563e05bd63a Mon Sep 17 00:00:00 2001 From: Gerald Britton Date: Tue, 24 May 2011 16:41:14 -0400 Subject: [PATCH 42/97] Catch common errors during import and report to user --- openlp/plugins/songs/lib/oooimport.py | 23 ++++++++++++++++++----- openlp/plugins/songs/lib/sofimport.py | 26 ++++++++++++++++---------- 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/openlp/plugins/songs/lib/oooimport.py b/openlp/plugins/songs/lib/oooimport.py index d43541bc7..1c5c7e1ef 100644 --- a/openlp/plugins/songs/lib/oooimport.py +++ b/openlp/plugins/songs/lib/oooimport.py @@ -40,6 +40,7 @@ if os.name == u'nt': PAGE_BOTH = 6 else: import uno + from com.sun.star.connection import NoConnectException from com.sun.star.style.BreakType import PAGE_BEFORE, PAGE_AFTER, PAGE_BOTH class OooImport(SongImport): @@ -56,7 +57,16 @@ class OooImport(SongImport): self.process_started = False def do_import(self): - self.start_ooo() + if not isinstance(self.import_source, list): + return + try: + self.start_ooo() + except NoConnectException as exc: + self.log_error( + self.import_source[0], + u'Unable to connect to OpenOffice.org or LibreOffice') + log.error(exc) + return self.import_wizard.progressBar.setMaximum(len(self.import_source)) for filename in self.import_source: if self.stop_import_flag: @@ -98,13 +108,16 @@ class OooImport(SongImport): while uno_instance is None and loop < 5: try: uno_instance = get_uno_instance(resolver) - except: + except NoConnectException: log.exception("Failed to resolve uno connection") self.start_ooo_process() loop += 1 - manager = uno_instance.ServiceManager - self.desktop = manager.createInstanceWithContext( - "com.sun.star.frame.Desktop", uno_instance) + else: + manager = uno_instance.ServiceManager + self.desktop = manager.createInstanceWithContext( + "com.sun.star.frame.Desktop", uno_instance) + return + raise def start_ooo_process(self): try: diff --git a/openlp/plugins/songs/lib/sofimport.py b/openlp/plugins/songs/lib/sofimport.py index 7f9fa16bc..f35094a96 100644 --- a/openlp/plugins/songs/lib/sofimport.py +++ b/openlp/plugins/songs/lib/sofimport.py @@ -30,10 +30,14 @@ # http://www.oooforum.org/forum/viewtopic.phtml?t=14409 # http://wiki.services.openoffice.org/wiki/Python +import logging import os import re from oooimport import OooImport +from com.sun.star.uno import RuntimeException + +log = logging.getLogger(__name__) if os.name == u'nt': BOLD = 150.0 @@ -85,16 +89,18 @@ class SofImport(OooImport): """ self.blanklines = 0 self.new_song() - paragraphs = self.document.getText().createEnumeration() - while paragraphs.hasMoreElements(): - if self.stop_import_flag: - return - paragraph = paragraphs.nextElement() - if paragraph.supportsService("com.sun.star.text.Paragraph"): - self.process_paragraph(paragraph) - if self.song: - self.finish() - self.song = False + try: + paragraphs = self.document.getText().createEnumeration() + while paragraphs.hasMoreElements(): + if self.stop_import_flag: + return + paragraph = paragraphs.nextElement() + if paragraph.supportsService("com.sun.star.text.Paragraph"): + self.process_paragraph(paragraph) + except RuntimeException as exc: + log.exception(u'Error processing file: %s', exc) + if not self.finish(): + self.log_error(self.filepath) def process_paragraph(self, paragraph): """ From 0c83471ee46af92b8ca1bea64d158b92e333fb11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Wed, 25 May 2011 16:18:03 +0200 Subject: [PATCH 43/97] move some code stop moving bibles to subfolders some fixes --- openlp.pyw | 16 +-- openlp/core/ui/mainwindow.py | 9 ++ openlp/plugins/bibles/bibleplugin.py | 16 ++- .../plugins/bibles/forms/bibleimportform.py | 4 +- .../plugins/bibles/forms/bibleupgradeform.py | 105 +++++++++--------- openlp/plugins/bibles/lib/db.py | 29 +++-- openlp/plugins/bibles/lib/manager.py | 11 +- 7 files changed, 110 insertions(+), 80 deletions(-) diff --git a/openlp.pyw b/openlp.pyw index 34980b1c6..6cf3dd2da 100755 --- a/openlp.pyw +++ b/openlp.pyw @@ -37,8 +37,7 @@ from traceback import format_exception from PyQt4 import QtCore, QtGui -from openlp.core.lib import Receiver, check_directory_exists, SettingsManager, \ - translate +from openlp.core.lib import Receiver, check_directory_exists from openlp.core.lib.ui import UiStrings from openlp.core.resources import qInitResources from openlp.core.ui.mainwindow import MainWindow @@ -130,18 +129,7 @@ class OpenLP(QtGui.QApplication): u'general/update check', QtCore.QVariant(True)).toBool() if update_check: VersionThread(self.mainWindow).start() - for plugin in self.mainWindow.pluginManager.plugins: - if plugin.name == u'Bibles' and plugin.isActive() and not \ - len(SettingsManager.get_files( u'bibles/bibles', u'.sqlite')) \ - and SettingsManager.get_files(u'bibles', u'.sqlite'): - if QtGui.QMessageBox.information(self.mainWindow, - translate('OpenLP', 'Information'), translate('OpenLP', - 'Bible format has changed.\nYou have to upgrade your ' - 'existing bibles.\nShould OpenLP upgrade now?'), - QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | - QtGui.QMessageBox.No)) == QtGui.QMessageBox.Yes: - plugin.onToolsUpgradeItemTriggered() - break + self.mainWindow.appStartup() DelayStartThread(self.mainWindow).start() return self.exec_() diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 09e2ec9e7..8535670fa 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -639,6 +639,15 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.setViewMode(False, True, False, False, True) self.ModeLiveItem.setChecked(True) + def appStartup(self): + # Give all the plugins a chance to perform some tasks at startup + Receiver.send_message(u'openlp_process_events') + for plugin in self.pluginManager.plugins: + if hasattr(plugin, u'appStartup'): + Receiver.send_message(u'openlp_process_events') + plugin.appStartup() + Receiver.send_message(u'openlp_process_events') + def firstTime(self): # Import themes if first time Receiver.send_message(u'openlp_process_events') diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index fd56d9d32..c326d6c00 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -60,7 +60,7 @@ class BiblePlugin(Plugin): #action_list.add_action(self.exportBibleItem, UiStrings().Export) # Set to invisible until we can export bibles self.exportBibleItem.setVisible(False) - if SettingsManager.get_files(u'bibles', u'.sqlite'): + if len(self.manager.old_bible_databases): self.toolsUpgradeItem.setVisible(True) def finalise(self): @@ -76,6 +76,20 @@ class BiblePlugin(Plugin): #action_list.remove_action(self.exportBibleItem, UiStrings().Export) self.exportBibleItem.setVisible(False) + def appStartup(self): + """ + Perform tasks on application starup + """ + if not len(self.manager.db_cache) and \ + len(self.manager.old_bible_databases): + if QtGui.QMessageBox.information(self.formparent, + translate('OpenLP', 'Information'), translate('OpenLP', + 'Bible format has changed.\nYou have to upgrade your ' + 'existing bibles.\nShould OpenLP upgrade now?'), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | + QtGui.QMessageBox.No)) == QtGui.QMessageBox.Yes: + self.onToolsUpgradeItemTriggered() + def addImportMenuItem(self, import_menu): self.importBibleItem = base_action(import_menu, u'importBibleItem') self.importBibleItem.setText(translate('BiblesPlugin', '&Bible')) diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 8e9073775..1df6946dd 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -472,7 +472,7 @@ class BibleImportForm(OpenLPWizard): license_version = unicode(self.field(u'license_version').toString()) license_copyright = \ unicode(self.field(u'license_copyright').toString()) - path = AppLocation.get_section_data_path(u'bibles/bibles') + path = AppLocation.get_section_data_path(u'bibles') if not license_version: critical_error_message_box(UiStrings().EmptyField, translate('BiblesPlugin.ImportWizardForm', @@ -720,5 +720,5 @@ class BibleImportForm(OpenLPWizard): self.progressLabel.setText(translate( 'BiblesPlugin.ImportWizardForm', 'Your Bible import failed.')) del self.manager.db_cache[importer.name] - delete_database(AppLocation.get_section_data_path(u'bibles/bibles'), + delete_database(AppLocation.get_section_data_path(u'bibles'), importer.file) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index da75d9553..4a8ad488d 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -67,18 +67,12 @@ class BibleUpgradeForm(OpenLPWizard): self.manager = manager self.mediaItem = bibleplugin.mediaItem self.suffix = u'.sqlite' - self.settingsSection = u'bibles/bibles' - self.oldsettingsSection = u'bibles' - self.oldpath = AppLocation.get_section_data_path( - self.oldsettingsSection) - self.newpath = AppLocation.get_section_data_path( + self.settingsSection = u'bibles' + self.path = AppLocation.get_section_data_path( self.settingsSection) - self.files = SettingsManager.get_files(self.oldsettingsSection, - self.suffix) + self.files = self.manager.old_bible_databases self.success = {} self.newbibles = {} - self.maxBibles = len(self.files) - self.stop_import_flag = False OpenLPWizard.__init__(self, parent, bibleplugin, u'bibleUpgradeWizard', u':/wizards/wizard_importbible.bmp') @@ -106,7 +100,8 @@ class BibleUpgradeForm(OpenLPWizard): self.verticalWidget[number].hide() self.formWidget[number].hide() else: - if os.path.exists(os.path.join(self.newpath, filename)): + version_name = unicode(self.versionNameEdit[number].text()) + if self.manager.exists(version_name): self.verticalWidget[number].show() self.formWidget[number].show() @@ -118,7 +113,7 @@ class BibleUpgradeForm(OpenLPWizard): if self.currentPage() == self.progressPage: Receiver.send_message(u'openlp_stop_wizard') for bible in self.newbibles.itervalues(): - delete_database(self.newpath, clean_filename( + delete_database(self.path, clean_filename( bible.get_name())) self.done(QtGui.QDialog.Rejected) @@ -139,7 +134,7 @@ class BibleUpgradeForm(OpenLPWizard): """ for number, filename in enumerate(self.files): if self.success[number]: - delete_file(os.path.join(self.oldpath, filename)) + delete_file(os.path.join(self.path, filename)) def customInit(self): """ @@ -152,10 +147,6 @@ class BibleUpgradeForm(OpenLPWizard): """ Set up the signals used in the bible importer. """ - for number, filename in enumerate(self.files): - QtCore.QObject.connect(self.checkBox[number], - QtCore.SIGNAL(u'stateChanged(int)'), - self.onCheckBoxIndexChanged) QtCore.QObject.connect(self.finishButton, QtCore.SIGNAL(u'clicked()'), self.onFinishButton) @@ -195,24 +186,24 @@ class BibleUpgradeForm(OpenLPWizard): self.formWidget = {} self.formLayoutAttention = {} for number, filename in enumerate(self.files): - bible = OldBibleDB(self.mediaItem, path=self.oldpath, file=filename) + bible = OldBibleDB(self.mediaItem, path=self.path, file=filename) self.checkBox[number] = QtGui.QCheckBox(self.scrollAreaContents) - checkBoxName = u'checkBox['+unicode(number)+u']' + checkBoxName = u'checkBox[%d]' % number self.checkBox[number].setObjectName(checkBoxName) self.checkBox[number].setText(bible.get_name()) self.checkBox[number].setCheckState(QtCore.Qt.Checked) self.formLayout.addWidget(self.checkBox[number]) self.verticalWidget[number] = QtGui.QWidget(self.scrollAreaContents) - verticalWidgetName = u'verticalWidget['+unicode(number)+u']' + verticalWidgetName = u'verticalWidget[%d]' % number self.verticalWidget[number].setObjectName(verticalWidgetName) self.horizontalLayout[number] = QtGui.QHBoxLayout( self.verticalWidget[number]) self.horizontalLayout[number].setContentsMargins(25, 0, 0, 0) - horizontalLayoutName = u'horizontalLayout['+unicode(number)+u']' + horizontalLayoutName = u'horizontalLayout[%d]' % number self.horizontalLayout[number].setObjectName(horizontalLayoutName) self.versionInfoPixmap[number] = QtGui.QLabel( self.verticalWidget[number]) - versionInfoPixmapName = u'versionInfoPixmap['+unicode(number)+u']' + versionInfoPixmapName = u'versionInfoPixmap[%d]' % number self.versionInfoPixmap[number].setObjectName(versionInfoPixmapName) self.versionInfoPixmap[number].setPixmap(QtGui.QPixmap( u':/bibles/bibles_upgrade_alert.png')) @@ -221,7 +212,7 @@ class BibleUpgradeForm(OpenLPWizard): self.versionInfoPixmap[number]) self.versionInfoLabel[number] = QtGui.QLabel( self.verticalWidget[number]) - versionInfoLabelName = u'versionInfoLabel['+unicode(number)+u']' + versionInfoLabelName = u'versionInfoLabel[%d]' % number self.versionInfoLabel[number].setObjectName(versionInfoLabelName) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred) @@ -234,13 +225,12 @@ class BibleUpgradeForm(OpenLPWizard): self.versionInfoLabel[number]) self.formLayout.addWidget(self.verticalWidget[number]) self.formWidget[number] = QtGui.QWidget(self.scrollAreaContents) - formWidgetName = u'formWidget['+unicode(number)+u']' + formWidgetName = u'formWidget[%d]' % number self.formWidget[number].setObjectName(formWidgetName) self.formLayoutAttention[number] = QtGui.QFormLayout( self.formWidget[number]) self.formLayoutAttention[number].setContentsMargins(25, 0, 0, 5) - formLayoutAttentionName = u'formLayoutAttention['+unicode(number)+\ - u']' + formLayoutAttentionName = u'formLayoutAttention[%d]' % number self.formLayoutAttention[number].setObjectName( formLayoutAttentionName) self.versionNameLabel[number] = QtGui.QLabel( @@ -255,6 +245,10 @@ class BibleUpgradeForm(OpenLPWizard): QtGui.QFormLayout.FieldRole, self.versionNameEdit[number]) self.versionNameEdit[number].setText(bible.get_name()) self.formLayout.addWidget(self.formWidget[number]) + #Set up the Signal for the checkbox + QtCore.QObject.connect(self.checkBox[number], + QtCore.SIGNAL(u'stateChanged(int)'), + self.onCheckBoxIndexChanged) self.spacerItem = QtGui.QSpacerItem(20, 5, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.formLayout.addItem(self.spacerItem) @@ -329,7 +323,7 @@ class BibleUpgradeForm(OpenLPWizard): if not self.checkBox[number].checkState() == QtCore.Qt.Checked: continue version_name = unicode(self.versionNameEdit[number].text()) - oldbible = OldBibleDB(self.mediaItem, path=self.oldpath, + oldbible = OldBibleDB(self.mediaItem, path=self.path, file=filename) oldname = oldbible.get_name() if not version_name: @@ -348,18 +342,28 @@ class BibleUpgradeForm(OpenLPWizard): 'uncheck.')) self.versionNameEdit[number].setFocus() return False - elif os.path.exists(os.path.join(self.newpath, filename)) and \ - version_name == oldname: - critical_error_message_box( - translate('BiblesPlugin.UpgradeWizardForm', + elif os.path.exists(os.path.join(self.path, clean_filename( + version_name))) and version_name == oldname: + newfilename = u'old_database_%s' % filename + if not os.path.exists(os.path.join(self.path, + newfilename)): + os.rename(os.path.join(self.path, filename), + os.path.join(self.path, newfilename)) + self.files[number] = newfilename + continue + else: + critical_error_message_box( + translate('BiblesPlugin.UpgradeWizardForm', 'Bible Exists'), - translate('BiblesPlugin.UpgradeWizardForm', - 'This Bible already exists. Please upgrade ' - 'a different Bible, delete the existing one or ' - 'uncheck.')) - self.versionNameEdit[number].setFocus() - return False - elif os.path.exists(os.path.join(self.newpath, + translate('BiblesPlugin.UpgradeWizardForm', + 'This Bible already exists. Please upgrade ' + 'a different Bible, delete the existing one or ' + 'uncheck.')) + self.verticalWidget[number].show() + self.formWidget[number].show() + self.versionNameEdit[number].setFocus() + return False + elif os.path.exists(os.path.join(self.path, clean_filename(version_name))): critical_error_message_box( translate('BiblesPlugin.UpgradeWizardForm', @@ -385,15 +389,16 @@ class BibleUpgradeForm(OpenLPWizard): self.success.clear() self.newbibles.clear() self.clearScrollArea() - self.files = SettingsManager.get_files(self.oldsettingsSection, - self.suffix) + self.files = self.manager.old_bible_databases self.addScrollArea() - self.customSignals() self.retranslateUi() self.maxBibles = len(self.files) for number, filename in enumerate(self.files): self.checkBox[number].setCheckState(QtCore.Qt.Checked) - if os.path.exists(os.path.join(self.newpath, filename)): + oldbible = OldBibleDB(self.mediaItem, path=self.path, + file=filename) + oldname = oldbible.get_name() + if self.manager.exists(oldname): self.verticalWidget[number].show() self.formWidget[number].show() else: @@ -440,11 +445,11 @@ class BibleUpgradeForm(OpenLPWizard): if not self.checkBox[biblenumber].checkState() == QtCore.Qt.Checked: continue self.progressBar.reset() - oldbible = OldBibleDB(self.mediaItem, path=self.oldpath, + oldbible = OldBibleDB(self.mediaItem, path=self.path, file=filename) name = oldbible.get_name() if name is None: - delete_file(os.path.join(self.oldpath, filename)) + delete_file(os.path.join(self.path, filename)) self.incrementProgressBar(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\nFailed')) % @@ -456,9 +461,9 @@ class BibleUpgradeForm(OpenLPWizard): 'BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\nImporting ...')) % (number + 1, self.maxBibles, name)) - if os.path.exists(os.path.join(self.newpath, filename)): + if os.path.exists(os.path.join(self.path, filename)): name = unicode(self.versionNameEdit[biblenumber].text()) - self.newbibles[number] = BibleDB(self.mediaItem, path=self.oldpath, + self.newbibles[number] = BibleDB(self.mediaItem, path=self.path, name=name) metadata = oldbible.get_metadata() webbible = False @@ -488,7 +493,7 @@ class BibleUpgradeForm(OpenLPWizard): u'name: "%s" failed' % ( meta_data[u'download source'], meta_data[u'download name'])) - delete_database(self.newpath, + delete_database(self.path, clean_filename(self.newbibles[number].get_name())) del self.newbibles[number] critical_error_message_box( @@ -517,7 +522,7 @@ class BibleUpgradeForm(OpenLPWizard): if not language_id: log.exception(u'Upgrading from "%s" '\ 'failed' % filename) - delete_database(self.newpath, + delete_database(self.path, clean_filename(self.newbibles[number].get_name())) del self.newbibles[number] self.incrementProgressBar(unicode(translate( @@ -543,7 +548,7 @@ class BibleUpgradeForm(OpenLPWizard): u'name: "%s" aborted by user' % ( meta_data[u'download source'], meta_data[u'download name'])) - delete_database(self.newpath, + delete_database(self.path, clean_filename(self.newbibles[number].get_name())) del self.newbibles[number] bible_failed = True @@ -559,7 +564,7 @@ class BibleUpgradeForm(OpenLPWizard): if not language_id: log.exception(u'Importing books from "%s" '\ 'failed' % name) - delete_database(self.newpath, + delete_database(self.path, clean_filename(self.newbibles[number].get_name())) del self.newbibles[number] self.incrementProgressBar(unicode(translate( @@ -585,7 +590,7 @@ class BibleUpgradeForm(OpenLPWizard): if not book_ref_id: log.exception(u'Importing books from %s " '\ 'failed - aborted by user' % name) - delete_database(self.newpath, + delete_database(self.path, clean_filename(self.newbibles[number].get_name())) del self.newbibles[number] bible_failed = True diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 0bbaaaf1b..9ece16500 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -62,18 +62,18 @@ class Verse(BaseModel): """ pass -def clean_filename(old_filename): +def clean_filename(filename): """ Clean up the version name of the Bible and convert it into a valid file name. - ``old_filename`` + ``filename`` The "dirty" file name or version name. """ - if not isinstance(old_filename, unicode): - old_filename = unicode(old_filename, u'utf-8') - old_filename = re.sub(r'[^\w]+', u'_', old_filename).strip(u'_') - return old_filename + u'.sqlite' + if not isinstance(filename, unicode): + filename = unicode(filename, u'utf-8') + filename = re.sub(r'[^\w]+', u'_', filename).strip(u'_') + return filename + u'.sqlite' def init_schema(url): """ @@ -160,7 +160,7 @@ class BibleDB(QtCore.QObject, Manager): self.file = clean_filename(self.name) if u'file' in kwargs: self.file = kwargs[u'file'] - Manager.__init__(self, u'bibles/bibles', init_schema, self.file) + Manager.__init__(self, u'bibles', init_schema, self.file) if u'file' in kwargs: self.get_name() if u'path' in kwargs: @@ -487,6 +487,16 @@ class BibleDB(QtCore.QObject, Manager): self.create_meta(u'language_id', language_id) return language_id + def find_old_database(self): + """ + Returns true if it is an old bible database. + """ + try: + columns = self.session.query(Book).all() + except: + return True + return False + def dump_bible(self): """ Utility debugging method to dump the contents of a bible. @@ -863,12 +873,9 @@ class AlternativeBookNamesDB(QtCore.QObject, Manager): database doesn't exist. """ if AlternativeBookNamesDB.cursor is None: - check_directory_exists(os.path.join(AppLocation.get_directory( - AppLocation.DataDir), u'bibles', u'resources')) filepath = os.path.join( AppLocation.get_directory(AppLocation.DataDir), u'bibles', - u'resources', u'alternative_book_names.sqlite') - log.debug(u'Filepath: %s' % filepath) + u'alternative_book_names.sqlite') if not os.path.exists(filepath): #create new DB, create table alternative_book_names AlternativeBookNamesDB.conn = sqlite3.connect(filepath) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index ee5491878..12490ba24 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -33,7 +33,7 @@ from openlp.core.lib import Receiver, SettingsManager, translate from openlp.core.lib.ui import critical_error_message_box from openlp.core.utils import AppLocation, delete_file from openlp.plugins.bibles.lib import parse_reference -from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta +from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta, OldBibleDB from csvbible import CSVBible from http import HTTPBible from opensong import OpenSongBible @@ -120,7 +120,7 @@ class BibleManager(object): """ log.debug(u'Bible Initialising') self.parent = parent - self.settingsSection = u'bibles/bibles' + self.settingsSection = u'bibles' self.web = u'Web' self.db_cache = None self.path = AppLocation.get_section_data_path(self.settingsSection) @@ -140,8 +140,11 @@ class BibleManager(object): """ log.debug(u'Reload bibles') files = SettingsManager.get_files(self.settingsSection, self.suffix) + if u'alternative_book_names.sqlite' in files: + files.remove(u'alternative_book_names.sqlite') log.debug(u'Bible Files %s', files) self.db_cache = {} + self.old_bible_databases = [] for filename in files: bible = BibleDB(self.parent, path=self.path, file=filename) name = bible.get_name() @@ -149,6 +152,10 @@ class BibleManager(object): if name is None: delete_file(os.path.join(self.path, filename)) continue + # Find old database versions + if bible.find_old_database(): + self.old_bible_databases.append(filename) + continue log.debug(u'Bible Name: "%s"', name) self.db_cache[name] = bible # Look to see if lazy load bible exists and get create getter. From e8cdba44bece32d6dcbc42f1c8cad548af9e636b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Wed, 25 May 2011 16:52:46 +0200 Subject: [PATCH 44/97] small clean up --- openlp/plugins/bibles/bibleplugin.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 75432a0e9..16607d569 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -29,8 +29,7 @@ import logging from PyQt4 import QtCore, QtGui -from openlp.core.lib import Plugin, StringContent, build_icon, translate, \ - SettingsManager +from openlp.core.lib import Plugin, StringContent, build_icon, translate from openlp.core.lib.ui import base_action, UiStrings from openlp.core.utils.actions import ActionList from openlp.plugins.bibles.lib import BibleManager, BiblesTab, BibleMediaItem From 175d6cebb24d168931c1161b9e06d7462aa21fcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Wed, 25 May 2011 21:13:37 +0200 Subject: [PATCH 45/97] add Bible Name to LanguageDialog renamed "Importing" to "Upgrading" and "Choose" to "Select" fixed traceback while textsearch removed unnecessary code --- openlp/plugins/bibles/bibleplugin.py | 5 ++--- .../plugins/bibles/forms/bibleimportform.py | 1 - .../plugins/bibles/forms/bibleupgradeform.py | 21 ++++++++++--------- openlp/plugins/bibles/forms/booknamedialog.py | 6 +++--- openlp/plugins/bibles/forms/booknameform.py | 2 +- openlp/plugins/bibles/forms/languagedialog.py | 6 +++--- openlp/plugins/bibles/forms/languageform.py | 9 ++++++-- openlp/plugins/bibles/lib/db.py | 13 ++++++------ openlp/plugins/bibles/lib/manager.py | 2 +- 9 files changed, 35 insertions(+), 30 deletions(-) diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 16607d569..4d43ab76d 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -80,8 +80,7 @@ class BiblePlugin(Plugin): """ Perform tasks on application starup """ - if not len(self.manager.db_cache) and \ - len(self.manager.old_bible_databases): + if len(self.manager.old_bible_databases): if QtGui.QMessageBox.information(self.formparent, translate('OpenLP', 'Information'), translate('OpenLP', 'Bible format has changed.\nYou have to upgrade your ' @@ -114,7 +113,7 @@ class BiblePlugin(Plugin): The actual **Tools** menu item, so that your actions can use it as their parent. """ - log.info(u'add tools menu') + log.debug(u'add tools menu') self.toolsUpgradeItem = QtGui.QAction(tools_menu) self.toolsUpgradeItem.setObjectName(u'toolsUpgradeItem') self.toolsUpgradeItem.setText( diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 81db1597d..cd793f7e7 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -31,7 +31,6 @@ import csv import logging import os import os.path -import re from PyQt4 import QtCore, QtGui diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 4a8ad488d..3ddf66f10 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -305,7 +305,8 @@ class BibleUpgradeForm(OpenLPWizard): self.versionInfoLabel[number].setText( translate('BiblesPlugin.UpgradeWizardForm', 'This ' 'Bible still exists. Please change the name or uncheck it.')) - self.progressPage.setTitle(WizardStrings.Importing) + self.progressPage.setTitle(translate('BiblesPlugin.UpgradeWizardForm', + 'Upgrading')) self.progressPage.setSubTitle( translate('BiblesPlugin.UpgradeWizardForm', 'Please wait while your Bibles are upgraded.')) @@ -459,7 +460,7 @@ class BibleUpgradeForm(OpenLPWizard): continue self.progressLabel.setText(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', - 'Upgrading Bible %s of %s: "%s"\nImporting ...')) % + 'Upgrading Bible %s of %s: "%s"\nUpgrading ...')) % (number + 1, self.maxBibles, name)) if os.path.exists(os.path.join(self.path, filename)): name = unicode(self.versionNameEdit[biblenumber].text()) @@ -489,7 +490,7 @@ class BibleUpgradeForm(OpenLPWizard): handler = BSExtract(proxy_server) books = handler.get_books_from_http(meta_data[u'download name']) if not books: - log.exception(u'Importing books from %s - download '\ + log.exception(u'Upgrading books from %s - download '\ u'name: "%s" failed' % ( meta_data[u'download source'], meta_data[u'download name'])) @@ -518,7 +519,7 @@ class BibleUpgradeForm(OpenLPWizard): self.newbibles[number].create_meta(u'language_id', language_id) else: - language_id = self.newbibles[number].get_language() + language_id = self.newbibles[number].get_language(name) if not language_id: log.exception(u'Upgrading from "%s" '\ 'failed' % filename) @@ -539,12 +540,12 @@ class BibleUpgradeForm(OpenLPWizard): self.incrementProgressBar(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\n' - 'Importing %s ...')) % + 'Upgrading %s ...')) % (number+1, self.maxBibles, name, book)) book_ref_id = self.newbibles[number].\ get_book_ref_id_by_name(book, len(books), language_id) if not book_ref_id: - log.exception(u'Importing books from %s - download '\ + log.exception(u'Upgrading books from %s - download '\ u'name: "%s" aborted by user' % ( meta_data[u'download source'], meta_data[u'download name'])) @@ -560,9 +561,9 @@ class BibleUpgradeForm(OpenLPWizard): language_id = self.newbibles[number].get_object(BibleMeta, u'language_id') if not language_id: - language_id = self.newbibles[number].get_language() + language_id = self.newbibles[number].get_language(name) if not language_id: - log.exception(u'Importing books from "%s" '\ + log.exception(u'Upgrading books from "%s" '\ 'failed' % name) delete_database(self.path, clean_filename(self.newbibles[number].get_name())) @@ -582,13 +583,13 @@ class BibleUpgradeForm(OpenLPWizard): self.incrementProgressBar(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\n' - 'Importing %s ...')) % + 'Upgrading %s ...')) % (number+1, self.maxBibles, name, book[u'name'])) book_ref_id = self.newbibles[number].\ get_book_ref_id_by_name(book[u'name'], len(books), language_id) if not book_ref_id: - log.exception(u'Importing books from %s " '\ + log.exception(u'Upgrading books from %s " '\ 'failed - aborted by user' % name) delete_database(self.path, clean_filename(self.newbibles[number].get_name())) diff --git a/openlp/plugins/bibles/forms/booknamedialog.py b/openlp/plugins/bibles/forms/booknamedialog.py index 20e96b922..632007013 100644 --- a/openlp/plugins/bibles/forms/booknamedialog.py +++ b/openlp/plugins/bibles/forms/booknamedialog.py @@ -100,12 +100,12 @@ class Ui_BookNameDialog(object): def retranslateUi(self, bookNameDialog): bookNameDialog.setWindowTitle( - translate('BiblesPlugin.BookNameDialog', 'Choose Book')) + translate('BiblesPlugin.BookNameDialog', 'Select Book')) self.headlineLabel.setText( - translate('BiblesPlugin.BookNameDialog', 'Choose Book:')) + translate('BiblesPlugin.BookNameDialog', 'Select Book:')) self.infoLabel.setText(translate('BiblesPlugin.BookNameDialog', 'The following books cannot be clearly attributed. \n' - 'Please choose which book it is.')) + 'Please select which book it is.')) self.requestLabel.setText(translate('BiblesPlugin.BookNameDialog', 'Book:')) self.infoLabelTestaments.setText(translate( diff --git a/openlp/plugins/bibles/forms/booknameform.py b/openlp/plugins/bibles/forms/booknameform.py index 425e20e41..fdb383a8c 100644 --- a/openlp/plugins/bibles/forms/booknameform.py +++ b/openlp/plugins/bibles/forms/booknameform.py @@ -116,7 +116,7 @@ class BookNameForm(QDialog, Ui_BookNameDialog): if self.requestComboBox.currentText() == u'': critical_error_message_box( message=translate('BiblesPlugin.BookNameForm', - 'You need to choose a book.')) + 'You need to select a book.')) self.requestComboBox.setFocus() return False else: diff --git a/openlp/plugins/bibles/forms/languagedialog.py b/openlp/plugins/bibles/forms/languagedialog.py index 7f3580279..0edcb74d8 100644 --- a/openlp/plugins/bibles/forms/languagedialog.py +++ b/openlp/plugins/bibles/forms/languagedialog.py @@ -85,10 +85,10 @@ class Ui_LanguageDialog(object): def retranslateUi(self, languageDialog): languageDialog.setWindowTitle( - translate('BiblesPlugin.LanguageDialog', 'Choose Language')) + translate('BiblesPlugin.LanguageDialog', 'Select Language')) self.headlineLabel.setText( - translate('BiblesPlugin.LanguageDialog', 'Choose Language:')) + translate('BiblesPlugin.LanguageDialog', 'Select Language:')) self.infoLabel.setText(translate('BiblesPlugin.LanguageDialog', - 'Please choose the Bible\'s language')) + 'Please select the Bible\'s language')) self.requestLabel.setText(translate('BiblesPlugin.languageDialog', 'Language:')) diff --git a/openlp/plugins/bibles/forms/languageform.py b/openlp/plugins/bibles/forms/languageform.py index 6235c6385..0e2c3f003 100644 --- a/openlp/plugins/bibles/forms/languageform.py +++ b/openlp/plugins/bibles/forms/languageform.py @@ -52,8 +52,13 @@ class LanguageForm(QDialog, Ui_LanguageDialog): QDialog.__init__(self, parent) self.setupUi(self) - def exec_(self): + def exec_(self, bible_name): self.requestComboBox.addItem(u'') + if bible_name: + self.infoLabel.setText(unicode(translate( + 'BiblesPlugin.LanguageDialog', + 'Please select the language for Bible:\n"%s"')) % + bible_name) items = BiblesResourcesDB.get_languages() for item in items: self.requestComboBox.addItem(item[u'name']) @@ -63,7 +68,7 @@ class LanguageForm(QDialog, Ui_LanguageDialog): if self.requestComboBox.currentText() == u'': critical_error_message_box( message=translate('BiblesPlugin.LanguageForm', - 'You need to choose a language.')) + 'You need to select a language.')) self.requestComboBox.setFocus() return False else: diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 8902593ca..7278da42f 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -396,7 +396,7 @@ class BibleDB(QtCore.QObject, Manager): .all() verse_list.extend(verses) else: - log.debug(u'OpenLP failed to find book %s', book) + log.debug(u'OpenLP failed to find book with id "%s"', book_id) if show_error: critical_error_message_box( translate('BiblesPlugin', 'No Book Found'), @@ -466,10 +466,10 @@ class BibleDB(QtCore.QObject, Manager): else: return count - def get_language(self): + def get_language(self, bible_name=None): """ If no language is given it calls a dialog window where the user could - choose the bible language. + select the bible language. Return the language id of a bible. ``book`` @@ -479,7 +479,7 @@ class BibleDB(QtCore.QObject, Manager): from openlp.plugins.bibles.forms import LanguageForm language = None language_form = LanguageForm(self.wizard) - if language_form.exec_(): + if language_form.exec_(bible_name): language = unicode(language_form.requestComboBox.currentText()) if not language: return False @@ -488,9 +488,10 @@ class BibleDB(QtCore.QObject, Manager): self.create_meta(u'language_id', language_id) return language_id - def find_old_database(self): + def is_old_database(self): """ - Returns true if it is an old bible database. + Returns ``True`` if it is a bible database, which has been created + prior to 1.9.6. """ try: columns = self.session.query(Book).all() diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 6b854eb44..7086c02c5 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -154,7 +154,7 @@ class BibleManager(object): delete_file(os.path.join(self.path, filename)) continue # Find old database versions - if bible.find_old_database(): + if bible.is_old_database(): self.old_bible_databases.append(filename) continue log.debug(u'Bible Name: "%s"', name) From 0f98c4fd8fe74481a2b2694262d73811769408e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Wed, 25 May 2011 22:20:17 +0200 Subject: [PATCH 46/97] change behaviour if "Cancel" button is pushed. --- .../plugins/bibles/forms/bibleupgradeform.py | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 3ddf66f10..b210b7c95 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -110,12 +110,7 @@ class BibleUpgradeForm(OpenLPWizard): Stop the wizard on cancel button, close button or ESC key. """ log.debug(u'Wizard cancelled by user') - if self.currentPage() == self.progressPage: - Receiver.send_message(u'openlp_stop_wizard') - for bible in self.newbibles.itervalues(): - delete_database(self.path, clean_filename( - bible.get_name())) - self.done(QtGui.QDialog.Rejected) + self.stop_import_flag = True def onCurrentIdChanged(self, pageId): """ @@ -133,7 +128,7 @@ class BibleUpgradeForm(OpenLPWizard): Some cleanup while finishing """ for number, filename in enumerate(self.files): - if self.success[number]: + if number in self.success and self.success[number] == True: delete_file(os.path.join(self.path, filename)) def customInit(self): @@ -440,6 +435,7 @@ class BibleUpgradeForm(OpenLPWizard): number = 0 for biblenumber, filename in enumerate(self.files): if self.stop_import_flag: + bible_failed = True break bible_failed = False self.success[biblenumber] = False @@ -536,6 +532,7 @@ class BibleUpgradeForm(OpenLPWizard): self.progressBar.setMaximum(len(books)) for book in books: if self.stop_import_flag: + bible_failed = True break self.incrementProgressBar(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', @@ -579,6 +576,7 @@ class BibleUpgradeForm(OpenLPWizard): self.progressBar.setMaximum(len(books)) for book in books: if self.stop_import_flag: + bible_failed = True break self.incrementProgressBar(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', @@ -624,15 +622,17 @@ class BibleUpgradeForm(OpenLPWizard): 'Upgrading Bible %s of %s: "%s"\nFailed')) % (number+1, self.maxBibles, name), self.progressBar.maximum()-self.progressBar.value()) + delete_database(self.path, + clean_filename(self.newbibles[number].get_name())) number += 1 self.mediaItem.reloadBibles() successful_import = 0 failed_import = 0 - for number, success in self.success.iteritems(): - if success == True: + for number, filename in enumerate(self.files): + #for number, success in self.success.iteritems(): + if number in self.success and self.success[number] == True: successful_import += 1 - elif success == False and self.checkBox[number].checkState() == \ - QtCore.Qt.Checked: + elif self.checkBox[number].checkState() == QtCore.Qt.Checked: failed_import += 1 if failed_import > 0: failed_import_text = unicode(translate( From 4399fc108f18000715ec6ee8caa7b50f601ad21f Mon Sep 17 00:00:00 2001 From: Gerald Britton Date: Wed, 25 May 2011 17:38:32 -0400 Subject: [PATCH 47/97] Fixed a silent error when OpenOffice fails to open a file.\ Also, added the file name to the exception log and made the exception explicit --- openlp/plugins/songs/lib/oooimport.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/lib/oooimport.py b/openlp/plugins/songs/lib/oooimport.py index f570f33d3..a03a36121 100644 --- a/openlp/plugins/songs/lib/oooimport.py +++ b/openlp/plugins/songs/lib/oooimport.py @@ -80,6 +80,10 @@ class OooImport(SongImport): if self.document: self.process_ooo_document() self.close_ooo_file() + else: + self.log_error(self.filepath) + else: + self.log_error(self.filepath) self.close_ooo() def process_ooo_document(self): @@ -160,8 +164,8 @@ class OooImport(SongImport): else: self.import_wizard.incrementProgressBar( u'Processing file ' + filepath, 0) - except: - log.exception("open_ooo_file failed") + except AttributeError: + log.exception("open_ooo_file failed: %s", url) return def close_ooo_file(self): From 29305104617dee05043d96b7a16b344d7ba644a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Thu, 26 May 2011 09:00:40 +0200 Subject: [PATCH 48/97] change languageform like Raoul suggest --- openlp/plugins/bibles/forms/languagedialog.py | 94 +++++++++---------- openlp/plugins/bibles/forms/languageform.py | 15 +-- openlp/plugins/bibles/lib/db.py | 2 +- 3 files changed, 51 insertions(+), 60 deletions(-) diff --git a/openlp/plugins/bibles/forms/languagedialog.py b/openlp/plugins/bibles/forms/languagedialog.py index 0edcb74d8..5c1325a54 100644 --- a/openlp/plugins/bibles/forms/languagedialog.py +++ b/openlp/plugins/bibles/forms/languagedialog.py @@ -27,68 +27,58 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate -from openlp.core.lib.ui import create_accept_reject_button_box class Ui_LanguageDialog(object): def setupUi(self, languageDialog): - languageDialog.setObjectName(u'LanugageDialog') - languageDialog.resize(400, 175) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, - QtGui.QSizePolicy.MinimumExpanding) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(languageDialog.sizePolicy() - .hasHeightForWidth()) - languageDialog.setSizePolicy(sizePolicy) - self.widget = QtGui.QWidget(languageDialog) - self.widget.setGeometry(QtCore.QRect(10, 15, 381, 151)) - self.widget.setObjectName(u'widget') - self.verticalLayout = QtGui.QVBoxLayout(self.widget) - self.verticalLayout.setObjectName(u'verticalLayout') - self.headlineLabel = QtGui.QLabel(self.widget) - font = QtGui.QFont() - font.setFamily(u'Arial') - font.setPointSize(11) - font.setWeight(75) - font.setBold(True) - self.headlineLabel.setFont(font) - self.headlineLabel.setObjectName(u'HeadlineLabel') - self.verticalLayout.addWidget(self.headlineLabel) - self.infoLabel = QtGui.QLabel(self.widget) - self.infoLabel.setObjectName(u'InfoLabel') - self.verticalLayout.addWidget(self.infoLabel) - self.formLayout = QtGui.QFormLayout() - self.formLayout.setObjectName(u'formLayout') - self.requestLabel = QtGui.QLabel(self.widget) - self.requestLabel.setObjectName(u'RequestLabel') - self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, - self.requestLabel) - self.requestComboBox = QtGui.QComboBox(self.widget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, + languageDialog.setObjectName(u'languageDialog') + languageDialog.resize(400, 165) + self.languageLayout = QtGui.QVBoxLayout(languageDialog) + self.languageLayout.setSpacing(8) + self.languageLayout.setMargin(8) + self.languageLayout.setObjectName(u'languageLayout') + self.bibleLabel = QtGui.QLabel(languageDialog) + self.bibleLabel.setObjectName(u'bibleLabel') + self.languageLayout.addWidget(self.bibleLabel) + self.infoLabel = QtGui.QLabel(languageDialog) + self.infoLabel.setWordWrap(True) + self.infoLabel.setObjectName(u'infoLabel') + self.languageLayout.addWidget(self.infoLabel) + self.languageHBoxLayout = QtGui.QHBoxLayout() + self.languageHBoxLayout.setSpacing(8) + self.languageHBoxLayout.setObjectName(u'languageHBoxLayout') + self.languageLabel = QtGui.QLabel(languageDialog) + self.languageLabel.setObjectName(u'languageLabel') + self.languageHBoxLayout.addWidget(self.languageLabel) + self.languageComboBox = QtGui.QComboBox(languageDialog) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.requestComboBox.sizePolicy() - .hasHeightForWidth()) - self.requestComboBox.setSizePolicy(sizePolicy) - self.requestComboBox.setObjectName(u'RequestComboBox') - self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, - self.requestComboBox) - self.verticalLayout.addLayout(self.formLayout) - spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, - QtGui.QSizePolicy.Expanding) - self.verticalLayout.addItem(spacerItem) - self.formLayout.addWidget( - create_accept_reject_button_box(languageDialog)) + sizePolicy.setHeightForWidth( + self.languageComboBox.sizePolicy().hasHeightForWidth()) + self.languageComboBox.setSizePolicy(sizePolicy) + self.languageComboBox.setObjectName(u'languageComboBox') + self.languageHBoxLayout.addWidget(self.languageComboBox) + self.languageLayout.addLayout(self.languageHBoxLayout) + self.buttonBox = QtGui.QDialogButtonBox(languageDialog) + self.buttonBox.setOrientation(QtCore.Qt.Horizontal) + self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel| + QtGui.QDialogButtonBox.Ok) + self.buttonBox.setObjectName(u'buttonBox') + self.languageLayout.addWidget(self.buttonBox) + self.retranslateUi(languageDialog) - QtCore.QMetaObject.connectSlotsByName(languageDialog) + QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'accepted()'), + languageDialog.accept) + QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(u'rejected()'), + languageDialog.reject) def retranslateUi(self, languageDialog): languageDialog.setWindowTitle( translate('BiblesPlugin.LanguageDialog', 'Select Language')) - self.headlineLabel.setText( - translate('BiblesPlugin.LanguageDialog', 'Select Language:')) + self.bibleLabel.setText(translate('BiblesPlugin.LanguageDialog', '')) self.infoLabel.setText(translate('BiblesPlugin.LanguageDialog', - 'Please select the Bible\'s language')) - self.requestLabel.setText(translate('BiblesPlugin.languageDialog', + 'OpenLP is unable to determine the language of this translation ' + 'of the Bible. Please select the language from the list below.')) + self.languageLabel.setText(translate('BiblesPlugin.LanguageDialog', 'Language:')) diff --git a/openlp/plugins/bibles/forms/languageform.py b/openlp/plugins/bibles/forms/languageform.py index 0e2c3f003..e7cde104c 100644 --- a/openlp/plugins/bibles/forms/languageform.py +++ b/openlp/plugins/bibles/forms/languageform.py @@ -53,23 +53,24 @@ class LanguageForm(QDialog, Ui_LanguageDialog): self.setupUi(self) def exec_(self, bible_name): - self.requestComboBox.addItem(u'') + self.languageComboBox.addItem(u'') if bible_name: self.infoLabel.setText(unicode(translate( 'BiblesPlugin.LanguageDialog', - 'Please select the language for Bible:\n"%s"')) % - bible_name) + 'OpenLP is unable to determine the language of this translation' + ' of the Bible. Please select the language for "%s" from the ' + 'list below.')) % bible_name) items = BiblesResourcesDB.get_languages() for item in items: - self.requestComboBox.addItem(item[u'name']) + self.languageComboBox.addItem(item[u'name']) return QDialog.exec_(self) def accept(self): - if self.requestComboBox.currentText() == u'': + if self.languageComboBox.currentText() == u'': critical_error_message_box( message=translate('BiblesPlugin.LanguageForm', - 'You need to select a language.')) - self.requestComboBox.setFocus() + 'You need to choose a language.')) + self.languageComboBox.setFocus() return False else: return QDialog.accept(self) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 7278da42f..a3eb0e849 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -480,7 +480,7 @@ class BibleDB(QtCore.QObject, Manager): language = None language_form = LanguageForm(self.wizard) if language_form.exec_(bible_name): - language = unicode(language_form.requestComboBox.currentText()) + language = unicode(language_form.languageComboBox.currentText()) if not language: return False language = BiblesResourcesDB.get_language(language) From 6486d41b8cc86dd9a9c5fc76f9907cb782386a54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Thu, 26 May 2011 09:25:17 +0200 Subject: [PATCH 49/97] correct some words and code changed behaviour if the "cancel" button is pressed while upgrading --- openlp/plugins/bibles/bibleplugin.py | 2 +- .../plugins/bibles/forms/bibleupgradeform.py | 34 +++++++++---------- openlp/plugins/bibles/lib/http.py | 20 +++++------ 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 4d43ab76d..0ec8b8ed5 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -84,7 +84,7 @@ class BiblePlugin(Plugin): if QtGui.QMessageBox.information(self.formparent, translate('OpenLP', 'Information'), translate('OpenLP', 'Bible format has changed.\nYou have to upgrade your ' - 'existing bibles.\nShould OpenLP upgrade now?'), + 'existing Bibles.\nShould OpenLP upgrade now?'), QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)) == QtGui.QMessageBox.Yes: self.onToolsUpgradeItemTriggered() diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index b210b7c95..7b7c259ac 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -111,6 +111,8 @@ class BibleUpgradeForm(OpenLPWizard): """ log.debug(u'Wizard cancelled by user') self.stop_import_flag = True + if not self.currentPage() == self.progressPage: + self.done(QtGui.QDialog.Rejected) def onCurrentIdChanged(self, pageId): """ @@ -413,7 +415,7 @@ class BibleUpgradeForm(OpenLPWizard): OpenLPWizard.preWizard(self) self.progressLabel.setText(translate( 'BiblesPlugin.UpgradeWizardForm', - 'Starting upgrading bible(s)...')) + 'Starting upgrading Bible(s)...')) Receiver.send_message(u'openlp_process_events') def performWizard(self): @@ -450,7 +452,7 @@ class BibleUpgradeForm(OpenLPWizard): self.incrementProgressBar(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\nFailed')) % - (number+1, self.maxBibles, name), + (number + 1, self.maxBibles, name), self.progressBar.maximum() - self.progressBar.value()) number += 1 continue @@ -503,8 +505,8 @@ class BibleUpgradeForm(OpenLPWizard): self.incrementProgressBar(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\nFailed')) % - (number+1, self.maxBibles, name), - self.progressBar.maximum()-self.progressBar.value()) + (number + 1, self.maxBibles, name), + self.progressBar.maximum() - self.progressBar.value()) number += 1 continue bible = BiblesResourcesDB.get_webbible( @@ -517,16 +519,15 @@ class BibleUpgradeForm(OpenLPWizard): else: language_id = self.newbibles[number].get_language(name) if not language_id: - log.exception(u'Upgrading from "%s" '\ - 'failed' % filename) + log.exception(u'Upgrading from "%s" failed' % filename) delete_database(self.path, clean_filename(self.newbibles[number].get_name())) del self.newbibles[number] self.incrementProgressBar(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\nFailed')) % - (number+1, self.maxBibles, name), - self.progressBar.maximum()-self.progressBar.value()) + (number + 1, self.maxBibles, name), + self.progressBar.maximum() - self.progressBar.value()) number += 1 continue self.progressBar.setMaximum(len(books)) @@ -538,7 +539,7 @@ class BibleUpgradeForm(OpenLPWizard): 'BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\n' 'Upgrading %s ...')) % - (number+1, self.maxBibles, name, book)) + (number + 1, self.maxBibles, name, book)) book_ref_id = self.newbibles[number].\ get_book_ref_id_by_name(book, len(books), language_id) if not book_ref_id: @@ -560,16 +561,15 @@ class BibleUpgradeForm(OpenLPWizard): if not language_id: language_id = self.newbibles[number].get_language(name) if not language_id: - log.exception(u'Upgrading books from "%s" '\ - 'failed' % name) + log.exception(u'Upgrading books from "%s" failed' % name) delete_database(self.path, clean_filename(self.newbibles[number].get_name())) del self.newbibles[number] self.incrementProgressBar(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\nFailed')) % - (number+1, self.maxBibles, name), - self.progressBar.maximum()-self.progressBar.value()) + (number + 1, self.maxBibles, name), + self.progressBar.maximum() - self.progressBar.value()) number += 1 continue books = oldbible.get_books() @@ -582,7 +582,7 @@ class BibleUpgradeForm(OpenLPWizard): 'BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\n' 'Upgrading %s ...')) % - (number+1, self.maxBibles, name, book[u'name'])) + (number + 1, self.maxBibles, name, book[u'name'])) book_ref_id = self.newbibles[number].\ get_book_ref_id_by_name(book[u'name'], len(books), language_id) @@ -614,14 +614,14 @@ class BibleUpgradeForm(OpenLPWizard): 'BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\n' 'Done')) % - (number+1, self.maxBibles, name)) + (number + 1, self.maxBibles, name)) self.success[biblenumber] = True else: self.incrementProgressBar(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\nFailed')) % - (number+1, self.maxBibles, name), - self.progressBar.maximum()-self.progressBar.value()) + (number + 1, self.maxBibles, name), + self.progressBar.maximum() - self.progressBar.value()) delete_database(self.path, clean_filename(self.newbibles[number].get_name())) number += 1 diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 1247aa1f0..5a05ade92 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -58,10 +58,10 @@ class BGExtract(object): def get_bible_chapter(self, version, bookname, chapter): """ - Access and decode bibles via the BibleGateway website. + Access and decode Bibles via the BibleGateway website. ``version`` - The version of the bible like 31 for New International version. + The version of the Bible like 31 for New International version. ``bookname`` Name of the Book. @@ -133,10 +133,10 @@ class BGExtract(object): def get_books_from_http(self, version): """ - Load a list of all books a bible contaions from BibleGateway website. + Load a list of all books a Bible contaions from BibleGateway website. ``version`` - The version of the bible like NIV for New International Version + The version of the Bible like NIV for New International Version """ log.debug(u'BGExtract.get_books_from_http("%s")', version) url_params = urllib.urlencode( @@ -157,7 +157,7 @@ class BGExtract(object): try: soup = BeautifulSoup(soup) except HTMLParseError: - log.exception(u'BeautifulSoup could not parse the bible page.') + log.exception(u'BeautifulSoup could not parse the Bible page.') if not soup: send_error_message(u'parse') return None @@ -224,11 +224,11 @@ class BSExtract(object): def get_books_from_http(self, version): """ - Load a list of all books a bible contains from Bibleserver mobile + Load a list of all books a Bible contains from Bibleserver mobile website. ``version`` - The version of the bible like NIV for New International Version + The version of the Bible like NIV for New International Version """ log.debug(u'BSExtract.get_books_from_http("%s")', version) chapter_url = u'http://m.bibleserver.com/overlay/selectBook?'\ @@ -261,7 +261,7 @@ class CWExtract(object): Access and decode bibles via the Crosswalk website ``version`` - The version of the bible like niv for New International Version + The version of the Bible like niv for New International Version ``bookname`` Text name of in english e.g. 'gen' for Genesis @@ -320,7 +320,7 @@ class CWExtract(object): def get_books_from_http(self, version): """ - Load a list of all books a bible contain from the Crosswalk website. + Load a list of all books a Bible contain from the Crosswalk website. ``version`` The version of the bible like NIV for New International Version @@ -383,7 +383,7 @@ class HTTPBible(BibleDB): self.wizard.progressBar.setMaximum(68) self.wizard.incrementProgressBar(unicode(translate( 'BiblesPlugin.HTTPBible', - 'Registering bible and loading books...'))) + 'Registering Bible and loading books...'))) self.create_meta(u'download source', self.download_source) self.create_meta(u'download name', self.download_name) if self.proxy_server: From 24d7b7b03829b22de1a22cab869c1fb4bc40c179 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Thu, 26 May 2011 09:34:29 +0200 Subject: [PATCH 50/97] small spelling change --- openlp/plugins/bibles/bibleplugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/bibleplugin.py b/openlp/plugins/bibles/bibleplugin.py index 0ec8b8ed5..5a1ff8eec 100644 --- a/openlp/plugins/bibles/bibleplugin.py +++ b/openlp/plugins/bibles/bibleplugin.py @@ -117,7 +117,7 @@ class BiblePlugin(Plugin): self.toolsUpgradeItem = QtGui.QAction(tools_menu) self.toolsUpgradeItem.setObjectName(u'toolsUpgradeItem') self.toolsUpgradeItem.setText( - translate('BiblePlugin', '&Upgrade Bible databases')) + translate('BiblePlugin', '&Upgrade older Bibles')) self.toolsUpgradeItem.setStatusTip( translate('BiblePlugin', 'Upgrade the Bible databases to the ' 'latest format')) From e70ba41373abceb0a143e54e2135ae512cbbc52f Mon Sep 17 00:00:00 2001 From: Gerald Britton Date: Thu, 26 May 2011 09:35:01 -0400 Subject: [PATCH 51/97] Add specific error messages if OoO open fails. Use a lambda to avoid repetition --- openlp/plugins/songs/lib/oooimport.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/lib/oooimport.py b/openlp/plugins/songs/lib/oooimport.py index a03a36121..5e4cd25d4 100644 --- a/openlp/plugins/songs/lib/oooimport.py +++ b/openlp/plugins/songs/lib/oooimport.py @@ -71,6 +71,10 @@ class OooImport(SongImport): log.error(exc) return self.import_wizard.progressBar.setMaximum(len(self.import_source)) + error_msg = lambda: self.log_error( + self.filepath, + translate('SongsPlugin.SongImport', + u'Unable to open file')) for filename in self.import_source: if self.stop_import_flag: break @@ -81,9 +85,9 @@ class OooImport(SongImport): self.process_ooo_document() self.close_ooo_file() else: - self.log_error(self.filepath) + error_msg() else: - self.log_error(self.filepath) + error_msg() self.close_ooo() def process_ooo_document(self): From 74e47dcbc7fb8c948a6447915551e3984af36ea8 Mon Sep 17 00:00:00 2001 From: Gerald Britton Date: Thu, 26 May 2011 14:20:14 -0400 Subject: [PATCH 52/97] Add specific error messages for file problems. Remove unicode strings in calls to translate() --- openlp/plugins/songs/lib/oooimport.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/openlp/plugins/songs/lib/oooimport.py b/openlp/plugins/songs/lib/oooimport.py index 5e4cd25d4..3cc61f4e3 100644 --- a/openlp/plugins/songs/lib/oooimport.py +++ b/openlp/plugins/songs/lib/oooimport.py @@ -67,14 +67,10 @@ class OooImport(SongImport): self.log_error( self.import_source[0], translate('SongsPlugin.SongImport', - u'Unable to open OpenOffice.org or LibreOffice')) + 'Unable to open OpenOffice.org or LibreOffice')) log.error(exc) return self.import_wizard.progressBar.setMaximum(len(self.import_source)) - error_msg = lambda: self.log_error( - self.filepath, - translate('SongsPlugin.SongImport', - u'Unable to open file')) for filename in self.import_source: if self.stop_import_flag: break @@ -85,9 +81,13 @@ class OooImport(SongImport): self.process_ooo_document() self.close_ooo_file() else: - error_msg() + self.log_error(self.filepath, + translate('SongsPlugin.SongImport', + 'Unable to open file')) else: - error_msg() + self.log_error(self.filepath, + translate('SongsPlugin.SongImport', + 'File not found')) self.close_ooo() def process_ooo_document(self): From c435127585284e27676963cdfb02ead7fb077efb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Thu, 26 May 2011 21:13:11 +0200 Subject: [PATCH 53/97] some fixes in relation with the extened LanguageForm close cursor from OldBibleDB --- openlp/plugins/bibles/forms/bibleimportform.py | 2 +- openlp/plugins/bibles/forms/bibleupgradeform.py | 1 + openlp/plugins/bibles/forms/languageform.py | 6 +----- openlp/plugins/bibles/lib/csvbible.py | 7 +++---- openlp/plugins/bibles/lib/db.py | 7 +++++++ openlp/plugins/bibles/lib/http.py | 4 ++-- openlp/plugins/bibles/lib/openlp1.py | 7 +++---- openlp/plugins/bibles/lib/opensong.py | 4 ++-- openlp/plugins/bibles/lib/osis.py | 7 +++---- 9 files changed, 23 insertions(+), 22 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 45ada29ba..731c4ff17 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -706,7 +706,7 @@ class BibleImportForm(OpenLPWizard): name=license_version, filename=unicode(self.field(u'openlp1_location').toString()) ) - if importer.do_import(): + if importer.do_import(license_version): self.manager.save_meta_data(license_version, license_version, license_copyright, license_permissions) self.manager.reload_bibles() diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 7b7c259ac..fef8c04df 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -324,6 +324,7 @@ class BibleUpgradeForm(OpenLPWizard): oldbible = OldBibleDB(self.mediaItem, path=self.path, file=filename) oldname = oldbible.get_name() + oldbible.close_cursor() if not version_name: critical_error_message_box(UiStrings().EmptyField, translate('BiblesPlugin.UpgradeWizardForm', diff --git a/openlp/plugins/bibles/forms/languageform.py b/openlp/plugins/bibles/forms/languageform.py index e7cde104c..477c7ee1e 100644 --- a/openlp/plugins/bibles/forms/languageform.py +++ b/openlp/plugins/bibles/forms/languageform.py @@ -55,11 +55,7 @@ class LanguageForm(QDialog, Ui_LanguageDialog): def exec_(self, bible_name): self.languageComboBox.addItem(u'') if bible_name: - self.infoLabel.setText(unicode(translate( - 'BiblesPlugin.LanguageDialog', - 'OpenLP is unable to determine the language of this translation' - ' of the Bible. Please select the language for "%s" from the ' - 'list below.')) % bible_name) + self.bibleLabel.setText(unicode(bible_name)) items = BiblesResourcesDB.get_languages() for item in items: self.languageComboBox.addItem(item[u'name']) diff --git a/openlp/plugins/bibles/lib/csvbible.py b/openlp/plugins/bibles/lib/csvbible.py index a4a498677..8b1ce0c8d 100644 --- a/openlp/plugins/bibles/lib/csvbible.py +++ b/openlp/plugins/bibles/lib/csvbible.py @@ -92,7 +92,7 @@ class CSVBible(BibleDB): self.booksfile = kwargs[u'booksfile'] self.versesfile = kwargs[u'versefile'] - def do_import(self): + def do_import(self, bible_name=None): """ Import the bible books and verses. """ @@ -100,10 +100,9 @@ class CSVBible(BibleDB): self.wizard.progressBar.setMinimum(0) self.wizard.progressBar.setMaximum(66) success = True - language_id = self.get_language() + language_id = self.get_language(bible_name) if not language_id: - log.exception(u'Importing books from "%s" '\ - 'failed' % self.filename) + log.exception(u'Importing books from "%s" failed' % self.filename) return False books_file = None book_list = {} diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index a3eb0e849..ab4cf3ba4 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -999,6 +999,13 @@ class OldBibleDB(QtCore.QObject, Manager): self.cursor = conn.cursor() return self.cursor + def close_cursor(self): + """ + Close the cursor + """ + if self.cursor: + self.cursor.close() + def run_sql(self, query, parameters=()): """ Run an SQL query on the database, returning the results. diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index 5a05ade92..ab82799d1 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -375,7 +375,7 @@ class HTTPBible(BibleDB): if u'proxy_password' in kwargs: self.proxy_password = kwargs[u'proxy_password'] - def do_import(self): + def do_import(self, bible_name=None): """ Run the import. This method overrides the parent class method. Returns ``True`` on success, ``False`` on failure. @@ -414,7 +414,7 @@ class HTTPBible(BibleDB): language_id = bible[u'language_id'] self.create_meta(u'language_id', language_id) else: - language_id = self.get_language() + language_id = self.get_language(bible_name) if not language_id: log.exception(u'Importing books from %s " '\ 'failed' % self.filename) diff --git a/openlp/plugins/bibles/lib/openlp1.py b/openlp/plugins/bibles/lib/openlp1.py index 2c3eb7851..3564c5d37 100644 --- a/openlp/plugins/bibles/lib/openlp1.py +++ b/openlp/plugins/bibles/lib/openlp1.py @@ -46,7 +46,7 @@ class OpenLP1Bible(BibleDB): BibleDB.__init__(self, parent, **kwargs) self.filename = kwargs[u'filename'] - def do_import(self): + def do_import(self, bible_name=None): """ Imports an openlp.org v1 bible. """ @@ -58,10 +58,9 @@ class OpenLP1Bible(BibleDB): except: return False #Create the bible language - language_id = self.get_language() + language_id = self.get_language(bible_name) if not language_id: - log.exception(u'Importing books from "%s " '\ - 'failed' % self.filename) + log.exception(u'Importing books from "%s" failed' % self.filename) return False # Create all books. cursor.execute(u'SELECT id, testament_id, name, abbreviation FROM book') diff --git a/openlp/plugins/bibles/lib/opensong.py b/openlp/plugins/bibles/lib/opensong.py index f848cd69b..005139784 100644 --- a/openlp/plugins/bibles/lib/opensong.py +++ b/openlp/plugins/bibles/lib/opensong.py @@ -46,7 +46,7 @@ class OpenSongBible(BibleDB): BibleDB.__init__(self, parent, **kwargs) self.filename = kwargs['filename'] - def do_import(self): + def do_import(self, bible_name=None): """ Loads a Bible from file. """ @@ -62,7 +62,7 @@ class OpenSongBible(BibleDB): file = open(self.filename, u'r') opensong = objectify.parse(file) bible = opensong.getroot() - language_id = self.get_language() + language_id = self.get_language(bible_name) if not language_id: log.exception(u'Importing books from "%s" '\ 'failed' % self.filename) diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index 682fed11a..effb62104 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -86,7 +86,7 @@ class OSISBible(BibleDB): if fbibles: fbibles.close() - def do_import(self): + def do_import(self, bible_name=None): """ Loads a Bible from file. """ @@ -109,10 +109,9 @@ class OSISBible(BibleDB): if detect_file: detect_file.close() # Set meta language_id - language_id = self.get_language() + language_id = self.get_language(bible_name) if not language_id: - log.exception(u'Importing books from "%s" '\ - 'failed' % self.filename) + log.exception(u'Importing books from "%s" failed' % self.filename) return False try: osis = codecs.open(self.filename, u'r', details['encoding']) From b5c392112b9dd4a4736a5fa8a18b928537708418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Thu, 26 May 2011 22:15:38 +0200 Subject: [PATCH 54/97] test close database --- openlp/plugins/bibles/forms/bibleupgradeform.py | 1 - openlp/plugins/bibles/lib/db.py | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index fef8c04df..7b7c259ac 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -324,7 +324,6 @@ class BibleUpgradeForm(OpenLPWizard): oldbible = OldBibleDB(self.mediaItem, path=self.path, file=filename) oldname = oldbible.get_name() - oldbible.close_cursor() if not version_name: critical_error_message_box(UiStrings().EmptyField, translate('BiblesPlugin.UpgradeWizardForm', diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index ab4cf3ba4..c557d8047 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -499,6 +499,12 @@ class BibleDB(QtCore.QObject, Manager): return True return False + def close_database(self): + """ + Close database connection. + """ + self.session.close() + def dump_bible(self): """ Utility debugging method to dump the contents of a bible. From f29830b98ea8d37ae76a67c88757879a16165c53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Thu, 26 May 2011 22:38:07 +0200 Subject: [PATCH 55/97] change BookNameDialog like Raoul want. --- .../plugins/bibles/forms/bibleupgradeform.py | 2 +- openlp/plugins/bibles/forms/booknamedialog.py | 154 +++++++++--------- openlp/plugins/bibles/forms/booknameform.py | 30 ++-- openlp/plugins/bibles/lib/db.py | 3 +- 4 files changed, 93 insertions(+), 96 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 7b7c259ac..875396de6 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -623,7 +623,7 @@ class BibleUpgradeForm(OpenLPWizard): (number + 1, self.maxBibles, name), self.progressBar.maximum() - self.progressBar.value()) delete_database(self.path, - clean_filename(self.newbibles[number].get_name())) + clean_filename(name)) number += 1 self.mediaItem.reloadBibles() successful_import = 0 diff --git a/openlp/plugins/bibles/forms/booknamedialog.py b/openlp/plugins/bibles/forms/booknamedialog.py index 632007013..d2901ce23 100644 --- a/openlp/plugins/bibles/forms/booknamedialog.py +++ b/openlp/plugins/bibles/forms/booknamedialog.py @@ -27,92 +27,88 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import translate -from openlp.core.lib.ui import create_accept_reject_button_box class Ui_BookNameDialog(object): def setupUi(self, bookNameDialog): - bookNameDialog.setObjectName(u'BookNameDialog') - bookNameDialog.resize(400, 275) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, - QtGui.QSizePolicy.MinimumExpanding) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(bookNameDialog.sizePolicy() - .hasHeightForWidth()) - bookNameDialog.setSizePolicy(sizePolicy) - self.widget = QtGui.QWidget(bookNameDialog) - self.widget.setGeometry(QtCore.QRect(10, 15, 381, 251)) - self.widget.setObjectName(u'widget') - self.verticalLayout = QtGui.QVBoxLayout(self.widget) - self.verticalLayout.setObjectName(u'verticalLayout') - self.headlineLabel = QtGui.QLabel(self.widget) - font = QtGui.QFont() - font.setFamily(u'Arial') - font.setPointSize(11) - font.setWeight(75) - font.setBold(True) - self.headlineLabel.setFont(font) - self.headlineLabel.setObjectName(u'HeadlineLabel') - self.verticalLayout.addWidget(self.headlineLabel) - self.infoLabel = QtGui.QLabel(self.widget) - self.infoLabel.setObjectName(u'InfoLabel') - self.verticalLayout.addWidget(self.infoLabel) - self.formLayout = QtGui.QFormLayout() - self.formLayout.setObjectName(u'formLayout') - self.requestLabel = QtGui.QLabel(self.widget) - self.requestLabel.setObjectName(u'RequestLabel') - self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, - self.requestLabel) - self.requestComboBox = QtGui.QComboBox(self.widget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, - QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.requestComboBox.sizePolicy() - .hasHeightForWidth()) - self.requestComboBox.setSizePolicy(sizePolicy) - self.requestComboBox.setObjectName(u'RequestComboBox') - self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, - self.requestComboBox) - self.verticalLayout.addLayout(self.formLayout) - self.infoLabelTestaments = QtGui.QLabel(self.widget) - self.infoLabelTestaments.setObjectName(u'InfoLabelTestaments') - self.verticalLayout.addWidget(self.infoLabelTestaments) - self.checkBoxOldTestament = QtGui.QCheckBox(self.widget) - self.checkBoxOldTestament.setObjectName(u'OldTestament') - self.checkBoxOldTestament.setCheckState(QtCore.Qt.Checked) - self.verticalLayout.addWidget(self.checkBoxOldTestament) - self.checkBoxNewTestament = QtGui.QCheckBox(self.widget) - self.checkBoxNewTestament.setObjectName(u'OldTestament') - self.checkBoxNewTestament.setCheckState(QtCore.Qt.Checked) - self.verticalLayout.addWidget(self.checkBoxNewTestament) - self.checkBoxApocrypha = QtGui.QCheckBox(self.widget) - self.checkBoxApocrypha.setObjectName(u'OldTestament') - self.checkBoxApocrypha.setCheckState(QtCore.Qt.Checked) - self.verticalLayout.addWidget(self.checkBoxApocrypha) - self.verticalLayout.addWidget( - create_accept_reject_button_box(bookNameDialog)) - spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, - QtGui.QSizePolicy.Expanding) - self.verticalLayout.addItem(spacerItem) + bookNameDialog.setObjectName(u'bookNameDialog') + bookNameDialog.resize(400, 271) + self.bookNameLayout = QtGui.QVBoxLayout(bookNameDialog) + self.bookNameLayout.setSpacing(8) + self.bookNameLayout.setMargin(8) + self.bookNameLayout.setObjectName(u'bookNameLayout') + self.infoLabel = QtGui.QLabel(bookNameDialog) + self.infoLabel.setWordWrap(True) + self.infoLabel.setObjectName(u'infoLabel') + self.bookNameLayout.addWidget(self.infoLabel) + self.correspondingLayout = QtGui.QGridLayout() + self.correspondingLayout.setSpacing(8) + self.correspondingLayout.setObjectName(u'correspondingLayout') + self.currentLabel = QtGui.QLabel(bookNameDialog) + self.currentLabel.setObjectName(u'currentLabel') + self.correspondingLayout.addWidget(self.currentLabel, 0, 0, 1, 1) + self.currentLineEdit = QtGui.QLineEdit(bookNameDialog) + self.currentLineEdit.setReadOnly(True) + self.currentLineEdit.setObjectName(u'currentLineEdit') + self.correspondingLayout.addWidget(self.currentLineEdit, 0, 1, 1, 1) + self.correspondingLabel = QtGui.QLabel(bookNameDialog) + self.correspondingLabel.setObjectName(u'correspondingLabel') + self.correspondingLayout.addWidget( + self.correspondingLabel, 1, 0, 1, 1) + self.correspondingComboBox = QtGui.QComboBox(bookNameDialog) + self.correspondingComboBox.setObjectName(u'correspondingComboBox') + self.correspondingLayout.addWidget( + self.correspondingComboBox, 1, 1, 1, 1) + self.bookNameLayout.addLayout(self.correspondingLayout) + self.optionsGroupBox = QtGui.QGroupBox(bookNameDialog) + self.optionsGroupBox.setObjectName(u'optionsGroupBox') + self.optionsLayout = QtGui.QVBoxLayout(self.optionsGroupBox) + self.optionsLayout.setSpacing(8) + self.optionsLayout.setMargin(8) + self.optionsLayout.setObjectName(u'optionsLayout') + self.oldTestamentCheckBox = QtGui.QCheckBox(self.optionsGroupBox) + self.oldTestamentCheckBox.setObjectName(u'oldTestamentCheckBox') + self.oldTestamentCheckBox.setCheckState(QtCore.Qt.Checked) + self.optionsLayout.addWidget(self.oldTestamentCheckBox) + self.newTestamentCheckBox = QtGui.QCheckBox(self.optionsGroupBox) + self.newTestamentCheckBox.setObjectName(u'newTestamentCheckBox') + self.newTestamentCheckBox.setCheckState(QtCore.Qt.Checked) + self.optionsLayout.addWidget(self.newTestamentCheckBox) + self.apocryphaCheckBox = QtGui.QCheckBox(self.optionsGroupBox) + self.apocryphaCheckBox.setObjectName(u'apocryphaCheckBox') + self.apocryphaCheckBox.setCheckState(QtCore.Qt.Checked) + self.optionsLayout.addWidget(self.apocryphaCheckBox) + self.bookNameLayout.addWidget(self.optionsGroupBox) + self.buttonBox = QtGui.QDialogButtonBox(bookNameDialog) + self.buttonBox.setOrientation(QtCore.Qt.Horizontal) + self.buttonBox.setStandardButtons( + QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) + self.buttonBox.setObjectName(u'buttonBox') + self.bookNameLayout.addWidget(self.buttonBox) + self.retranslateUi(bookNameDialog) - QtCore.QMetaObject.connectSlotsByName(self) + QtCore.QObject.connect( + self.buttonBox, QtCore.SIGNAL(u'accepted()'), + bookNameDialog.accept) + QtCore.QObject.connect( + self.buttonBox, QtCore.SIGNAL(u'rejected()'), + bookNameDialog.reject) + QtCore.QMetaObject.connectSlotsByName(bookNameDialog) def retranslateUi(self, bookNameDialog): - bookNameDialog.setWindowTitle( - translate('BiblesPlugin.BookNameDialog', 'Select Book')) - self.headlineLabel.setText( - translate('BiblesPlugin.BookNameDialog', 'Select Book:')) + bookNameDialog.setWindowTitle(translate('BiblesPlugin.BookNameDialog', + 'Select Book Name')) self.infoLabel.setText(translate('BiblesPlugin.BookNameDialog', - 'The following books cannot be clearly attributed. \n' - 'Please select which book it is.')) - self.requestLabel.setText(translate('BiblesPlugin.BookNameDialog', - 'Book:')) - self.infoLabelTestaments.setText(translate( - 'BiblesPlugin.BookNameDialog', 'Show books from:')) - self.checkBoxOldTestament.setText(translate( + 'The following book name cannot be matched up internally. Please ' + 'select the corresponding English name from the list.')) + self.currentLabel.setText(translate('BiblesPlugin.BookNameDialog', + 'Current name:')) + self.correspondingLabel.setText(translate( + 'BiblesPlugin.BookNameDialog', 'Corresponding name:')) + self.optionsGroupBox.setTitle(translate('BiblesPlugin.BookNameDialog', + 'Show Books From')) + self.oldTestamentCheckBox.setText(translate( 'BiblesPlugin.BookNameDialog', 'Old Testament')) - self.checkBoxNewTestament.setText(translate( + self.newTestamentCheckBox.setText(translate( 'BiblesPlugin.BookNameDialog', 'New Testament')) - self.checkBoxApocrypha.setText(translate('BiblesPlugin.BookNameDialog', + self.apocryphaCheckBox.setText(translate('BiblesPlugin.BookNameDialog', 'Apocrypha')) diff --git a/openlp/plugins/bibles/forms/booknameform.py b/openlp/plugins/bibles/forms/booknameform.py index fdb383a8c..df4943656 100644 --- a/openlp/plugins/bibles/forms/booknameform.py +++ b/openlp/plugins/bibles/forms/booknameform.py @@ -59,13 +59,13 @@ class BookNameForm(QDialog, Ui_BookNameDialog): """ Set up the signals used in the booknameform. """ - QtCore.QObject.connect(self.checkBoxOldTestament, + QtCore.QObject.connect(self.oldTestamentCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), self.onCheckBoxIndexChanged) - QtCore.QObject.connect(self.checkBoxNewTestament, + QtCore.QObject.connect(self.newTestamentCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), self.onCheckBoxIndexChanged) - QtCore.QObject.connect(self.checkBoxApocrypha, + QtCore.QObject.connect(self.apocryphaCheckBox, QtCore.SIGNAL(u'stateChanged(int)'), self.onCheckBoxIndexChanged) @@ -79,8 +79,8 @@ class BookNameForm(QDialog, Ui_BookNameDialog): ''' Reload the Combobox items ''' - self.requestComboBox.clear() - self.requestComboBox.addItem(u'') + self.correspondingComboBox.clear() + self.correspondingComboBox.addItem(u'') items = BiblesResourcesDB.get_books() for item in items: addBook = True @@ -88,36 +88,36 @@ class BookNameForm(QDialog, Ui_BookNameDialog): if book.book_reference_id == item[u'id']: addBook = False break - if self.checkBoxOldTestament.checkState() == QtCore.Qt.Unchecked \ + if self.oldTestamentCheckBox.checkState() == QtCore.Qt.Unchecked \ and item[u'testament_id'] == 1: addBook = False - elif self.checkBoxNewTestament.checkState() == QtCore.Qt.Unchecked \ + elif self.newTestamentCheckBox.checkState() == QtCore.Qt.Unchecked \ and item[u'testament_id'] == 2: addBook = False - elif self.checkBoxApocrypha.checkState() == QtCore.Qt.Unchecked \ + elif self.apocryphaCheckBox.checkState() == QtCore.Qt.Unchecked \ and item[u'testament_id'] == 3: addBook = False if addBook: - self.requestComboBox.addItem(item[u'name']) + self.correspondingComboBox.addItem(item[u'name']) def exec_(self, name, books, maxbooks): self.books = books log.debug(maxbooks) if maxbooks <= 27: - self.checkBoxOldTestament.setCheckState(QtCore.Qt.Unchecked) - self.checkBoxApocrypha.setCheckState(QtCore.Qt.Unchecked) + self.oldTestamentCheckBox.setCheckState(QtCore.Qt.Unchecked) + self.apocryphaCheckBox.setCheckState(QtCore.Qt.Unchecked) elif maxbooks <= 66: - self.checkBoxApocrypha.setCheckState(QtCore.Qt.Unchecked) + self.apocryphaCheckBox.setCheckState(QtCore.Qt.Unchecked) self.reloadComboBox() - self.requestLabel.setText(name) + self.currentLineEdit.setText(name) return QDialog.exec_(self) def accept(self): - if self.requestComboBox.currentText() == u'': + if self.correspondingComboBox.currentText() == u'': critical_error_message_box( message=translate('BiblesPlugin.BookNameForm', 'You need to select a book.')) - self.requestComboBox.setFocus() + self.correspondingComboBox.setFocus() return False else: return QDialog.accept(self) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index c557d8047..864c002f5 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -343,7 +343,8 @@ class BibleDB(QtCore.QObject, Manager): book_ref = None book_name = BookNameForm(self.wizard) if book_name.exec_(book, self.get_books(), maxbooks): - book_ref = unicode(book_name.requestComboBox.currentText()) + book_ref = unicode( + book_name.correspondingComboBox.currentText()) if not book_ref: return None else: From d3148f90f8c4a4ef4522faaca964fc8c9ff9f193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Fri, 27 May 2011 09:54:49 +0200 Subject: [PATCH 56/97] fix Traceback like Jonathan recommand --- openlp/core/lib/db.py | 3 ++- openlp/plugins/bibles/lib/db.py | 13 ------------- openlp/plugins/bibles/lib/manager.py | 1 + 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/openlp/core/lib/db.py b/openlp/core/lib/db.py index 5b03e5fa4..e51271624 100644 --- a/openlp/core/lib/db.py +++ b/openlp/core/lib/db.py @@ -34,6 +34,7 @@ from PyQt4 import QtCore from sqlalchemy import create_engine, MetaData from sqlalchemy.exceptions import InvalidRequestError from sqlalchemy.orm import scoped_session, sessionmaker +from sqlalchemy.pool import NullPool from openlp.core.utils import AppLocation, delete_file @@ -52,7 +53,7 @@ def init_db(url, auto_flush=True, auto_commit=False): ``auto_commit`` Sets the commit behaviour of the session """ - engine = create_engine(url) + engine = create_engine(url, poolclass=NullPool) metadata = MetaData(bind=engine) session = scoped_session(sessionmaker(autoflush=auto_flush, autocommit=auto_commit, bind=engine)) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 0cf3b8a26..87da5fc52 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -500,12 +500,6 @@ class BibleDB(QtCore.QObject, Manager): return True return False - def close_database(self): - """ - Close database connection. - """ - self.session.close() - def dump_bible(self): """ Utility debugging method to dump the contents of a bible. @@ -1006,13 +1000,6 @@ class OldBibleDB(QtCore.QObject, Manager): self.cursor = conn.cursor() return self.cursor - def close_cursor(self): - """ - Close the cursor - """ - if self.cursor: - self.cursor.close() - def run_sql(self, query, parameters=()): """ Run an SQL query on the database, returning the results. diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 5fb235520..2699462c3 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -156,6 +156,7 @@ class BibleManager(object): # Find old database versions if bible.is_old_database(): self.old_bible_databases.append(filename) + bible.session.close() continue log.debug(u'Bible Name: "%s"', name) self.db_cache[name] = bible From e5231aba410d391f566dc6e3f065a34f8a7e4658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Fri, 27 May 2011 11:23:46 +0200 Subject: [PATCH 57/97] change using old bible databases in bibleupgradeform --- .../plugins/bibles/forms/bibleupgradeform.py | 30 +++++++------------ openlp/plugins/bibles/lib/db.py | 4 +-- openlp/plugins/bibles/lib/manager.py | 2 +- 3 files changed, 14 insertions(+), 22 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 875396de6..1cc075324 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -131,7 +131,7 @@ class BibleUpgradeForm(OpenLPWizard): """ for number, filename in enumerate(self.files): if number in self.success and self.success[number] == True: - delete_file(os.path.join(self.path, filename)) + delete_file(os.path.join(self.path, filename[0])) def customInit(self): """ @@ -183,7 +183,7 @@ class BibleUpgradeForm(OpenLPWizard): self.formWidget = {} self.formLayoutAttention = {} for number, filename in enumerate(self.files): - bible = OldBibleDB(self.mediaItem, path=self.path, file=filename) + bible = OldBibleDB(self.mediaItem, path=self.path, file=filename[0]) self.checkBox[number] = QtGui.QCheckBox(self.scrollAreaContents) checkBoxName = u'checkBox[%d]' % number self.checkBox[number].setObjectName(checkBoxName) @@ -321,9 +321,6 @@ class BibleUpgradeForm(OpenLPWizard): if not self.checkBox[number].checkState() == QtCore.Qt.Checked: continue version_name = unicode(self.versionNameEdit[number].text()) - oldbible = OldBibleDB(self.mediaItem, path=self.path, - file=filename) - oldname = oldbible.get_name() if not version_name: critical_error_message_box(UiStrings().EmptyField, translate('BiblesPlugin.UpgradeWizardForm', @@ -341,13 +338,13 @@ class BibleUpgradeForm(OpenLPWizard): self.versionNameEdit[number].setFocus() return False elif os.path.exists(os.path.join(self.path, clean_filename( - version_name))) and version_name == oldname: - newfilename = u'old_database_%s' % filename + version_name))) and version_name == filename[1]: + newfilename = u'old_database_%s' % filename[0] if not os.path.exists(os.path.join(self.path, newfilename)): - os.rename(os.path.join(self.path, filename), + os.rename(os.path.join(self.path, filename[0]), os.path.join(self.path, newfilename)) - self.files[number] = newfilename + self.files[number] = [newfilename, filename[1]] continue else: critical_error_message_box( @@ -393,9 +390,7 @@ class BibleUpgradeForm(OpenLPWizard): self.maxBibles = len(self.files) for number, filename in enumerate(self.files): self.checkBox[number].setCheckState(QtCore.Qt.Checked) - oldbible = OldBibleDB(self.mediaItem, path=self.path, - file=filename) - oldname = oldbible.get_name() + oldname = filename[1] if self.manager.exists(oldname): self.verticalWidget[number].show() self.formWidget[number].show() @@ -444,11 +439,8 @@ class BibleUpgradeForm(OpenLPWizard): if not self.checkBox[biblenumber].checkState() == QtCore.Qt.Checked: continue self.progressBar.reset() - oldbible = OldBibleDB(self.mediaItem, path=self.path, - file=filename) - name = oldbible.get_name() - if name is None: - delete_file(os.path.join(self.path, filename)) + if filename[1] is None: + delete_file(os.path.join(self.path, filename[0])) self.incrementProgressBar(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\nFailed')) % @@ -460,7 +452,7 @@ class BibleUpgradeForm(OpenLPWizard): 'BiblesPlugin.UpgradeWizardForm', 'Upgrading Bible %s of %s: "%s"\nUpgrading ...')) % (number + 1, self.maxBibles, name)) - if os.path.exists(os.path.join(self.path, filename)): + if os.path.exists(os.path.join(self.path, filename[0])): name = unicode(self.versionNameEdit[biblenumber].text()) self.newbibles[number] = BibleDB(self.mediaItem, path=self.path, name=name) @@ -519,7 +511,7 @@ class BibleUpgradeForm(OpenLPWizard): else: language_id = self.newbibles[number].get_language(name) if not language_id: - log.exception(u'Upgrading from "%s" failed' % filename) + log.exception(u'Upgrading from "%s" failed' % filename[0]) delete_database(self.path, clean_filename(self.newbibles[number].get_name())) del self.newbibles[number] diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 87da5fc52..776521aa6 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -996,8 +996,8 @@ class OldBibleDB(QtCore.QObject, Manager): """ if self.cursor is None: filepath = os.path.join(self.path, self.file) - conn = sqlite3.connect(filepath) - self.cursor = conn.cursor() + self.connection = sqlite3.connect(filepath) + self.cursor = self.connection.cursor() return self.cursor def run_sql(self, query, parameters=()): diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 2699462c3..40ddcaf25 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -155,7 +155,7 @@ class BibleManager(object): continue # Find old database versions if bible.is_old_database(): - self.old_bible_databases.append(filename) + self.old_bible_databases.append([filename, name]) bible.session.close() continue log.debug(u'Bible Name: "%s"', name) From 8eb261ee88a8e4f09506fd50e84b8e50927e32ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Fri, 27 May 2011 11:39:58 +0200 Subject: [PATCH 58/97] bug fixes setFocus to the Combobox in booknameform --- openlp/plugins/bibles/forms/bibleupgradeform.py | 8 +++++++- openlp/plugins/bibles/forms/booknameform.py | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 1cc075324..8ac99d99f 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -439,7 +439,10 @@ class BibleUpgradeForm(OpenLPWizard): if not self.checkBox[biblenumber].checkState() == QtCore.Qt.Checked: continue self.progressBar.reset() - if filename[1] is None: + oldbible = OldBibleDB(self.mediaItem, path=self.path, + file=filename[0]) + name = filename[1] + if name is None: delete_file(os.path.join(self.path, filename[0])) self.incrementProgressBar(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', @@ -596,6 +599,9 @@ class BibleUpgradeForm(OpenLPWizard): self.newbibles[number].delete_book(db_book) continue for verse in verses: + if self.stop_import_flag: + bible_failed = True + break self.newbibles[number].create_verse(db_book.id, int(verse[u'chapter']), int(verse[u'verse']), unicode(verse[u'text'])) diff --git a/openlp/plugins/bibles/forms/booknameform.py b/openlp/plugins/bibles/forms/booknameform.py index df4943656..e2d7004ec 100644 --- a/openlp/plugins/bibles/forms/booknameform.py +++ b/openlp/plugins/bibles/forms/booknameform.py @@ -110,6 +110,7 @@ class BookNameForm(QDialog, Ui_BookNameDialog): self.apocryphaCheckBox.setCheckState(QtCore.Qt.Unchecked) self.reloadComboBox() self.currentLineEdit.setText(name) + self.correspondingComboBox.setFocus() return QDialog.exec_(self) def accept(self): From 42a8a4407e84b032b2e87673ca7d7f8e32e1bb73 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Fri, 27 May 2011 16:28:38 +0200 Subject: [PATCH 59/97] fixed bug 789143 Fixes: https://launchpad.net/bugs/789143 --- openlp/plugins/songs/lib/__init__.py | 46 ++-------------------------- 1 file changed, 2 insertions(+), 44 deletions(-) diff --git a/openlp/plugins/songs/lib/__init__.py b/openlp/plugins/songs/lib/__init__.py index 9e068e7f1..e3779f2c0 100644 --- a/openlp/plugins/songs/lib/__init__.py +++ b/openlp/plugins/songs/lib/__init__.py @@ -171,7 +171,8 @@ class VerseType(object): @staticmethod def from_loose_input(verse_name): """ - Return the VerseType for a given string, Other if not found + Return the VerseType for a given string, Other if not found. Use this + with caution! ``verse_name`` The string to return a VerseType for @@ -265,52 +266,9 @@ def clean_song(manager, song): whitespace = re.compile(r'\W+', re.UNICODE) song.search_title = (whitespace.sub(u' ', song.title).strip() + u'@' + whitespace.sub(u' ', song.alternate_title).strip()).strip().lower() - # Remove the old "language" attribute from lyrics tag (prior to 1.9.5). This - # is not very important, but this keeps the database clean. This can be - # removed when everybody has cleaned his songs. - song.lyrics = song.lyrics.replace(u'', u'') verses = SongXML().get_verses(song.lyrics) lyrics = u' '.join([whitespace.sub(u' ', verse[1]) for verse in verses]) song.search_lyrics = lyrics.lower() - # We need a new and clean SongXML instance. - sxml = SongXML() - # Rebuild the song's verses, to remove any wrong verse names (for example - # translated ones), which might have been added prior to 1.9.5. - # List for later comparison. - compare_order = [] - for verse in verses: - verse_type = VerseType.Tags[VerseType.from_loose_input( - verse[0][u'type'])] - sxml.add_verse_to_lyrics( - verse_type, - verse[0][u'label'], - verse[1], - verse[0][u'lang'] if verse[0].has_key(u'lang') else None - ) - compare_order.append((u'%s%s' % (verse_type, verse[0][u'label']) - ).upper()) - if verse[0][u'label'] == u'1': - compare_order.append(verse_type.upper()) - song.lyrics = unicode(sxml.extract_xml(), u'utf-8') - # Rebuild the verse order, to convert translated verse tags, which might - # have been added prior to 1.9.5. - if song.verse_order: - order = song.verse_order.strip().split() - else: - order = [] - new_order = [] - for verse_def in order: - verse_type = VerseType.Tags[VerseType.from_loose_input(verse_def[0])] - if len(verse_def) > 1: - new_order.append((u'%s%s' % (verse_type, verse_def[1:])).upper()) - else: - new_order.append(verse_type.upper()) - song.verse_order = u' '.join(new_order) - # Check if the verse order contains tags for verses which do not exist. - for order in new_order: - if order not in compare_order: - song.verse_order = u'' - break # The song does not have any author, add one. if not song.authors: name = SongStrings.AuthorUnknown From 010373b798c76f5dd71bda030f804b22a7312e23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Fri, 27 May 2011 22:33:23 +0200 Subject: [PATCH 60/97] Fixed Traceback if BookNameDialog was canceled while upgrading non webbibles Replace LineEdit in BookNameDialog with Label --- openlp/plugins/bibles/forms/bibleupgradeform.py | 2 +- openlp/plugins/bibles/forms/booknamedialog.py | 8 ++++---- openlp/plugins/bibles/forms/booknameform.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 8ac99d99f..bd9a3172d 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -606,7 +606,7 @@ class BibleUpgradeForm(OpenLPWizard): int(verse[u'chapter']), int(verse[u'verse']), unicode(verse[u'text'])) Receiver.send_message(u'openlp_process_events') - self.newbibles[number].session.commit() + self.newbibles[number].session.commit() if not bible_failed: self.incrementProgressBar(unicode(translate( 'BiblesPlugin.UpgradeWizardForm', diff --git a/openlp/plugins/bibles/forms/booknamedialog.py b/openlp/plugins/bibles/forms/booknamedialog.py index d2901ce23..e9211b3d5 100644 --- a/openlp/plugins/bibles/forms/booknamedialog.py +++ b/openlp/plugins/bibles/forms/booknamedialog.py @@ -41,15 +41,15 @@ class Ui_BookNameDialog(object): self.infoLabel.setObjectName(u'infoLabel') self.bookNameLayout.addWidget(self.infoLabel) self.correspondingLayout = QtGui.QGridLayout() + self.correspondingLayout.setColumnStretch(1, 1) self.correspondingLayout.setSpacing(8) self.correspondingLayout.setObjectName(u'correspondingLayout') self.currentLabel = QtGui.QLabel(bookNameDialog) self.currentLabel.setObjectName(u'currentLabel') self.correspondingLayout.addWidget(self.currentLabel, 0, 0, 1, 1) - self.currentLineEdit = QtGui.QLineEdit(bookNameDialog) - self.currentLineEdit.setReadOnly(True) - self.currentLineEdit.setObjectName(u'currentLineEdit') - self.correspondingLayout.addWidget(self.currentLineEdit, 0, 1, 1, 1) + self.currentBookLabel = QtGui.QLabel(bookNameDialog) + self.currentBookLabel.setObjectName(u'currentBookLabel') + self.correspondingLayout.addWidget(self.currentBookLabel, 0, 1, 1, 1) self.correspondingLabel = QtGui.QLabel(bookNameDialog) self.correspondingLabel.setObjectName(u'correspondingLabel') self.correspondingLayout.addWidget( diff --git a/openlp/plugins/bibles/forms/booknameform.py b/openlp/plugins/bibles/forms/booknameform.py index e2d7004ec..8ad3ad977 100644 --- a/openlp/plugins/bibles/forms/booknameform.py +++ b/openlp/plugins/bibles/forms/booknameform.py @@ -109,7 +109,7 @@ class BookNameForm(QDialog, Ui_BookNameDialog): elif maxbooks <= 66: self.apocryphaCheckBox.setCheckState(QtCore.Qt.Unchecked) self.reloadComboBox() - self.currentLineEdit.setText(name) + self.currentBookLabel.setText(unicode(name)) self.correspondingComboBox.setFocus() return QDialog.exec_(self) From 5f9b23f8e737dbee841a511a196ecda2600d43d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Fri, 27 May 2011 22:53:46 +0200 Subject: [PATCH 61/97] remove unnecessary line --- openlp/plugins/bibles/forms/bibleupgradeform.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index bd9a3172d..a5b175aef 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -627,7 +627,6 @@ class BibleUpgradeForm(OpenLPWizard): successful_import = 0 failed_import = 0 for number, filename in enumerate(self.files): - #for number, success in self.success.iteritems(): if number in self.success and self.success[number] == True: successful_import += 1 elif self.checkBox[number].checkState() == QtCore.Qt.Checked: From e550665b23a0632e1210a391d88c5e3ef42e6189 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Fri, 27 May 2011 23:11:53 +0200 Subject: [PATCH 62/97] bug fix --- openlp/plugins/bibles/lib/manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 50a64ca42..2a3858afc 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -221,7 +221,7 @@ class BibleManager(object): { u'name': book.name, u'book_reference_id': book.book_reference_id, - u'chapters': self.db_cache[bible].get_chapter_count(book.book_reference_id) + u'chapters': self.db_cache[bible].get_chapter_count(book) } for book in self.db_cache[bible].get_books() ] From 4138d6fbd01951006a81a2cfee157eed45845998 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Sat, 28 May 2011 10:53:37 +0100 Subject: [PATCH 63/97] Change lots of parents --- openlp/core/lib/mediamanageritem.py | 21 ++++---- openlp/core/lib/plugin.py | 2 +- openlp/plugins/alerts/forms/alertform.py | 5 +- openlp/plugins/bibles/lib/mediaitem.py | 54 +++++++++---------- openlp/plugins/custom/forms/editcustomform.py | 8 +-- openlp/plugins/custom/lib/mediaitem.py | 24 ++++----- openlp/plugins/images/lib/mediaitem.py | 12 ++--- openlp/plugins/media/lib/mediaitem.py | 10 ++-- openlp/plugins/presentations/lib/mediaitem.py | 12 ++--- .../presentations/presentationplugin.py | 2 +- openlp/plugins/remotes/lib/httpserver.py | 18 +++---- openlp/plugins/songs/forms/editsongform.py | 3 +- openlp/plugins/songs/lib/mediaitem.py | 34 ++++++------ 13 files changed, 102 insertions(+), 103 deletions(-) diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 9b76447ff..9b780fa75 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -93,8 +93,7 @@ class MediaManagerItem(QtGui.QWidget): QtGui.QWidget.__init__(self) self.parent = parent self.whitespace = re.compile(r'\W+', re.UNICODE) - #TODO: plugin should not be the parent in future - self.plugin = parent # plugin + self.plugin = plugin visible_title = self.plugin.getString(StringContent.VisibleName) self.title = unicode(visible_title[u'title']) self.settingsSection = self.plugin.name.lower() @@ -114,10 +113,10 @@ class MediaManagerItem(QtGui.QWidget): self.retranslateUi() self.autoSelectItem = None QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'%s_service_load' % self.parent.name.lower()), + QtCore.SIGNAL(u'%s_service_load' % self.plugin.name.lower()), self.serviceLoad) QtCore.QObject.connect(Receiver.get_receiver(), - QtCore.SIGNAL(u'%s_set_autoselect_item' % self.parent.name.lower()), + QtCore.SIGNAL(u'%s_set_autoselect_item' % self.plugin.name.lower()), self.setAutoSelectItem) def requiredIcons(self): @@ -475,7 +474,7 @@ class MediaManagerItem(QtGui.QWidget): serviceItem = self.buildServiceItem() if serviceItem: serviceItem.from_plugin = True - self.parent.previewController.addServiceItem(serviceItem) + self.plugin.previewController.addServiceItem(serviceItem) if keepFocus: self.listView.setFocus() @@ -503,7 +502,7 @@ class MediaManagerItem(QtGui.QWidget): if serviceItem: if not item_id: serviceItem.from_plugin = True - self.parent.liveController.addServiceItem(serviceItem) + self.plugin.liveController.addServiceItem(serviceItem) def createItemFromId(self, item_id): item = QtGui.QListWidgetItem() @@ -533,7 +532,7 @@ class MediaManagerItem(QtGui.QWidget): serviceItem = self.buildServiceItem(item, True) if serviceItem: serviceItem.from_plugin = False - self.parent.serviceManager.addServiceItem(serviceItem, + self.plugin.serviceManager.addServiceItem(serviceItem, replace=replace) def onAddEditClick(self): @@ -546,14 +545,14 @@ class MediaManagerItem(QtGui.QWidget): 'You must select one or more items.')) else: log.debug(u'%s Add requested', self.plugin.name) - serviceItem = self.parent.serviceManager.getServiceItem() + serviceItem = self.plugin.serviceManager.getServiceItem() if not serviceItem: QtGui.QMessageBox.information(self, UiStrings().NISs, translate('OpenLP.MediaManagerItem', 'You must select an existing service item to add to.')) elif self.plugin.name.lower() == serviceItem.name.lower(): self.generateSlideData(serviceItem) - self.parent.serviceManager.addServiceItem(serviceItem, + self.plugin.serviceManager.addServiceItem(serviceItem, replace=True) else: # Turn off the remote edit update message indicator @@ -567,8 +566,8 @@ class MediaManagerItem(QtGui.QWidget): """ Common method for generating a service item """ - serviceItem = ServiceItem(self.parent) - serviceItem.add_icon(self.parent.icon_path) + serviceItem = ServiceItem(self.plugin) + serviceItem.add_icon(self.plugin.icon_path) if self.generateSlideData(serviceItem, item, xmlVersion): return serviceItem else: diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 0417446c1..974c59de2 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -215,7 +215,7 @@ class Plugin(QtCore.QObject): you need, and return it for integration into openlp.org. """ if self.media_item_class: - return self.media_item_class(self, self, self.icon) + return self.media_item_class(self.mediadock, self, self.icon) return None def addImportMenuItem(self, importMenu): diff --git a/openlp/plugins/alerts/forms/alertform.py b/openlp/plugins/alerts/forms/alertform.py index 13cb4503a..92db42723 100644 --- a/openlp/plugins/alerts/forms/alertform.py +++ b/openlp/plugins/alerts/forms/alertform.py @@ -41,7 +41,8 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): Initialise the alert form """ self.manager = plugin.manager - self.parent = plugin + self.plugin = plugin + self.parent = plugin.formparent self.item_id = None QtGui.QDialog.__init__(self, plugin.formparent) self.setupUi(self) @@ -195,7 +196,7 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): self.parameterEdit.setFocus() return False text = text.replace(u'<>', unicode(self.parameterEdit.text())) - self.parent.alertsmanager.displayAlert(text) + self.plugin.alertsmanager.displayAlert(text) return True def onCurrentRowChanged(self, row): diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 41059f942..baf04995b 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -61,7 +61,7 @@ class BibleMediaItem(MediaManagerItem): self.unlockIcon = QtGui.QIcon(u':/bibles/bibles_search_unlock.png') MediaManagerItem.__init__(self, parent, plugin, icon) # Place to store the search results for both bibles. - self.settings = self.parent.settings_tab + self.settings = self.plugin.settings_tab self.quickPreviewAllowed = True self.hasSearch = True self.search_results = {} @@ -338,7 +338,7 @@ class BibleMediaItem(MediaManagerItem): def initialise(self): log.debug(u'bible manager initialise') - self.parent.manager.media = self + self.plugin.manager.media = self self.loadBibles() bible = QtCore.QSettings().value( self.settingsSection + u'/quick bible', QtCore.QVariant( @@ -365,7 +365,7 @@ class BibleMediaItem(MediaManagerItem): self.quickSecondComboBox.addItem(u'') self.advancedSecondComboBox.addItem(u'') # Get all bibles and sort the list. - bibles = self.parent.manager.get_bibles().keys() + bibles = self.plugin.manager.get_bibles().keys() bibles.sort(cmp=locale.strcoll) # Load the bibles into the combo boxes. for bible in bibles: @@ -386,7 +386,7 @@ class BibleMediaItem(MediaManagerItem): def reloadBibles(self): log.debug(u'Reloading Bibles') - self.parent.manager.reload_bibles() + self.plugin.manager.reload_bibles() self.loadBibles() def initialiseAdvancedBible(self, bible): @@ -400,7 +400,7 @@ class BibleMediaItem(MediaManagerItem): The bible to initialise (unicode). """ log.debug(u'initialiseAdvancedBible %s', bible) - book_data = self.parent.manager.get_books(bible) + book_data = self.plugin.manager.get_books(bible) self.advancedBookComboBox.clear() first = True for book in book_data: @@ -416,7 +416,7 @@ class BibleMediaItem(MediaManagerItem): def initialiseChapterVerse(self, bible, book, chapter_count): log.debug(u'initialiseChapterVerse %s, %s', bible, book) self.chapter_count = chapter_count - verse_count = self.parent.manager.get_verse_count(bible, book, 1) + verse_count = self.plugin.manager.get_verse_count(bible, book, 1) if verse_count == 0: self.advancedSearchButton.setEnabled(False) critical_error_message_box( @@ -445,7 +445,7 @@ class BibleMediaItem(MediaManagerItem): books = [] # We have to do a 'Reference Search'. if self.quickSearchEdit.currentSearchType() == BibleSearch.Reference: - bibles = self.parent.manager.get_bibles() + bibles = self.plugin.manager.get_bibles() bible = unicode(self.quickVersionComboBox.currentText()) if bible: book_data = bibles[bible].get_books() @@ -455,8 +455,8 @@ class BibleMediaItem(MediaManagerItem): def onImportClick(self): if not hasattr(self, u'import_wizard'): - self.import_wizard = BibleImportForm(self, self.parent.manager, - self.parent) + self.import_wizard = BibleImportForm(self, self.plugin.manager, + self.plugin) # If the import was not cancelled then reload. if self.import_wizard.exec_(): self.reloadBibles() @@ -515,7 +515,7 @@ class BibleMediaItem(MediaManagerItem): bible = unicode(self.advancedVersionComboBox.currentText()) book = unicode(self.advancedBookComboBox.currentText()) verse_from = int(self.advancedFromVerse.currentText()) - verse_count = self.parent.manager.get_verse_count(bible, book, + verse_count = self.plugin.manager.get_verse_count(bible, book, chapter_to) self.adjustComboBox(verse_from, verse_count, self.advancedToVerse, True) @@ -527,7 +527,7 @@ class BibleMediaItem(MediaManagerItem): chapter_to = int(self.advancedToChapter.currentText()) verse_from = int(self.advancedFromVerse.currentText()) verse_to = int(self.advancedToVerse.currentText()) - verse_count = self.parent.manager.get_verse_count(bible, book, + verse_count = self.plugin.manager.get_verse_count(bible, book, chapter_to) if chapter_from == chapter_to and verse_from > verse_to: self.adjustComboBox(verse_from, verse_count, self.advancedToVerse) @@ -539,7 +539,7 @@ class BibleMediaItem(MediaManagerItem): book = unicode(self.advancedBookComboBox.currentText()) chapter_from = int(self.advancedFromChapter.currentText()) chapter_to = int(self.advancedToChapter.currentText()) - verse_count = self.parent.manager.get_verse_count(bible, book, + verse_count = self.plugin.manager.get_verse_count(bible, book, chapter_from) self.adjustComboBox(1, verse_count, self.advancedFromVerse) if chapter_from > chapter_to: @@ -599,9 +599,9 @@ class BibleMediaItem(MediaManagerItem): range_separator + chapter_to + verse_separator + verse_to versetext = u'%s %s' % (book, verse_range) Receiver.send_message(u'cursor_busy') - self.search_results = self.parent.manager.get_verses(bible, versetext) + self.search_results = self.plugin.manager.get_verses(bible, versetext) if second_bible: - self.second_search_results = self.parent.manager.get_verses( + self.second_search_results = self.plugin.manager.get_verses( second_bible, versetext) if not self.advancedLockButton.isChecked(): self.listView.clear() @@ -627,15 +627,15 @@ class BibleMediaItem(MediaManagerItem): text = unicode(self.quickSearchEdit.text()) if self.quickSearchEdit.currentSearchType() == BibleSearch.Reference: # We are doing a 'Reference Search'. - self.search_results = self.parent.manager.get_verses(bible, text) + self.search_results = self.plugin.manager.get_verses(bible, text) if second_bible and self.search_results: - self.second_search_results = self.parent.manager.get_verses( + self.second_search_results = self.plugin.manager.get_verses( second_bible, text) else: # We are doing a 'Text Search'. Receiver.send_message(u'cursor_busy') - bibles = self.parent.manager.get_bibles() - self.search_results = self.parent.manager.verse_search(bible, + bibles = self.plugin.manager.get_bibles() + self.search_results = self.plugin.manager.verse_search(bible, second_bible, text) if second_bible and self.search_results: text = [] @@ -674,19 +674,19 @@ class BibleMediaItem(MediaManagerItem): further action is saved for/in each row. """ verse_separator = get_reference_match(u'sep_v_display') - version = self.parent.manager.get_meta_data(bible, u'Version').value - copyright = self.parent.manager.get_meta_data(bible, u'Copyright').value + version = self.plugin.manager.get_meta_data(bible, u'Version').value + copyright = self.plugin.manager.get_meta_data(bible, u'Copyright').value permissions = \ - self.parent.manager.get_meta_data(bible, u'Permissions').value + self.plugin.manager.get_meta_data(bible, u'Permissions').value second_version = u'' second_copyright = u'' second_permissions = u'' if second_bible: - second_version = self.parent.manager.get_meta_data( + second_version = self.plugin.manager.get_meta_data( second_bible, u'Version').value - second_copyright = self.parent.manager.get_meta_data( + second_copyright = self.plugin.manager.get_meta_data( second_bible, u'Copyright').value - second_permissions = self.parent.manager.get_meta_data( + second_permissions = self.plugin.manager.get_meta_data( second_bible, u'Permissions').value items = [] for count, verse in enumerate(search_results): @@ -879,7 +879,7 @@ class BibleMediaItem(MediaManagerItem): # We are still in the same chapter, but a verse has been skipped. return True elif old_chapter + 1 == chapter and (verse != 1 or - old_verse != self.parent.manager.get_verse_count( + old_verse != self.plugin.manager.get_verse_count( old_bible, old_book, old_chapter)): # We are in the following chapter, but the last verse was not the # last verse of the chapter or the current verse is not the @@ -923,7 +923,7 @@ class BibleMediaItem(MediaManagerItem): Search for some Bible verses (by reference). """ bible = unicode(self.quickVersionComboBox.currentText()) - search_results = self.parent.manager.get_verses(bible, string, False) + search_results = self.plugin.manager.get_verses(bible, string, False) results = [] if search_results: versetext = u' '.join([verse.text for verse in search_results]) @@ -933,6 +933,6 @@ class BibleMediaItem(MediaManagerItem): def createItemFromId(self, item_id): item = QtGui.QListWidgetItem() bible = unicode(self.quickVersionComboBox.currentText()) - search_results = self.parent.manager.get_verses(bible, item_id, False) + search_results = self.plugin.manager.get_verses(bible, item_id, False) items = self.buildDisplayResults(bible, u'', search_results) return items diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index 0e4376634..68d11404d 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -43,13 +43,13 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): Class documentation goes here. """ log.info(u'Custom Editor loaded') - def __init__(self, parent): + def __init__(self, plugin): """ Constructor """ - QtGui.QDialog.__init__(self) - self.parent = parent - self.manager = self.parent.manager + self.plugin = plugin + QtGui.QDialog.__init__(self, self.plugin.formparent) + self.manager = self.plugin.manager self.setupUi(self) # Create other objects and forms. self.editSlideForm = EditCustomSlideForm(self) diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 43f4afd63..4a9dd8140 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -56,14 +56,14 @@ class CustomMediaItem(MediaManagerItem): def __init__(self, parent, plugin, icon): self.IconPath = u'custom/custom' - MediaManagerItem.__init__(self, parent, self, icon) + MediaManagerItem.__init__(self, parent, plugin, icon) self.singleServiceItem = False self.quickPreviewAllowed = True self.hasSearch = True # Holds information about whether the edit is remotly triggered and # which Custom is required. self.remoteCustom = -1 - self.manager = parent.manager + self.manager = plugin.manager def addEndHeaderBar(self): self.addToolbarSeparator() @@ -151,8 +151,8 @@ class CustomMediaItem(MediaManagerItem): self.listView.setCurrentItem(custom_name) def onNewClick(self): - self.parent.edit_custom_form.loadCustom(0) - self.parent.edit_custom_form.exec_() + self.plugin.edit_custom_form.loadCustom(0) + self.plugin.edit_custom_form.exec_() self.initialise() def onRemoteEditClear(self): @@ -170,9 +170,9 @@ class CustomMediaItem(MediaManagerItem): if valid: self.remoteCustom = fields[1] self.remoteTriggered = fields[0] - self.parent.edit_custom_form.loadCustom(fields[1], + self.plugin.edit_custom_form.loadCustom(fields[1], (fields[0] == u'P')) - self.parent.edit_custom_form.exec_() + self.plugin.edit_custom_form.exec_() def onEditClick(self): """ @@ -181,8 +181,8 @@ class CustomMediaItem(MediaManagerItem): if check_item_selected(self.listView, UiStrings().SelectEdit): item = self.listView.currentItem() item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] - self.parent.edit_custom_form.loadCustom(item_id, False) - self.parent.edit_custom_form.exec_() + self.plugin.edit_custom_form.loadCustom(item_id, False) + self.plugin.edit_custom_form.exec_() self.initialise() def onDeleteClick(self): @@ -195,7 +195,7 @@ class CustomMediaItem(MediaManagerItem): id_list = [(item.data(QtCore.Qt.UserRole)).toInt()[0] for item in self.listView.selectedIndexes()] for id in id_list: - self.parent.manager.delete_object(CustomSlide, id) + self.plugin.manager.delete_object(CustomSlide, id) for row in row_list: self.listView.takeItem(row) @@ -212,7 +212,7 @@ class CustomMediaItem(MediaManagerItem): service_item.add_capability(ItemCapabilities.AllowsPreview) service_item.add_capability(ItemCapabilities.AllowsLoop) service_item.add_capability(ItemCapabilities.AllowsVirtualSplit) - customSlide = self.parent.manager.get_object(CustomSlide, item_id) + customSlide = self.plugin.manager.get_object(CustomSlide, item_id) title = customSlide.title credit = customSlide.credits service_item.edit_id = item_id @@ -245,13 +245,13 @@ class CustomMediaItem(MediaManagerItem): search_type = self.searchTextEdit.currentSearchType() if search_type == CustomSearch.Titles: log.debug(u'Titles Search') - search_results = self.parent.manager.get_all_objects(CustomSlide, + search_results = self.plugin.manager.get_all_objects(CustomSlide, CustomSlide.title.like(u'%' + self.whitespace.sub(u' ', search_keywords) + u'%'), order_by_ref=CustomSlide.title) self.loadList(search_results) elif search_type == CustomSearch.Themes: log.debug(u'Theme Search') - search_results = self.parent.manager.get_all_objects(CustomSlide, + search_results = self.plugin.manager.get_all_objects(CustomSlide, CustomSlide.theme_name.like(u'%' + self.whitespace.sub(u' ', search_keywords) + u'%'), order_by_ref=CustomSlide.title) self.loadList(search_results) diff --git a/openlp/plugins/images/lib/mediaitem.py b/openlp/plugins/images/lib/mediaitem.py index f760a984e..921a52ede 100644 --- a/openlp/plugins/images/lib/mediaitem.py +++ b/openlp/plugins/images/lib/mediaitem.py @@ -47,7 +47,7 @@ class ImageMediaItem(MediaManagerItem): def __init__(self, parent, plugin, icon): self.IconPath = u'images/image' - MediaManagerItem.__init__(self, parent, self, icon) + MediaManagerItem.__init__(self, parent, plugin, icon) self.quickPreviewAllowed = True self.hasSearch = True QtCore.QObject.connect(Receiver.get_receiver(), @@ -112,14 +112,14 @@ class ImageMediaItem(MediaManagerItem): def loadList(self, list, initialLoad=False): if not initialLoad: - self.parent.formparent.displayProgressBar(len(list)) + self.plugin.formparent.displayProgressBar(len(list)) # Sort the themes by its filename considering language specific # characters. lower() is needed for windows! list.sort(cmp=locale.strcoll, key=lambda filename: os.path.split(unicode(filename))[1].lower()) for imageFile in list: if not initialLoad: - self.parent.formparent.incrementProgressBar() + self.plugin.formparent.incrementProgressBar() filename = os.path.split(unicode(imageFile))[1] thumb = os.path.join(self.servicePath, filename) if os.path.exists(thumb): @@ -134,7 +134,7 @@ class ImageMediaItem(MediaManagerItem): item_name.setData(QtCore.Qt.UserRole, QtCore.QVariant(imageFile)) self.listView.addItem(item_name) if not initialLoad: - self.parent.formparent.finishedProgressBar() + self.plugin.formparent.finishedProgressBar() def generateSlideData(self, service_item, item=None, xmlVersion=False): if item: @@ -188,7 +188,7 @@ class ImageMediaItem(MediaManagerItem): Called to reset the Live backgound with the image selected, """ self.resetAction.setVisible(False) - self.parent.liveController.display.resetImage() + self.plugin.liveController.display.resetImage() def liveThemeChanged(self): """ @@ -208,7 +208,7 @@ class ImageMediaItem(MediaManagerItem): filename = unicode(bitem.data(QtCore.Qt.UserRole).toString()) if os.path.exists(filename): (path, name) = os.path.split(filename) - self.parent.liveController.display.directImage(name, filename) + self.plugin.liveController.display.directImage(name, filename) self.resetAction.setVisible(True) else: critical_error_message_box(UiStrings().LiveBGError, diff --git a/openlp/plugins/media/lib/mediaitem.py b/openlp/plugins/media/lib/mediaitem.py index 9dc17f4d3..96b97d25a 100644 --- a/openlp/plugins/media/lib/mediaitem.py +++ b/openlp/plugins/media/lib/mediaitem.py @@ -50,7 +50,7 @@ class MediaMediaItem(MediaManagerItem): self.background = False self.PreviewFunction = QtGui.QPixmap( u':/media/media_video.png').toImage() - MediaManagerItem.__init__(self, parent, self, icon) + MediaManagerItem.__init__(self, parent, plugin, icon) self.singleServiceItem = False self.hasSearch = True self.mediaObject = None @@ -65,8 +65,8 @@ class MediaMediaItem(MediaManagerItem): self.onNewPrompt = translate('MediaPlugin.MediaItem', 'Select Media') self.onNewFileMasks = unicode(translate('MediaPlugin.MediaItem', 'Videos (%s);;Audio (%s);;%s (*)')) % ( - u' '.join(self.parent.video_extensions_list), - u' '.join(self.parent.audio_extensions_list), UiStrings().AllFiles) + u' '.join(self.plugin.video_extensions_list), + u' '.join(self.plugin.audio_extensions_list), UiStrings().AllFiles) self.replaceAction.setText(UiStrings().ReplaceBG) self.replaceAction.setToolTip(UiStrings().ReplaceLiveBG) self.resetAction.setText(UiStrings().ResetBG) @@ -95,7 +95,7 @@ class MediaMediaItem(MediaManagerItem): Called to reset the Live backgound with the media selected, """ self.resetAction.setVisible(False) - self.parent.liveController.display.resetVideo() + self.plugin.liveController.display.resetVideo() def videobackgroundReplaced(self): """ @@ -114,7 +114,7 @@ class MediaMediaItem(MediaManagerItem): filename = unicode(item.data(QtCore.Qt.UserRole).toString()) if os.path.exists(filename): (path, name) = os.path.split(filename) - self.parent.liveController.display.video(filename, 0, True) + self.plugin.liveController.display.video(filename, 0, True) self.resetAction.setVisible(True) else: critical_error_message_box(UiStrings().LiveBGError, diff --git a/openlp/plugins/presentations/lib/mediaitem.py b/openlp/plugins/presentations/lib/mediaitem.py index b757b5bfd..e138d4ef9 100644 --- a/openlp/plugins/presentations/lib/mediaitem.py +++ b/openlp/plugins/presentations/lib/mediaitem.py @@ -46,14 +46,14 @@ class PresentationMediaItem(MediaManagerItem): """ log.info(u'Presentations Media Item loaded') - def __init__(self, parent, icon, title, controllers): + def __init__(self, parent, plugin, icon, controllers): """ Constructor. Setup defaults """ self.controllers = controllers self.IconPath = u'presentations/presentation' self.Automatic = u'' - MediaManagerItem.__init__(self, parent, self, icon) + MediaManagerItem.__init__(self, parent, plugin, icon) self.message_listener = MessageListener(self) self.hasSearch = True QtCore.QObject.connect(Receiver.get_receiver(), @@ -82,7 +82,7 @@ class PresentationMediaItem(MediaManagerItem): for type in types: if fileType.find(type) == -1: fileType += u'*.%s ' % type - self.parent.serviceManager.supportedSuffixes(type) + self.plugin.serviceManager.supportedSuffixes(type) self.onNewFileMasks = unicode(translate('PresentationPlugin.MediaItem', 'Presentations (%s)')) % fileType @@ -161,14 +161,14 @@ class PresentationMediaItem(MediaManagerItem): titles = [os.path.split(file)[1] for file in currlist] Receiver.send_message(u'cursor_busy') if not initialLoad: - self.parent.formparent.displayProgressBar(len(files)) + self.plugin.formparent.displayProgressBar(len(files)) # Sort the themes by its filename considering language specific # characters. lower() is needed for windows! files.sort(cmp=locale.strcoll, key=lambda filename: os.path.split(unicode(filename))[1].lower()) for file in files: if not initialLoad: - self.parent.formparent.incrementProgressBar() + self.plugin.formparent.incrementProgressBar() if currlist.count(file) > 0: continue filename = os.path.split(unicode(file))[1] @@ -208,7 +208,7 @@ class PresentationMediaItem(MediaManagerItem): self.listView.addItem(item_name) Receiver.send_message(u'cursor_normal') if not initialLoad: - self.parent.formparent.finishedProgressBar() + self.plugin.formparent.finishedProgressBar() def onDeleteClick(self): """ diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 171039d15..313e6258f 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -99,7 +99,7 @@ class PresentationPlugin(Plugin): Create the Media Manager List """ return PresentationMediaItem( - self, self.icon, self.name, self.controllers) + self.mediadock, self, self.icon, self.controllers) def registerControllers(self, controller): """ diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index 0ff8bc32e..9d29156f7 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -154,12 +154,12 @@ class HttpServer(object): e.g. http://localhost:4316/send/slidecontroller_live_next http://localhost:4316/send/alerts_text?q=your%20alert%20text """ - def __init__(self, parent): + def __init__(self, plugin): """ Initialise the httpserver, and start the server """ log.debug(u'Initialise httpserver') - self.parent = parent + self.plugin = plugin self.html_dir = os.path.join( AppLocation.get_directory(AppLocation.PluginsDir), u'remotes', u'html') @@ -176,10 +176,10 @@ class HttpServer(object): """ log.debug(u'Start TCP server') port = QtCore.QSettings().value( - self.parent.settingsSection + u'/port', + self.plugin.settingsSection + u'/port', QtCore.QVariant(4316)).toInt()[0] address = QtCore.QSettings().value( - self.parent.settingsSection + u'/ip address', + self.plugin.settingsSection + u'/ip address', QtCore.QVariant(u'0.0.0.0')).toString() self.server = QtNetwork.QTcpServer() self.server.listen(QtNetwork.QHostAddress(address), port) @@ -264,7 +264,7 @@ class HttpConnection(object): def _get_service_items(self): service_items = [] - service_manager = self.parent.parent.serviceManager + service_manager = self.parent.plugin.serviceManager if self.parent.current_item: cur_uuid = self.parent.current_item._uuid else: @@ -457,7 +457,7 @@ class HttpConnection(object): """ if action == u'search': searches = [] - for plugin in self.parent.parent.pluginManager.plugins: + for plugin in self.parent.plugin.pluginManager.plugins: if plugin.status == PluginStatus.Active and \ plugin.mediaItem and plugin.mediaItem.hasSearch: searches.append(plugin.name) @@ -473,7 +473,7 @@ class HttpConnection(object): The plugin name to search in. """ text = json.loads(self.url_params[u'data'][0])[u'request'][u'text'] - plugin = self.parent.parent.pluginManager.get_plugin_by_name(type) + plugin = self.parent.plugin.pluginManager.get_plugin_by_name(type) if plugin.status == PluginStatus.Active and \ plugin.mediaItem and plugin.mediaItem.hasSearch: results =plugin.mediaItem.search(text) @@ -488,7 +488,7 @@ class HttpConnection(object): Go live on an item of type ``type``. """ id = json.loads(self.url_params[u'data'][0])[u'request'][u'id'] - plugin = self.parent.parent.pluginManager.get_plugin_by_name(type) + plugin = self.parent.plugin.pluginManager.get_plugin_by_name(type) if plugin.status == PluginStatus.Active and plugin.mediaItem: plugin.mediaItem.goLive(id) @@ -497,7 +497,7 @@ class HttpConnection(object): Add item of type ``type`` to the end of the service """ id = json.loads(self.url_params[u'data'][0])[u'request'][u'id'] - plugin = self.parent.parent.pluginManager.get_plugin_by_name(type) + plugin = self.parent.plugin.pluginManager.get_plugin_by_name(type) if plugin.status == PluginStatus.Active and plugin.mediaItem: item_id = plugin.mediaItem.createItemFromId(id) plugin.mediaItem.addToService(item_id) diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index 393009f82..b6e0c04a8 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -52,7 +52,6 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): Constructor """ QtGui.QDialog.__init__(self, parent) - self.parent = parent self.song = None # can this be automated? self.width = 400 @@ -90,7 +89,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.onVerseListViewPressed) QtCore.QObject.connect(self.themeAddButton, QtCore.SIGNAL(u'clicked()'), - self.parent.parent.renderer.theme_manager.onAddTheme) + self.parent().plugin.renderer.theme_manager.onAddTheme) QtCore.QObject.connect(self.maintenanceButton, QtCore.SIGNAL(u'clicked()'), self.onMaintenanceButtonClicked) QtCore.QObject.connect(Receiver.get_receiver(), diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 7fe4d45c4..49ed759ff 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -62,12 +62,12 @@ class SongMediaItem(MediaManagerItem): def __init__(self, parent, plugin, icon): self.IconPath = u'songs/song' - MediaManagerItem.__init__(self, parent, self, icon) - self.edit_song_form = EditSongForm(self, self.parent.manager) - self.openLyrics = OpenLyrics(self.parent.manager) + MediaManagerItem.__init__(self, parent, plugin, icon) + self.edit_song_form = EditSongForm(self, self.plugin.manager) + self.openLyrics = OpenLyrics(self.plugin.manager) self.singleServiceItem = False self.song_maintenance_form = SongMaintenanceForm( - self.parent.manager, self) + self.plugin.manager, self) # Holds information about whether the edit is remotly triggered and # which Song is required. self.remoteSong = -1 @@ -178,31 +178,31 @@ class SongMediaItem(MediaManagerItem): self.displayResultsSong(search_results) elif search_type == SongSearch.Titles: log.debug(u'Titles Search') - search_results = self.parent.manager.get_all_objects(Song, + search_results = self.plugin.manager.get_all_objects(Song, Song.search_title.like(u'%' + self.whitespace.sub(u' ', search_keywords.lower()) + u'%')) self.displayResultsSong(search_results) elif search_type == SongSearch.Lyrics: log.debug(u'Lyrics Search') - search_results = self.parent.manager.get_all_objects(Song, + search_results = self.plugin.manager.get_all_objects(Song, Song.search_lyrics.like(u'%' + search_keywords.lower() + u'%')) self.displayResultsSong(search_results) elif search_type == SongSearch.Authors: log.debug(u'Authors Search') - search_results = self.parent.manager.get_all_objects(Author, + search_results = self.plugin.manager.get_all_objects(Author, Author.display_name.like(u'%' + search_keywords + u'%'), Author.display_name.asc()) self.displayResultsAuthor(search_results) elif search_type == SongSearch.Themes: log.debug(u'Theme Search') - search_results = self.parent.manager.get_all_objects(Song, + search_results = self.plugin.manager.get_all_objects(Song, Song.theme_name.like(u'%' + self.whitespace.sub(u' ', search_keywords) + u'%')) self.displayResultsSong(search_results) self.check_search_result() def searchEntire(self, search_keywords): - return self.parent.manager.get_all_objects(Song, + return self.plugin.manager.get_all_objects(Song, or_(Song.search_title.like(u'%' + self.whitespace.sub(u' ', search_keywords.lower()) + u'%'), Song.search_lyrics.like(u'%' + search_keywords.lower() + u'%'), @@ -225,7 +225,7 @@ class SongMediaItem(MediaManagerItem): if self.editItem and self.updateServiceOnEdit and \ not self.remoteTriggered: item = self.buildServiceItem(self.editItem) - self.parent.serviceManager.replaceServiceItem(item) + self.plugin.serviceManager.replaceServiceItem(item) self.onRemoteEditClear() self.onSearchTextButtonClick() log.debug(u'onSongListLoad - finished') @@ -284,12 +284,12 @@ class SongMediaItem(MediaManagerItem): def onImportClick(self): if not hasattr(self, u'import_wizard'): - self.import_wizard = SongImportForm(self, self.parent) + self.import_wizard = SongImportForm(self, self.plugin) if self.import_wizard.exec_() == QtGui.QDialog.Accepted: Receiver.send_message(u'songs_load_list') def onExportClick(self): - export_wizard = SongExportForm(self, self.parent) + export_wizard = SongExportForm(self, self.plugin) export_wizard.exec_() def onNewClick(self): @@ -314,7 +314,7 @@ class SongMediaItem(MediaManagerItem): log.debug(u'onRemoteEdit %s' % message) remote_type, song_id = message.split(u':') song_id = int(song_id) - valid = self.parent.manager.get_object(Song, song_id) + valid = self.plugin.manager.get_object(Song, song_id) if valid: self.remoteSong = song_id self.remoteTriggered = remote_type @@ -350,7 +350,7 @@ class SongMediaItem(MediaManagerItem): return for item in items: item_id = (item.data(QtCore.Qt.UserRole)).toInt()[0] - self.parent.manager.delete_object(Song, item_id) + self.plugin.manager.delete_object(Song, item_id) self.onSearchTextButtonClick() def generateSlideData(self, service_item, item=None, xmlVersion=False): @@ -362,7 +362,7 @@ class SongMediaItem(MediaManagerItem): service_item.add_capability(ItemCapabilities.OnLoadUpdate) service_item.add_capability(ItemCapabilities.AddIfNewItem) service_item.add_capability(ItemCapabilities.AllowsVirtualSplit) - song = self.parent.manager.get_object(Song, item_id) + song = self.plugin.manager.get_object(Song, item_id) service_item.theme = song.theme_name service_item.edit_id = item_id if song.lyrics.startswith(u' Date: Sat, 28 May 2011 11:15:10 +0100 Subject: [PATCH 64/97] merge fixes --- openlp/plugins/custom/forms/editcustomform.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index 1aa283311..26a25e12a 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -43,12 +43,11 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): Class documentation goes here. """ log.info(u'Custom Editor loaded') - def __init__(self, plugin, manager): + def __init__(self, parent, manager): """ Constructor """ - self.plugin = plugin - QtGui.QDialog.__init__(self, self.plugin.formparent) + QtGui.QDialog.__init__(self, parent) self.manager = manager self.setupUi(self) # Create other objects and forms. @@ -137,7 +136,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): self.customSlide.credits = unicode(self.creditEdit.text()) self.customSlide.theme_name = unicode(self.themeComboBox.currentText()) success = self.manager.save_object(self.customSlide) - self.parent.auto_select_id = self.customSlide.id + self.parent().auto_select_id = self.customSlide.id return success def onUpButtonClicked(self): From 6a1ee02cdd94c80d91c00d3c972b1853cd44d4f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sat, 28 May 2011 14:48:10 +0200 Subject: [PATCH 65/97] add Backup page to the wizard remove blank item on Combobox in BookNameForm --- .../plugins/bibles/forms/bibleupgradeform.py | 116 ++++++++++++++++++ openlp/plugins/bibles/forms/booknameform.py | 1 - 2 files changed, 116 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index a5b175aef..64a9f9ffa 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -29,6 +29,7 @@ The bible import functions for OpenLP import logging import os.path import re +import shutil from PyQt4 import QtCore, QtGui @@ -133,6 +134,32 @@ class BibleUpgradeForm(OpenLPWizard): if number in self.success and self.success[number] == True: delete_file(os.path.join(self.path, filename[0])) + def onBackupBrowseButtonClicked(self): + """ + Show the file open dialog for the OSIS file. + """ + filename = QtGui.QFileDialog.getExistingDirectory(self, translate( + 'BiblesPlugin.UpgradeWizardForm', 'Select a Backup Directory'), + os.path.dirname(SettingsManager.get_last_dir( + self.plugin.settingsSection, 1))) + if filename: + self.backupDirectoryEdit.setText(filename) + SettingsManager.set_last_dir(self.plugin.settingsSection, + filename, 1) + + def backupOldBibles(self, backupdirectory): + """ + Backup old bible databases in a given folder. + """ + for filename in self.files: + try: + shutil.copy(os.path.join(self.path, filename[0]), + backupdirectory) + except: + return False + break + return True + def customInit(self): """ Perform any custom initialisation for bible upgrading. @@ -146,11 +173,52 @@ class BibleUpgradeForm(OpenLPWizard): """ QtCore.QObject.connect(self.finishButton, QtCore.SIGNAL(u'clicked()'), self.onFinishButton) + QtCore.QObject.connect(self.backupBrowseButton, + QtCore.SIGNAL(u'clicked()'), self.onBackupBrowseButtonClicked) def addCustomPages(self): """ Add the bible import specific wizard pages. """ + # Backup Page + self.backupPage = QtGui.QWizardPage() + self.backupPage.setObjectName(u'BackupPage') + self.backupLayout = QtGui.QVBoxLayout(self.backupPage) + self.backupLayout.setObjectName(u'BackupLayout') + self.backupInfoLabel = QtGui.QLabel(self.backupPage) + self.backupInfoLabel.setObjectName(u'backupInfoLabel') + self.backupInfoLabel.setWordWrap(True) + self.backupLayout.addWidget(self.backupInfoLabel) + self.formLayout = QtGui.QFormLayout() + self.formLayout.setMargin(0) + self.formLayout.setObjectName(u'FormLayout') + self.backupDirectoryLabel = QtGui.QLabel(self.backupPage) + self.backupDirectoryLabel.setObjectName(u'backupDirectoryLabel') + self.backupDirectoryLayout = QtGui.QHBoxLayout() + self.backupDirectoryLayout.setObjectName(u'BackupDirectoryLayout') + self.backupDirectoryEdit = QtGui.QLineEdit(self.backupPage) + self.backupDirectoryEdit.setObjectName(u'BackupFolderEdit') + self.backupDirectoryLayout.addWidget(self.backupDirectoryEdit) + self.backupBrowseButton = QtGui.QToolButton(self.backupPage) + self.backupBrowseButton.setIcon(self.openIcon) + self.backupBrowseButton.setObjectName(u'BackupBrowseButton') + self.backupDirectoryLayout.addWidget(self.backupBrowseButton) + self.formLayout.addRow(self.backupDirectoryLabel, + self.backupDirectoryLayout) + self.backupLayout.addLayout(self.formLayout) + self.backupAdditionalInfoLabel = QtGui.QLabel(self.backupPage) + self.backupAdditionalInfoLabel.setObjectName( + u'BackupAdditionalInfoLabel') + self.backupAdditionalInfoLabel.setWordWrap(True) + self.backupLayout.addWidget(self.backupAdditionalInfoLabel) + self.noBackupCheckBox = QtGui.QCheckBox(self.backupPage) + self.noBackupCheckBox.setObjectName('NoBackupCheckBox') + self.backupLayout.addWidget(self.noBackupCheckBox) + self.spacer = QtGui.QSpacerItem(10, 0, QtGui.QSizePolicy.Fixed, + QtGui.QSizePolicy.Minimum) + self.backupLayout.addItem(self.spacer) + self.addPage(self.backupPage) + # Select Page self.selectPage = QtGui.QWizardPage() self.selectPage.setObjectName(u'SelectPage') self.pageLayout = QtGui.QVBoxLayout(self.selectPage) @@ -290,6 +358,27 @@ class BibleUpgradeForm(OpenLPWizard): 'This wizard will help you to upgrade your existing Bibles from a ' 'prior version of OpenLP 2. Click the next button below to start ' 'the process by selecting the Bibles to upgrade.')) + self.backupPage.setTitle( + translate('BiblesPlugin.UpgradeWizardForm', + 'Select Backup Directory')) + self.backupPage.setSubTitle( + translate('BiblesPlugin.UpgradeWizardForm', + 'Please select a Directory for Backup your old Bibles')) + self.backupInfoLabel.setText(translate('BiblesPlugin.UpgradeWizardForm', + 'The Bible upgrade procedure will prevent you running older ' + 'versions of OpenLP. \nPlease select a backup location for your ' + 'existing Bibles.')) + self.backupDirectoryLabel.setText( + translate('BiblesPlugin.UpgradeWizardForm', 'Backup Directory:')) + self.backupAdditionalInfoLabel.setText( + translate('BiblesPlugin.UpgradeWizardForm', + 'These Bibles can copied back to your OpenLP data folder should ' + 'you need to revert to a previous version. Instructions on how ' + 'to restore the files can be found on our FAQ ' + 'at http://wiki.openlp.org/faq')) + self.noBackupCheckBox.setText( + translate('BiblesPlugin.UpgradeWizardForm', + 'There is no need to backup my Bibles')) self.selectPage.setTitle( translate('BiblesPlugin.UpgradeWizardForm', 'Select Bibles')) @@ -316,6 +405,33 @@ class BibleUpgradeForm(OpenLPWizard): """ if self.currentPage() == self.welcomePage: return True + elif self.currentPage() == self.backupPage: + if not self.noBackupCheckBox.checkState() == QtCore.Qt.Checked: + if not unicode(self.backupDirectoryEdit.text()): + critical_error_message_box(UiStrings().EmptyField, + translate('BiblesPlugin.UpgradeWizardForm', + 'You need to specify a Backup Directory for your ' + 'Bibles.')) + self.backupDirectoryEdit.setFocus() + return False + elif not os.path.exists(unicode( + self.backupDirectoryEdit.text())): + critical_error_message_box(UiStrings().Error, + translate('BiblesPlugin.UpgradeWizardForm', + 'The given path is not an existing directory.')) + self.backupDirectoryEdit.setFocus() + return False + else: + if not self.backupOldBibles(unicode( + self.backupDirectoryEdit.text())): + critical_error_message_box(UiStrings().Error, + translate('BiblesPlugin.UpgradeWizardForm', + 'The backup was not successfull.\nTo backup your ' + 'Bibles you need the permission to write in the given ' + 'directory. If you have a permissions to write and ' + 'this error still occurs, please report a bug.')) + return False + return True elif self.currentPage() == self.selectPage: for number, filename in enumerate(self.files): if not self.checkBox[number].checkState() == QtCore.Qt.Checked: diff --git a/openlp/plugins/bibles/forms/booknameform.py b/openlp/plugins/bibles/forms/booknameform.py index 8ad3ad977..28e4c9df1 100644 --- a/openlp/plugins/bibles/forms/booknameform.py +++ b/openlp/plugins/bibles/forms/booknameform.py @@ -80,7 +80,6 @@ class BookNameForm(QDialog, Ui_BookNameDialog): Reload the Combobox items ''' self.correspondingComboBox.clear() - self.correspondingComboBox.addItem(u'') items = BiblesResourcesDB.get_books() for item in items: addBook = True From 9b9f47a5beb4507537616c9d14ea0ff3267caf61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sat, 28 May 2011 15:33:15 +0200 Subject: [PATCH 66/97] small fix --- openlp/plugins/bibles/forms/bibleupgradeform.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 64a9f9ffa..00623fbce 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -157,7 +157,6 @@ class BibleUpgradeForm(OpenLPWizard): backupdirectory) except: return False - break return True def customInit(self): From 6507b431b0a7f12918bd704a09ff7414ca8befd9 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 28 May 2011 18:25:11 +0200 Subject: [PATCH 67/97] fix for older versions --- openlp/plugins/songs/lib/__init__.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/openlp/plugins/songs/lib/__init__.py b/openlp/plugins/songs/lib/__init__.py index e3779f2c0..ac7724ade 100644 --- a/openlp/plugins/songs/lib/__init__.py +++ b/openlp/plugins/songs/lib/__init__.py @@ -269,6 +269,19 @@ def clean_song(manager, song): verses = SongXML().get_verses(song.lyrics) lyrics = u' '.join([whitespace.sub(u' ', verse[1]) for verse in verses]) song.search_lyrics = lyrics.lower() + compare_order = [] + for verse in verses: + compare_order.append( + (u'%s%s' % (verse[0][u'type'], verse[0][u'label'])).upper()) + if verse[0][u'label'] == u'1': + compare_order.append(verse[0][u'type'].upper()) + # Check if the verse order contains tags for verses which do not exist. + # (This is relevant for people upgrading from 1.9.4 and older). + for order in song.verse_order.split(): + # The verse order contains invalid tags, so reset the order. + if order not in compare_order: + song.verse_order = u'' + break # The song does not have any author, add one. if not song.authors: name = SongStrings.AuthorUnknown From 5bedf62ec45d7732d3b8502a82dea1c394758640 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 28 May 2011 18:30:16 +0200 Subject: [PATCH 68/97] added more code back --- openlp/plugins/songs/lib/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/__init__.py b/openlp/plugins/songs/lib/__init__.py index ac7724ade..8aab8a34d 100644 --- a/openlp/plugins/songs/lib/__init__.py +++ b/openlp/plugins/songs/lib/__init__.py @@ -277,7 +277,11 @@ def clean_song(manager, song): compare_order.append(verse[0][u'type'].upper()) # Check if the verse order contains tags for verses which do not exist. # (This is relevant for people upgrading from 1.9.4 and older). - for order in song.verse_order.split(): + if song.verse_order: + order = song.verse_order.strip().split() + else: + order = [] + for order in order: # The verse order contains invalid tags, so reset the order. if order not in compare_order: song.verse_order = u'' From 64b9b4232167af374d810af37ebb90c065d45b9e Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sat, 28 May 2011 19:01:41 +0200 Subject: [PATCH 69/97] better solution --- openlp/plugins/songs/lib/__init__.py | 74 +++++++++++++++++++--------- 1 file changed, 52 insertions(+), 22 deletions(-) diff --git a/openlp/plugins/songs/lib/__init__.py b/openlp/plugins/songs/lib/__init__.py index 8aab8a34d..53b3d7cb1 100644 --- a/openlp/plugins/songs/lib/__init__.py +++ b/openlp/plugins/songs/lib/__init__.py @@ -171,8 +171,7 @@ class VerseType(object): @staticmethod def from_loose_input(verse_name): """ - Return the VerseType for a given string, Other if not found. Use this - with caution! + Return the VerseType for a given string, Other if not found ``verse_name`` The string to return a VerseType for @@ -266,26 +265,57 @@ def clean_song(manager, song): whitespace = re.compile(r'\W+', re.UNICODE) song.search_title = (whitespace.sub(u' ', song.title).strip() + u'@' + whitespace.sub(u' ', song.alternate_title).strip()).strip().lower() - verses = SongXML().get_verses(song.lyrics) - lyrics = u' '.join([whitespace.sub(u' ', verse[1]) for verse in verses]) - song.search_lyrics = lyrics.lower() - compare_order = [] - for verse in verses: - compare_order.append( - (u'%s%s' % (verse[0][u'type'], verse[0][u'label'])).upper()) - if verse[0][u'label'] == u'1': - compare_order.append(verse[0][u'type'].upper()) - # Check if the verse order contains tags for verses which do not exist. - # (This is relevant for people upgrading from 1.9.4 and older). - if song.verse_order: - order = song.verse_order.strip().split() - else: - order = [] - for order in order: - # The verse order contains invalid tags, so reset the order. - if order not in compare_order: - song.verse_order = u'' - break + # Only do this, if we the song is a 1.9.4 song (or older). + if song.lyrics.find(u'') != -1: + # Remove the old "language" attribute from lyrics tag (prior to 1.9.5). + # This is not very important, but this keeps the database clean. This + # can be removed when everybody has cleaned his songs. + song.lyrics = song.lyrics.replace( + u'', u'') + verses = SongXML().get_verses(song.lyrics) + lyrics = u' '.join([whitespace.sub(u' ', verse[1]) for verse in verses]) + song.search_lyrics = lyrics.lower() + # We need a new and clean SongXML instance. + sxml = SongXML() + # Rebuild the song's verses, to remove any wrong verse names (for + # example translated ones), which might have been added prior to 1.9.5. + # List for later comparison. + compare_order = [] + for verse in verses: + verse_type = VerseType.Tags[VerseType.from_loose_input( + verse[0][u'type'])] + sxml.add_verse_to_lyrics( + verse_type, + verse[0][u'label'], + verse[1], + verse[0][u'lang'] if verse[0].has_key(u'lang') else None + ) + compare_order.append((u'%s%s' % (verse_type, verse[0][u'label']) + ).upper()) + if verse[0][u'label'] == u'1': + compare_order.append(verse_type.upper()) + song.lyrics = unicode(sxml.extract_xml(), u'utf-8') + # Rebuild the verse order, to convert translated verse tags, which might + # have been added prior to 1.9.5. + if song.verse_order: + order = song.verse_order.strip().split() + else: + order = [] + new_order = [] + for verse_def in order: + verse_type = VerseType.Tags[ + VerseType.from_loose_input(verse_def[0])] + if len(verse_def) > 1: + new_order.append( + (u'%s%s' % (verse_type, verse_def[1:])).upper()) + else: + new_order.append(verse_type.upper()) + song.verse_order = u' '.join(new_order) + # Check if the verse order contains tags for verses which do not exist. + for order in new_order: + if order not in compare_order: + song.verse_order = u'' + break # The song does not have any author, add one. if not song.authors: name = SongStrings.AuthorUnknown From 82a72fdc877831ee79e96bea02b3b2c778637c8a Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Sat, 28 May 2011 19:47:14 +0100 Subject: [PATCH 70/97] Don't set .parent's on Qt items, pass to init instead --- openlp/core/lib/dockwidget.py | 1 - openlp/core/lib/mediamanageritem.py | 3 +- openlp/core/lib/plugin.py | 3 +- openlp/core/lib/renderer.py | 4 +- openlp/core/ui/maindisplay.py | 3 +- openlp/core/ui/pluginform.py | 5 +-- openlp/core/ui/slidecontroller.py | 43 +++++++++---------- openlp/plugins/alerts/forms/alertform.py | 1 - openlp/plugins/alerts/lib/alertsmanager.py | 9 ++-- .../presentations/presentationplugin.py | 2 +- openlp/plugins/songs/forms/editsongform.py | 4 +- 11 files changed, 37 insertions(+), 41 deletions(-) diff --git a/openlp/core/lib/dockwidget.py b/openlp/core/lib/dockwidget.py index 5c461bbf8..182b98c48 100644 --- a/openlp/core/lib/dockwidget.py +++ b/openlp/core/lib/dockwidget.py @@ -47,7 +47,6 @@ class OpenLPDockWidget(QtGui.QDockWidget): """ log.debug(u'Initialise the %s widget' % name) QtGui.QDockWidget.__init__(self, parent) - self.parent = parent if name: self.setObjectName(name) if icon: diff --git a/openlp/core/lib/mediamanageritem.py b/openlp/core/lib/mediamanageritem.py index 679aa12d6..602b3c55b 100644 --- a/openlp/core/lib/mediamanageritem.py +++ b/openlp/core/lib/mediamanageritem.py @@ -90,8 +90,7 @@ class MediaManagerItem(QtGui.QWidget): """ Constructor to create the media manager item. """ - QtGui.QWidget.__init__(self) - self.parent = parent + QtGui.QWidget.__init__(self, parent) self.whitespace = re.compile(r'\W+', re.UNICODE) self.plugin = plugin visible_title = self.plugin.getString(StringContent.VisibleName) diff --git a/openlp/core/lib/plugin.py b/openlp/core/lib/plugin.py index 974c59de2..65ed76dfe 100644 --- a/openlp/core/lib/plugin.py +++ b/openlp/core/lib/plugin.py @@ -215,7 +215,8 @@ class Plugin(QtCore.QObject): you need, and return it for integration into openlp.org. """ if self.media_item_class: - return self.media_item_class(self.mediadock, self, self.icon) + return self.media_item_class(self.mediadock.media_dock, self, + self.icon) return None def addImportMenuItem(self, importMenu): diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 079a9aa9c..4acf88202 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -77,7 +77,7 @@ class Renderer(object): self.theme_data = None self.bg_frame = None self.force_page = False - self.display = MainDisplay(self, self.image_manager, False) + self.display = MainDisplay(None, self.image_manager, False) self.display.setup() def update_display(self): @@ -86,7 +86,7 @@ class Renderer(object): """ log.debug(u'Update Display') self._calculate_default(self.screens.current[u'size']) - self.display = MainDisplay(self, self.image_manager, False) + self.display = MainDisplay(None, self.image_manager, False) self.display.setup() self.bg_frame = None self.theme_data = None diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index dc7c28ded..763b9bc8b 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -50,7 +50,8 @@ class MainDisplay(QtGui.QGraphicsView): """ def __init__(self, parent, image_manager, live): QtGui.QGraphicsView.__init__(self) - self.parent = parent + if parent: + self.setParent(parent) self.isLive = live self.image_manager = image_manager self.screens = ScreenList.get_instance() diff --git a/openlp/core/ui/pluginform.py b/openlp/core/ui/pluginform.py index 0f7f6dbeb..c93b08ccb 100644 --- a/openlp/core/ui/pluginform.py +++ b/openlp/core/ui/pluginform.py @@ -40,7 +40,6 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): """ def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) - self.parent = parent self.activePlugin = None self.programaticChange = False self.setupUi(self) @@ -65,7 +64,7 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): self._clearDetails() self.programaticChange = True pluginListWidth = 0 - for plugin in self.parent.pluginManager.plugins: + for plugin in self.parent().pluginManager.plugins: item = QtGui.QListWidgetItem(self.pluginListWidget) # We do this just to make 100% sure the status is an integer as # sometimes when it's loaded from the config, it isn't cast to int. @@ -117,7 +116,7 @@ class PluginForm(QtGui.QDialog, Ui_PluginViewDialog): plugin_name_singular = \ self.pluginListWidget.currentItem().text().split(u' ')[0] self.activePlugin = None - for plugin in self.parent.pluginManager.plugins: + for plugin in self.parent().pluginManager.plugins: if plugin.nameStrings[u'singular'] == plugin_name_singular: self.activePlugin = plugin break diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 98046ba2a..5cd128f5e 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -46,7 +46,6 @@ class SlideList(QtGui.QTableWidget): """ def __init__(self, parent=None, name=None): QtGui.QTableWidget.__init__(self, parent.controller) - self.parent = parent class SlideController(QtGui.QWidget): @@ -60,11 +59,10 @@ class SlideController(QtGui.QWidget): """ QtGui.QWidget.__init__(self, parent) self.isLive = isLive - self.parent = parent self.screens = ScreenList.get_instance() self.ratio = float(self.screens.current[u'size'].width()) / \ float(self.screens.current[u'size'].height()) - self.image_manager = self.parent.image_manager + self.image_manager = self.parent().image_manager self.loopList = [ u'Start Loop', u'Loop Separator', @@ -461,7 +459,7 @@ class SlideController(QtGui.QWidget): self.previewListWidget.resizeRowsToContents() else: # Sort out image heights. - width = self.parent.controlSplitter.sizes()[self.split] + width = self.parent().controlSplitter.sizes()[self.split] for framenumber in range(len(self.serviceItem.get_frames())): self.previewListWidget.setRowHeight( framenumber, width / self.ratio) @@ -502,7 +500,7 @@ class SlideController(QtGui.QWidget): self.toolbar.actions[u'Stop Loop'].setVisible(False) if item.is_text(): if QtCore.QSettings().value( - self.parent.songsSettingsSection + u'/display songbar', + self.parent().songsSettingsSection + u'/display songbar', QtCore.QVariant(True)).toBool() and len(self.slideList) > 0: self.toolbar.makeWidgetsVisible([u'Song Menu']) if item.is_capable(ItemCapabilities.AllowsLoop) and \ @@ -591,7 +589,7 @@ class SlideController(QtGui.QWidget): Receiver.send_message(u'%s_start' % serviceItem.name.lower(), [serviceItem, self.isLive, self.hideMode(), slideno]) self.slideList = {} - width = self.parent.controlSplitter.sizes()[self.split] + width = self.parent().controlSplitter.sizes()[self.split] self.previewListWidget.clear() self.previewListWidget.setRowCount(0) self.previewListWidget.setColumnWidth(0, width) @@ -625,8 +623,8 @@ class SlideController(QtGui.QWidget): label.setScaledContents(True) if self.serviceItem.is_command(): image = resize_image(frame[u'image'], - self.parent.renderer.width, - self.parent.renderer.height) + self.parent().renderer.width, + self.parent().renderer.height) else: # If current slide set background to image if framenumber == slideno: @@ -635,7 +633,7 @@ class SlideController(QtGui.QWidget): image = self.image_manager.get_image(frame[u'title']) label.setPixmap(QtGui.QPixmap.fromImage(image)) self.previewListWidget.setCellWidget(framenumber, 0, label) - slideHeight = width * self.parent.renderer.screen_ratio + slideHeight = width * self.parent().renderer.screen_ratio row += 1 text.append(unicode(row)) self.previewListWidget.setItem(framenumber, 0, item) @@ -736,7 +734,7 @@ class SlideController(QtGui.QWidget): """ log.debug(u'mainDisplaySetBackground live = %s' % self.isLive) display_type = QtCore.QSettings().value( - self.parent.generalSettingsSection + u'/screen blank', + self.parent().generalSettingsSection + u'/screen blank', QtCore.QVariant(u'')).toString() if not self.display.primary: # Order done to handle initial conversion @@ -772,11 +770,11 @@ class SlideController(QtGui.QWidget): self.desktopScreen.setChecked(False) if checked: QtCore.QSettings().setValue( - self.parent.generalSettingsSection + u'/screen blank', + self.parent().generalSettingsSection + u'/screen blank', QtCore.QVariant(u'blanked')) else: QtCore.QSettings().remove( - self.parent.generalSettingsSection + u'/screen blank') + self.parent().generalSettingsSection + u'/screen blank') self.blankPlugin() self.updatePreview() @@ -793,11 +791,11 @@ class SlideController(QtGui.QWidget): self.desktopScreen.setChecked(False) if checked: QtCore.QSettings().setValue( - self.parent.generalSettingsSection + u'/screen blank', + self.parent().generalSettingsSection + u'/screen blank', QtCore.QVariant(u'themed')) else: QtCore.QSettings().remove( - self.parent.generalSettingsSection + u'/screen blank') + self.parent().generalSettingsSection + u'/screen blank') self.blankPlugin() self.updatePreview() @@ -814,11 +812,11 @@ class SlideController(QtGui.QWidget): self.desktopScreen.setChecked(checked) if checked: QtCore.QSettings().setValue( - self.parent.generalSettingsSection + u'/screen blank', + self.parent().generalSettingsSection + u'/screen blank', QtCore.QVariant(u'hidden')) else: QtCore.QSettings().remove( - self.parent.generalSettingsSection + u'/screen blank') + self.parent().generalSettingsSection + u'/screen blank') self.hidePlugin(checked) self.updatePreview() @@ -956,8 +954,8 @@ class SlideController(QtGui.QWidget): else: row = self.previewListWidget.currentRow() + 1 if row == self.previewListWidget.rowCount(): - if QtCore.QSettings().value(self.parent.generalSettingsSection + - u'/enable slide loop', QtCore.QVariant(True)).toBool(): + if QtCore.QSettings().value(self.parent().generalSettingsSection + + u'/enable slide loop', QtCore.QVariant(True)).toBool(): row = 0 else: row = self.previewListWidget.rowCount() - 1 @@ -977,8 +975,8 @@ class SlideController(QtGui.QWidget): else: row = self.previewListWidget.currentRow() - 1 if row == -1: - if QtCore.QSettings().value(self.parent.generalSettingsSection + - u'/enable slide loop', QtCore.QVariant(True)).toBool(): + if QtCore.QSettings().value(self.parent().generalSettingsSection + + u'/enable slide loop', QtCore.QVariant(True)).toBool(): row = self.previewListWidget.rowCount() - 1 else: row = 0 @@ -1055,7 +1053,8 @@ class SlideController(QtGui.QWidget): From the preview display request the Item to be added to service """ if self.serviceItem: - self.parent.serviceManagerContents.addServiceItem(self.serviceItem) + self.parent().serviceManagerContents.addServiceItem( + self.serviceItem) def onGoLiveClick(self): """ @@ -1083,7 +1082,7 @@ class SlideController(QtGui.QWidget): Receiver.send_message('servicemanager_preview_live', u'%s:%s' % (self.serviceItem._uuid, row)) else: - self.parent.liveController.addServiceManagerItem( + self.parent().liveController.addServiceManagerItem( self.serviceItem, row) def onMediaStart(self, item): diff --git a/openlp/plugins/alerts/forms/alertform.py b/openlp/plugins/alerts/forms/alertform.py index 92db42723..1415c809c 100644 --- a/openlp/plugins/alerts/forms/alertform.py +++ b/openlp/plugins/alerts/forms/alertform.py @@ -42,7 +42,6 @@ class AlertForm(QtGui.QDialog, Ui_AlertDialog): """ self.manager = plugin.manager self.plugin = plugin - self.parent = plugin.formparent self.item_id = None QtGui.QDialog.__init__(self, plugin.formparent) self.setupUi(self) diff --git a/openlp/plugins/alerts/lib/alertsmanager.py b/openlp/plugins/alerts/lib/alertsmanager.py index c55e76ef7..1d40d5dd3 100644 --- a/openlp/plugins/alerts/lib/alertsmanager.py +++ b/openlp/plugins/alerts/lib/alertsmanager.py @@ -40,8 +40,7 @@ class AlertsManager(QtCore.QObject): log.info(u'Alert Manager loaded') def __init__(self, parent): - QtCore.QObject.__init__(self) - self.parent = parent + QtCore.QObject.__init__(self, parent) self.screen = None self.timer_id = 0 self.alertList = [] @@ -85,8 +84,8 @@ class AlertsManager(QtCore.QObject): if len(self.alertList) == 0: return text = self.alertList.pop(0) - alertTab = self.parent.settings_tab - self.parent.liveController.display.alert(text) + alertTab = self.parent().settings_tab + self.parent().liveController.display.alert(text) # Check to see if we have a timer running. if self.timer_id == 0: self.timer_id = self.startTimer(int(alertTab.timeout) * 1000) @@ -101,7 +100,7 @@ class AlertsManager(QtCore.QObject): """ log.debug(u'timer event') if event.timerId() == self.timer_id: - self.parent.liveController.display.alert(u'') + self.parent().liveController.display.alert(u'') self.killTimer(self.timer_id) self.timer_id = 0 self.generateAlert() diff --git a/openlp/plugins/presentations/presentationplugin.py b/openlp/plugins/presentations/presentationplugin.py index 313e6258f..29acb73f4 100644 --- a/openlp/plugins/presentations/presentationplugin.py +++ b/openlp/plugins/presentations/presentationplugin.py @@ -99,7 +99,7 @@ class PresentationPlugin(Plugin): Create the Media Manager List """ return PresentationMediaItem( - self.mediadock, self, self.icon, self.controllers) + self.mediadock.media_dock, self, self.icon, self.controllers) def registerControllers(self, controller): """ diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index c942e2daa..a958f180f 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -648,7 +648,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): text = unicode(self.songBookComboBox.currentText()) if item == 0 and text: temp_song_book = text - self.parent.song_maintenance_form.exec_() + self.parent().song_maintenance_form.exec_() self.loadAuthors() self.loadBooks() self.loadTopics() @@ -754,7 +754,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.song.topics.append(self.manager.get_object(Topic, topicId)) clean_song(self.manager, self.song) self.manager.save_object(self.song) - self.parent.auto_select_id = self.song.id + self.parent().auto_select_id = self.song.id def _processLyrics(self): """ From 147c41e16f6e07698e3f363cf68111692573f1c3 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Sat, 28 May 2011 20:38:19 +0100 Subject: [PATCH 71/97] Fix a couple of parents so the form opens in the right place --- openlp/plugins/custom/forms/editcustomform.py | 5 +++-- openlp/plugins/custom/lib/mediaitem.py | 3 ++- openlp/plugins/songs/forms/editsongform.py | 9 +++++---- openlp/plugins/songs/lib/mediaitem.py | 3 ++- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index 26a25e12a..054d6dbeb 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -43,12 +43,13 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): Class documentation goes here. """ log.info(u'Custom Editor loaded') - def __init__(self, parent, manager): + def __init__(self, mediaitem, parent, manager): """ Constructor """ QtGui.QDialog.__init__(self, parent) self.manager = manager + self.mediaitem = mediaitem self.setupUi(self) # Create other objects and forms. self.editSlideForm = EditCustomSlideForm(self) @@ -136,7 +137,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): self.customSlide.credits = unicode(self.creditEdit.text()) self.customSlide.theme_name = unicode(self.themeComboBox.currentText()) success = self.manager.save_object(self.customSlide) - self.parent().auto_select_id = self.customSlide.id + self.mediaitem().auto_select_id = self.customSlide.id return success def onUpButtonClicked(self): diff --git a/openlp/plugins/custom/lib/mediaitem.py b/openlp/plugins/custom/lib/mediaitem.py index 2ae3ff85f..0398d8fa2 100644 --- a/openlp/plugins/custom/lib/mediaitem.py +++ b/openlp/plugins/custom/lib/mediaitem.py @@ -58,7 +58,8 @@ class CustomMediaItem(MediaManagerItem): def __init__(self, parent, plugin, icon): self.IconPath = u'custom/custom' MediaManagerItem.__init__(self, parent, plugin, icon) - self.edit_custom_form = EditCustomForm(self, self.plugin.manager) + self.edit_custom_form = EditCustomForm(self, self.plugin.formparent, + self.plugin.manager) self.singleServiceItem = False self.quickPreviewAllowed = True self.hasSearch = True diff --git a/openlp/plugins/songs/forms/editsongform.py b/openlp/plugins/songs/forms/editsongform.py index a958f180f..c8c351509 100644 --- a/openlp/plugins/songs/forms/editsongform.py +++ b/openlp/plugins/songs/forms/editsongform.py @@ -47,11 +47,12 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): """ log.info(u'%s EditSongForm loaded', __name__) - def __init__(self, parent, manager): + def __init__(self, mediaitem, parent, manager): """ Constructor """ QtGui.QDialog.__init__(self, parent) + self.mediaitem = mediaitem self.song = None # can this be automated? self.width = 400 @@ -89,7 +90,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.onVerseListViewPressed) QtCore.QObject.connect(self.themeAddButton, QtCore.SIGNAL(u'clicked()'), - self.parent().plugin.renderer.theme_manager.onAddTheme) + self.mediaitem.plugin.renderer.theme_manager.onAddTheme) QtCore.QObject.connect(self.maintenanceButton, QtCore.SIGNAL(u'clicked()'), self.onMaintenanceButtonClicked) QtCore.QObject.connect(Receiver.get_receiver(), @@ -648,7 +649,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): text = unicode(self.songBookComboBox.currentText()) if item == 0 and text: temp_song_book = text - self.parent().song_maintenance_form.exec_() + self.mediaitem.song_maintenance_form.exec_() self.loadAuthors() self.loadBooks() self.loadTopics() @@ -754,7 +755,7 @@ class EditSongForm(QtGui.QDialog, Ui_EditSongDialog): self.song.topics.append(self.manager.get_object(Topic, topicId)) clean_song(self.manager, self.song) self.manager.save_object(self.song) - self.parent().auto_select_id = self.song.id + self.mediaitem.auto_select_id = self.song.id def _processLyrics(self): """ diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 9ced6179b..02108a846 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -63,7 +63,8 @@ class SongMediaItem(MediaManagerItem): def __init__(self, parent, plugin, icon): self.IconPath = u'songs/song' MediaManagerItem.__init__(self, parent, plugin, icon) - self.edit_song_form = EditSongForm(self, self.plugin.manager) + self.edit_song_form = EditSongForm(self, self.plugin.formparent, + self.plugin.manager) self.openLyrics = OpenLyrics(self.plugin.manager) self.singleServiceItem = False self.song_maintenance_form = SongMaintenanceForm( From ddf11d468157fd1084e8b2910a825b44de24f313 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Sat, 28 May 2011 21:12:32 +0100 Subject: [PATCH 72/97] Live dangerously, and pass parent None to MainDisplay --- openlp/core/ui/maindisplay.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index 763b9bc8b..715bb3b5b 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -49,9 +49,7 @@ class MainDisplay(QtGui.QGraphicsView): This is the display screen. """ def __init__(self, parent, image_manager, live): - QtGui.QGraphicsView.__init__(self) - if parent: - self.setParent(parent) + QtGui.QGraphicsView.__init__(self, parent) self.isLive = live self.image_manager = image_manager self.screens = ScreenList.get_instance() From caa6639c7b184d348c25099479a3cd66895550e5 Mon Sep 17 00:00:00 2001 From: Gerald Britton Date: Sat, 28 May 2011 16:43:33 -0400 Subject: [PATCH 73/97] Uglification to conform to weird standards :) --- openlp/plugins/songs/lib/oooimport.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/openlp/plugins/songs/lib/oooimport.py b/openlp/plugins/songs/lib/oooimport.py index 45e85f64c..ddbab8b31 100644 --- a/openlp/plugins/songs/lib/oooimport.py +++ b/openlp/plugins/songs/lib/oooimport.py @@ -82,12 +82,11 @@ class OooImport(SongImport): self.close_ooo_file() else: self.log_error(self.filepath, - translate('SongsPlugin.SongImport', - 'Unable to open file')) + translate('SongsPlugin.SongImport', + 'Unable to open file')) else: self.log_error(self.filepath, - translate('SongsPlugin.SongImport', - 'File not found')) + translate('SongsPlugin.SongImport', 'File not found')) self.close_ooo() def process_ooo_document(self): From 81fca6bedb8e284bec07317afebd8fc71ed7b481 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sat, 28 May 2011 23:01:27 +0200 Subject: [PATCH 74/97] change layout of backup page change some strings --- .../plugins/bibles/forms/bibleupgradeform.py | 54 +++++++++++-------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleupgradeform.py b/openlp/plugins/bibles/forms/bibleupgradeform.py index 00623fbce..0fdcdfd11 100644 --- a/openlp/plugins/bibles/forms/bibleupgradeform.py +++ b/openlp/plugins/bibles/forms/bibleupgradeform.py @@ -147,6 +147,13 @@ class BibleUpgradeForm(OpenLPWizard): SettingsManager.set_last_dir(self.plugin.settingsSection, filename, 1) + def onNoBackupCheckBoxToggled(self, checked): + """ + Enable or disable the backup directory widgets. + """ + self.backupDirectoryEdit.setEnabled(not checked) + self.backupBrowseButton.setEnabled(not checked) + def backupOldBibles(self, backupdirectory): """ Backup old bible databases in a given folder. @@ -173,7 +180,9 @@ class BibleUpgradeForm(OpenLPWizard): QtCore.QObject.connect(self.finishButton, QtCore.SIGNAL(u'clicked()'), self.onFinishButton) QtCore.QObject.connect(self.backupBrowseButton, - QtCore.SIGNAL(u'clicked()'), self.onBackupBrowseButtonClicked) + QtCore.SIGNAL(u'clicked()'), self.onBackupBrowseButtonClicked) + QtCore.QObject.connect(self.noBackupCheckBox, + QtCore.SIGNAL(u'toggled(bool)'), self.onNoBackupCheckBoxToggled) def addCustomPages(self): """ @@ -185,9 +194,14 @@ class BibleUpgradeForm(OpenLPWizard): self.backupLayout = QtGui.QVBoxLayout(self.backupPage) self.backupLayout.setObjectName(u'BackupLayout') self.backupInfoLabel = QtGui.QLabel(self.backupPage) - self.backupInfoLabel.setObjectName(u'backupInfoLabel') + self.backupInfoLabel.setOpenExternalLinks(True) + self.backupInfoLabel.setTextFormat(QtCore.Qt.RichText) self.backupInfoLabel.setWordWrap(True) + self.backupInfoLabel.setObjectName(u'backupInfoLabel') self.backupLayout.addWidget(self.backupInfoLabel) + self.selectLabel = QtGui.QLabel(self.backupPage) + self.selectLabel.setObjectName(u'selectLabel') + self.backupLayout.addWidget(self.selectLabel) self.formLayout = QtGui.QFormLayout() self.formLayout.setMargin(0) self.formLayout.setObjectName(u'FormLayout') @@ -205,11 +219,6 @@ class BibleUpgradeForm(OpenLPWizard): self.formLayout.addRow(self.backupDirectoryLabel, self.backupDirectoryLayout) self.backupLayout.addLayout(self.formLayout) - self.backupAdditionalInfoLabel = QtGui.QLabel(self.backupPage) - self.backupAdditionalInfoLabel.setObjectName( - u'BackupAdditionalInfoLabel') - self.backupAdditionalInfoLabel.setWordWrap(True) - self.backupLayout.addWidget(self.backupAdditionalInfoLabel) self.noBackupCheckBox = QtGui.QCheckBox(self.backupPage) self.noBackupCheckBox.setObjectName('NoBackupCheckBox') self.backupLayout.addWidget(self.noBackupCheckBox) @@ -356,25 +365,24 @@ class BibleUpgradeForm(OpenLPWizard): translate('BiblesPlugin.UpgradeWizardForm', 'This wizard will help you to upgrade your existing Bibles from a ' 'prior version of OpenLP 2. Click the next button below to start ' - 'the process by selecting the Bibles to upgrade.')) + 'the upgrade process.')) self.backupPage.setTitle( translate('BiblesPlugin.UpgradeWizardForm', 'Select Backup Directory')) self.backupPage.setSubTitle( translate('BiblesPlugin.UpgradeWizardForm', - 'Please select a Directory for Backup your old Bibles')) + 'Please select a backup directory for your Bibles')) self.backupInfoLabel.setText(translate('BiblesPlugin.UpgradeWizardForm', - 'The Bible upgrade procedure will prevent you running older ' - 'versions of OpenLP. \nPlease select a backup location for your ' - 'existing Bibles.')) + 'Previous releases of OpenLP 2.0 are unable to use upgraded Bibles.' + ' This will create a backup of your current Bibles so that you can ' + 'simply copy the files back to your OpenLP data directory if you ' + 'need to revert to a previous release of OpenLP. Instructions on ' + 'how to restore the files can be found in our Frequently Asked Questions.')) + self.selectLabel.setText(translate('BiblesPlugin.UpgradeWizardForm', + 'Please select a backup location for your Bibles.')) self.backupDirectoryLabel.setText( translate('BiblesPlugin.UpgradeWizardForm', 'Backup Directory:')) - self.backupAdditionalInfoLabel.setText( - translate('BiblesPlugin.UpgradeWizardForm', - 'These Bibles can copied back to your OpenLP data folder should ' - 'you need to revert to a previous version. Instructions on how ' - 'to restore the files can be found on our FAQ ' - 'at http://wiki.openlp.org/faq')) self.noBackupCheckBox.setText( translate('BiblesPlugin.UpgradeWizardForm', 'There is no need to backup my Bibles')) @@ -749,21 +757,21 @@ class BibleUpgradeForm(OpenLPWizard): if failed_import > 0: failed_import_text = unicode(translate( 'BiblesPlugin.UpgradeWizardForm', - ' - %s upgrade fail')) % failed_import + ', %s failed')) % failed_import else: failed_import_text = u'' if successful_import > 0: if include_webbible: self.progressLabel.setText(unicode( - translate('BiblesPlugin.UpgradeWizardForm', 'Upgrade %s ' - 'Bible(s) successful%s.\nPlease note, that verses from ' + translate('BiblesPlugin.UpgradeWizardForm', 'Upgrading ' + 'Bible(s): %s successful%s\nPlease note, that verses from ' 'Web Bibles will be downloaded\non demand and so an ' 'Internet connection is required.')) % (successful_import, failed_import_text)) else: self.progressLabel.setText(unicode( - translate('BiblesPlugin.UpgradeWizardForm', 'Upgrade %s ' - 'Bible(s) successful.%s')) % (successful_import, + translate('BiblesPlugin.UpgradeWizardForm', 'Upgrading ' + 'Bible(s): %s successful%s')) % (successful_import, failed_import_text)) else: self.progressLabel.setText( From 975dd3cb00854537feb7f20d67c3958e90ccdc4e Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Sat, 28 May 2011 22:23:07 +0100 Subject: [PATCH 75/97] mediaitem() -> mediaitem --- openlp/plugins/custom/forms/editcustomform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/custom/forms/editcustomform.py b/openlp/plugins/custom/forms/editcustomform.py index 054d6dbeb..5c9c035b7 100644 --- a/openlp/plugins/custom/forms/editcustomform.py +++ b/openlp/plugins/custom/forms/editcustomform.py @@ -137,7 +137,7 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog): self.customSlide.credits = unicode(self.creditEdit.text()) self.customSlide.theme_name = unicode(self.themeComboBox.currentText()) success = self.manager.save_object(self.customSlide) - self.mediaitem().auto_select_id = self.customSlide.id + self.mediaitem.auto_select_id = self.customSlide.id return success def onUpButtonClicked(self): From b56f93aad5e21ba4c0e3fcc60714d002fdc8c6aa Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 29 May 2011 08:23:12 +0200 Subject: [PATCH 76/97] camelCase fixes and shortcut fixes --- openlp/core/ui/mainwindow.py | 2 +- openlp/plugins/songusage/songusageplugin.py | 76 ++++++++++----------- 2 files changed, 38 insertions(+), 40 deletions(-) diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index 82f1b9253..3ebb34b8c 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -179,7 +179,7 @@ class Ui_MainWindow(object): u'printServiceItem', [QtGui.QKeySequence(u'Ctrl+P')], self.serviceManagerContents.printServiceOrder, category=UiStrings().File) - self.fileExitItem = shortcut_action(mainWindow, u'FileExitItem', + self.fileExitItem = shortcut_action(mainWindow, u'fileExitItem', [QtGui.QKeySequence(u'Alt+F4')], mainWindow.close, u':/system/system_exit.png', category=UiStrings().File) action_list.add_category(UiStrings().Import, CategoryOrder.standardMenu) diff --git a/openlp/plugins/songusage/songusageplugin.py b/openlp/plugins/songusage/songusageplugin.py index 7d05e0add..9a4f6910f 100644 --- a/openlp/plugins/songusage/songusageplugin.py +++ b/openlp/plugins/songusage/songusageplugin.py @@ -62,44 +62,44 @@ class SongUsagePlugin(Plugin): """ log.info(u'add tools menu') self.toolsMenu = tools_menu - self.SongUsageMenu = QtGui.QMenu(tools_menu) - self.SongUsageMenu.setObjectName(u'SongUsageMenu') - self.SongUsageMenu.setTitle(translate( + self.songUsageMenu = QtGui.QMenu(tools_menu) + self.songUsageMenu.setObjectName(u'songUsageMenu') + self.songUsageMenu.setTitle(translate( 'SongUsagePlugin', '&Song Usage Tracking')) # SongUsage Delete - self.SongUsageDelete = base_action(tools_menu, u'SongUsageDelete') - self.SongUsageDelete.setText(translate('SongUsagePlugin', + self.songUsageDelete = base_action(tools_menu, u'songUsageDelete') + self.songUsageDelete.setText(translate('SongUsagePlugin', '&Delete Tracking Data')) - self.SongUsageDelete.setStatusTip(translate('SongUsagePlugin', + self.songUsageDelete.setStatusTip(translate('SongUsagePlugin', 'Delete song usage data up to a specified date.')) # SongUsage Report - self.SongUsageReport = base_action(tools_menu, u'SongUsageReport') - self.SongUsageReport.setText( + self.songUsageReport = base_action(tools_menu, u'songUsageReport') + self.songUsageReport.setText( translate('SongUsagePlugin', '&Extract Tracking Data')) - self.SongUsageReport.setStatusTip( + self.songUsageReport.setStatusTip( translate('SongUsagePlugin', 'Generate a report on song usage.')) # SongUsage activation - self.SongUsageStatus = shortcut_action(tools_menu, u'SongUsageStatus', + self.songUsageStatus = shortcut_action(tools_menu, u'songUsageStatus', [QtCore.Qt.Key_F4], self.toggleSongUsageState, checked=False) - self.SongUsageStatus.setText(translate( + self.songUsageStatus.setText(translate( 'SongUsagePlugin', 'Toggle Tracking')) - self.SongUsageStatus.setStatusTip(translate('SongUsagePlugin', + self.songUsageStatus.setStatusTip(translate('SongUsagePlugin', 'Toggle the tracking of song usage.')) #Add Menus together - self.toolsMenu.addAction(self.SongUsageMenu.menuAction()) - self.SongUsageMenu.addAction(self.SongUsageStatus) - self.SongUsageMenu.addSeparator() - self.SongUsageMenu.addAction(self.SongUsageDelete) - self.SongUsageMenu.addAction(self.SongUsageReport) + self.toolsMenu.addAction(self.songUsageMenu.menuAction()) + self.songUsageMenu.addAction(self.songUsageStatus) + self.songUsageMenu.addSeparator() + self.songUsageMenu.addAction(self.songUsageDelete) + self.songUsageMenu.addAction(self.songUsageReport) # Signals and slots - QtCore.QObject.connect(self.SongUsageStatus, + QtCore.QObject.connect(self.songUsageStatus, QtCore.SIGNAL(u'visibilityChanged(bool)'), - self.SongUsageStatus.setChecked) - QtCore.QObject.connect(self.SongUsageDelete, + self.songUsageStatus.setChecked) + QtCore.QObject.connect(self.songUsageDelete, QtCore.SIGNAL(u'triggered()'), self.onSongUsageDelete) - QtCore.QObject.connect(self.SongUsageReport, + QtCore.QObject.connect(self.songUsageReport, QtCore.SIGNAL(u'triggered()'), self.onSongUsageReport) - self.SongUsageMenu.menuAction().setVisible(False) + self.songUsageMenu.menuAction().setVisible(False) def initialise(self): log.info(u'SongUsage Initialising') @@ -110,20 +110,20 @@ class SongUsagePlugin(Plugin): self.SongUsageActive = QtCore.QSettings().value( self.settingsSection + u'/active', QtCore.QVariant(False)).toBool() - self.SongUsageStatus.setChecked(self.SongUsageActive) + self.songUsageStatus.setChecked(self.SongUsageActive) action_list = ActionList.get_instance() - action_list.add_action(self.SongUsageDelete, + action_list.add_action(self.songUsageDelete, translate('SongUsagePlugin', 'Song Usage')) - action_list.add_action(self.SongUsageReport, + action_list.add_action(self.songUsageReport, translate('SongUsagePlugin', 'Song Usage')) - action_list.add_action(self.SongUsageStatus, + action_list.add_action(self.songUsageStatus, translate('SongUsagePlugin', 'Song Usage')) if self.manager is None: self.manager = Manager(u'songusage', init_schema) - self.SongUsagedeleteform = SongUsageDeleteForm(self.manager, + self.songUsageDeleteForm = SongUsageDeleteForm(self.manager, self.formparent) - self.SongUsagedetailform = SongUsageDetailForm(self, self.formparent) - self.SongUsageMenu.menuAction().setVisible(True) + self.songUsageDetailForm = SongUsageDetailForm(self, self.formparent) + self.songUsageMenu.menuAction().setVisible(True) def finalise(self): """ @@ -132,13 +132,13 @@ class SongUsagePlugin(Plugin): log.info(u'Plugin Finalise') self.manager.finalise() Plugin.finalise(self) - self.SongUsageMenu.menuAction().setVisible(False) + self.songUsageMenu.menuAction().setVisible(False) action_list = ActionList.get_instance() - action_list.remove_action(self.SongUsageDelete, + action_list.remove_action(self.songUsageDelete, translate('SongUsagePlugin', 'Song Usage')) - action_list.remove_action(self.SongUsageReport, + action_list.remove_action(self.songUsageReport, translate('SongUsagePlugin', 'Song Usage')) - action_list.remove_action(self.SongUsageStatus, + action_list.remove_action(self.songUsageStatus, translate('SongUsagePlugin', 'Song Usage')) #stop any events being processed self.SongUsageActive = False @@ -160,17 +160,15 @@ class SongUsagePlugin(Plugin): song_usage_item.title = audit[0] song_usage_item.copyright = audit[2] song_usage_item.ccl_number = audit[3] - song_usage_item.authors = u'' - for author in audit[1]: - song_usage_item.authors += author + u' ' + song_usage_item.authors = u' '.join(audit[1]) self.manager.save_object(song_usage_item) def onSongUsageDelete(self): - self.SongUsagedeleteform.exec_() + self.songUsageDeleteForm.exec_() def onSongUsageReport(self): - self.SongUsagedetailform.initialise() - self.SongUsagedetailform.exec_() + self.songUsageDetailForm.initialise() + self.songUsageDetailForm.exec_() def about(self): about_text = translate('SongUsagePlugin', 'SongUsage Plugin' From 22ad88d3ee36c284e67d0d9dd35729bd4a9606e4 Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Sun, 29 May 2011 08:26:14 +0200 Subject: [PATCH 78/97] fix for bug #789618 Fixes: https://launchpad.net/bugs/789618 --- openlp/core/ui/printserviceform.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/openlp/core/ui/printserviceform.py b/openlp/core/ui/printserviceform.py index 09ae8857f..b1147731b 100644 --- a/openlp/core/ui/printserviceform.py +++ b/openlp/core/ui/printserviceform.py @@ -56,7 +56,9 @@ http://doc.trolltech.com/4.7/richtext-html-subset.html#css-properties font-size:large; } -.itemText {} +.itemText { + margin-top:10px; +} .itemFooter { font-size:8px; @@ -85,7 +87,7 @@ http://doc.trolltech.com/4.7/richtext-html-subset.html#css-properties .imageList {} .customNotes { - margin-top: 10px; + margin-top:10px; } .customNotesTitle { @@ -212,11 +214,11 @@ class PrintServiceForm(QtGui.QDialog, Ui_PrintServiceDialog): verse_def = None for slide in item.get_frames(): if not verse_def or verse_def != slide[u'verseTag']: - p = self._addElement(u'div', parent=div, + text_div = self._addElement(u'div', parent=div, classId=u'itemText') else: - self._addElement(u'br', parent=p) - self._addElement(u'p', slide[u'html'], p) + self._addElement(u'br', parent=text_div) + self._addElement(u'span', slide[u'html'], text_div) verse_def = slide[u'verseTag'] # Break the page before the div element. if index != 0 and self.pageBreakAfterText.isChecked(): From a8ea8d668a5067af5f2b975f0ba5545811e3e028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sun, 29 May 2011 21:32:37 +0200 Subject: [PATCH 79/97] correct indent --- openlp/plugins/bibles/lib/manager.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 2cbd2f919..2a3858afc 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -219,9 +219,9 @@ class BibleManager(object): log.debug(u'BibleManager.get_books("%s")', bible) return [ { - u'name': book.name, - u'book_reference_id': book.book_reference_id, - u'chapters': self.db_cache[bible].get_chapter_count(book) + u'name': book.name, + u'book_reference_id': book.book_reference_id, + u'chapters': self.db_cache[bible].get_chapter_count(book) } for book in self.db_cache[bible].get_books() ] From 9cd536e137585ca2c90339effb3c3b3379ad71f1 Mon Sep 17 00:00:00 2001 From: Jonathan Corwin Date: Sun, 29 May 2011 21:46:13 +0100 Subject: [PATCH 80/97] Fix the parent that whydoubt sneaked in --- openlp/core/ui/slidecontroller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/core/ui/slidecontroller.py b/openlp/core/ui/slidecontroller.py index 6de04a64d..a59f00f21 100644 --- a/openlp/core/ui/slidecontroller.py +++ b/openlp/core/ui/slidecontroller.py @@ -199,7 +199,7 @@ class SlideController(QtGui.QWidget): u':/media/media_time.png', False, UiStrings().LiveToolbar) self.playSlidesOnce.setText( translate('OpenLP.SlideController', 'Play Slides to End')) - if QtCore.QSettings().value(self.parent.generalSettingsSection + + if QtCore.QSettings().value(self.parent().generalSettingsSection + u'/enable slide loop', QtCore.QVariant(True)).toBool(): self.playSlidesMenu.setDefaultAction(self.playSlidesLoop) else: From 0a2d97021cf97e04336fd271d33b0f2002ef70fc Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 30 May 2011 07:03:46 +0200 Subject: [PATCH 81/97] added spaces --- openlp/core/ui/printserviceform.py | 36 +++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/openlp/core/ui/printserviceform.py b/openlp/core/ui/printserviceform.py index b1147731b..ccd1eb18c 100644 --- a/openlp/core/ui/printserviceform.py +++ b/openlp/core/ui/printserviceform.py @@ -42,44 +42,44 @@ http://doc.trolltech.com/4.7/richtext-html-subset.html#css-properties */ .serviceTitle { - font-weight:600; - font-size:x-large; - color:black; + font-weight: 600; + font-size: x-large; + color: black; } .item { - color:black; + color: black; } .itemTitle { - font-weight:600; - font-size:large; + font-weight: 600; + font-size: large; } .itemText { - margin-top:10px; + margin-top: 10px; } .itemFooter { - font-size:8px; + font-size: 8px; } .itemNotes {} .itemNotesTitle { - font-weight:bold; - font-size:12px; + font-weight: bold; + font-size: 12px; } .itemNotesText { - font-size:11px; + font-size: 11px; } .media {} .mediaTitle { - font-weight:bold; - font-size:11px; + font-weight: bold; + font-size: 11px; } .mediaText {} @@ -87,20 +87,20 @@ http://doc.trolltech.com/4.7/richtext-html-subset.html#css-properties .imageList {} .customNotes { - margin-top:10px; + margin-top: 10px; } .customNotesTitle { - font-weight:bold; - font-size:11px; + font-weight: bold; + font-size: 11px; } .customNotesText { - font-size:11px; + font-size: 11px; } .newPage { - page-break-before:always; + page-break-before: always; } """ From 30ec309ff8550cab242331aabcaf2f27cfbd7ff6 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Mon, 30 May 2011 08:45:58 +0200 Subject: [PATCH 82/97] Fixed up various index errors on InnoDB tables. --- openlp/plugins/songs/lib/db.py | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/openlp/plugins/songs/lib/db.py b/openlp/plugins/songs/lib/db.py index ced98537e..9a332e994 100644 --- a/openlp/plugins/songs/lib/db.py +++ b/openlp/plugins/songs/lib/db.py @@ -165,7 +165,7 @@ def init_schema(url): Column(u'id', types.Integer, primary_key=True), Column(u'first_name', types.Unicode(128)), Column(u'last_name', types.Unicode(128)), - Column(u'display_name', types.Unicode(255), nullable=False) + Column(u'display_name', types.Unicode(255), index=True, nullable=False) ) # Definition of the "media_files" table @@ -186,7 +186,7 @@ def init_schema(url): songs_table = Table(u'songs', metadata, Column(u'id', types.Integer, primary_key=True), Column(u'song_book_id', types.Integer, - ForeignKey(u'song_books.id'), default=0), + ForeignKey(u'song_books.id'), default=None), Column(u'title', types.Unicode(255), nullable=False), Column(u'alternate_title', types.Unicode(255)), Column(u'lyrics', types.UnicodeText, nullable=False), @@ -203,7 +203,7 @@ def init_schema(url): # Definition of the "topics" table topics_table = Table(u'topics', metadata, Column(u'id', types.Integer, primary_key=True), - Column(u'name', types.Unicode(128), nullable=False) + Column(u'name', types.Unicode(128), index=True, nullable=False) ) # Definition of the "authors_songs" table @@ -230,27 +230,6 @@ def init_schema(url): ForeignKey(u'topics.id'), primary_key=True) ) - # Define table indexes - Index(u'authors_id', authors_table.c.id) - Index(u'authors_display_name_id', authors_table.c.display_name, - authors_table.c.id) - Index(u'media_files_id', media_files_table.c.id) - Index(u'song_books_id', song_books_table.c.id) - Index(u'songs_id', songs_table.c.id) - Index(u'topics_id', topics_table.c.id) - Index(u'authors_songs_author', authors_songs_table.c.author_id, - authors_songs_table.c.song_id) - Index(u'authors_songs_song', authors_songs_table.c.song_id, - authors_songs_table.c.author_id) - Index(u'media_files_songs_file', media_files_songs_table.c.media_file_id, - media_files_songs_table.c.song_id) - Index(u'media_files_songs_song', media_files_songs_table.c.song_id, - media_files_songs_table.c.media_file_id) - Index(u'topics_song_topic', songs_topics_table.c.topic_id, - songs_topics_table.c.song_id) - Index(u'topics_song_song', songs_topics_table.c.song_id, - songs_topics_table.c.topic_id) - mapper(Author, authors_table) mapper(Book, song_books_table) mapper(MediaFile, media_files_table) From 99ae60aba318fc9b50bcaa1552ccac61cae593a4 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Mon, 30 May 2011 13:17:23 +0200 Subject: [PATCH 83/97] Fixed up loading a song from a service. --- openlp/plugins/songs/lib/mediaitem.py | 1 + openlp/plugins/songs/lib/xml.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/mediaitem.py b/openlp/plugins/songs/lib/mediaitem.py index 3d9a9ef76..65e2289cd 100644 --- a/openlp/plugins/songs/lib/mediaitem.py +++ b/openlp/plugins/songs/lib/mediaitem.py @@ -27,6 +27,7 @@ import logging import locale +import re from PyQt4 import QtCore, QtGui from sqlalchemy.sql import or_ diff --git a/openlp/plugins/songs/lib/xml.py b/openlp/plugins/songs/lib/xml.py index 7bcf56aa1..f5ec28103 100644 --- a/openlp/plugins/songs/lib/xml.py +++ b/openlp/plugins/songs/lib/xml.py @@ -514,7 +514,7 @@ class OpenLyrics(object): ``song`` The song object. """ - song.song_book_id = 0 + song.song_book_id = None song.song_number = u'' if hasattr(properties, u'songbooks'): for songbook in properties.songbooks.songbook: From ed3a608b8da9c5f3093f55b7cdc7054871e42dce Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 30 May 2011 17:07:49 +0200 Subject: [PATCH 85/97] fixed tag deletion (bug #789929 Fixes: https://launchpad.net/bugs/789929 --- openlp/core/ui/displaytagform.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/openlp/core/ui/displaytagform.py b/openlp/core/ui/displaytagform.py index 6aaddf2b8..4b25f851a 100644 --- a/openlp/core/ui/displaytagform.py +++ b/openlp/core/ui/displaytagform.py @@ -147,6 +147,7 @@ class DisplayTagForm(QtGui.QDialog, Ui_DisplayTagDialog): DisplayTags.remove_html_tag(self.selected) self.selected = -1 self._resetTable() + self._saveTable() def onSavedPushed(self): """ @@ -171,14 +172,19 @@ class DisplayTagForm(QtGui.QDialog, Ui_DisplayTagDialog): html[u'end tag'] = u'{/%s}' % tag self.selected = -1 self._resetTable() - temp = [] + self._saveTable() + + def _saveTable(self): + """ + Saves all display tags except protected ones. + """ + tags = [] for tag in DisplayTags.get_html_tags(): if not tag[u'protected']: - temp.append(tag) - if temp: - ctemp = cPickle.dumps(temp) + tags.append(tag) + if tags: QtCore.QSettings().setValue(u'displayTags/html_tags', - QtCore.QVariant(ctemp)) + QtCore.QVariant(cPickle.dumps(tags))) else: QtCore.QSettings().setValue(u'displayTags/html_tags', QtCore.QVariant(u'')) From 27b8ec3deba4fc948d29c3c9daec37cf442c59d1 Mon Sep 17 00:00:00 2001 From: Gerald Britton Date: Mon, 30 May 2011 15:19:16 -0400 Subject: [PATCH 86/97] Add exception logging to import.py --- openlp/plugins/songs/lib/importer.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/openlp/plugins/songs/lib/importer.py b/openlp/plugins/songs/lib/importer.py index cf2d3f536..fffc0f4f8 100644 --- a/openlp/plugins/songs/lib/importer.py +++ b/openlp/plugins/songs/lib/importer.py @@ -38,20 +38,25 @@ from songbeamerimport import SongBeamerImport from songshowplusimport import SongShowPlusImport from foilpresenterimport import FoilPresenterImport # Imports that might fail +import logging +log = logging.getLogger(__name__) try: from olp1import import OpenLP1SongImport HAS_OPENLP1 = True except ImportError: + log.exception('Error importing %s', 'OpenLP1SongImport') HAS_OPENLP1 = False try: from sofimport import SofImport HAS_SOF = True except ImportError: + log.exception('Error importing %s', 'SofImport') HAS_SOF = False try: from oooimport import OooImport HAS_OOO = True except ImportError: + log.exception('Error importing %s', 'OooImport') HAS_OOO = False class SongFormat(object): From ab3896ce6fd431de6ac946ae5b4a416ec4e44e9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Mon, 30 May 2011 21:41:02 +0200 Subject: [PATCH 87/97] removed unnecessary code --- openlp/plugins/bibles/lib/mediaitem.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 2ade16e6d..d6911b936 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -534,8 +534,6 @@ class BibleMediaItem(MediaManagerItem): unicode(self.advancedVersionComboBox.currentText())) def onAdvancedSecondComboBox(self): - QtCore.QSettings().setValue(self.settingsSection + u'/advanced bible', - QtCore.QVariant(self.advancedVersionComboBox.currentText())) self.initialiseAdvancedBible( unicode(self.advancedVersionComboBox.currentText())) From 934a70b9555339539757bc97c78f10fc8d5ec3d3 Mon Sep 17 00:00:00 2001 From: Gerald Britton Date: Mon, 30 May 2011 16:14:36 -0400 Subject: [PATCH 88/97] Relocate import logging statement --- openlp/plugins/songs/lib/importer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/importer.py b/openlp/plugins/songs/lib/importer.py index fffc0f4f8..ab92033c4 100644 --- a/openlp/plugins/songs/lib/importer.py +++ b/openlp/plugins/songs/lib/importer.py @@ -27,6 +27,7 @@ """ The :mod:`importer` modules provides the general song import functionality. """ +import logging from opensongimport import OpenSongImport from easislidesimport import EasiSlidesImport from olpimport import OpenLPSongImport @@ -38,7 +39,6 @@ from songbeamerimport import SongBeamerImport from songshowplusimport import SongShowPlusImport from foilpresenterimport import FoilPresenterImport # Imports that might fail -import logging log = logging.getLogger(__name__) try: from olp1import import OpenLP1SongImport From cde0eb5ab571462751e6291317597aed4a86f331 Mon Sep 17 00:00:00 2001 From: Gerald Britton Date: Mon, 30 May 2011 17:15:34 -0400 Subject: [PATCH 89/97] Only import uno exceptions if not running Windoes --- openlp/plugins/songs/lib/oooimport.py | 1 + openlp/plugins/songs/lib/sofimport.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/openlp/plugins/songs/lib/oooimport.py b/openlp/plugins/songs/lib/oooimport.py index ddbab8b31..fb6ee43a6 100644 --- a/openlp/plugins/songs/lib/oooimport.py +++ b/openlp/plugins/songs/lib/oooimport.py @@ -40,6 +40,7 @@ if os.name == u'nt': PAGE_BEFORE = 4 PAGE_AFTER = 5 PAGE_BOTH = 6 + NoConnectException = Exception else: import uno from com.sun.star.connection import NoConnectException diff --git a/openlp/plugins/songs/lib/sofimport.py b/openlp/plugins/songs/lib/sofimport.py index 5cc0482f2..7f0bed72b 100644 --- a/openlp/plugins/songs/lib/sofimport.py +++ b/openlp/plugins/songs/lib/sofimport.py @@ -36,7 +36,7 @@ import os import re from oooimport import OooImport -from com.sun.star.uno import RuntimeException + log = logging.getLogger(__name__) @@ -44,12 +44,14 @@ if os.name == u'nt': BOLD = 150.0 ITALIC = 2 from oooimport import PAGE_BEFORE, PAGE_AFTER, PAGE_BOTH + RuntimeException = Exception else: try: from com.sun.star.awt.FontWeight import BOLD from com.sun.star.awt.FontSlant import ITALIC from com.sun.star.style.BreakType import PAGE_BEFORE, PAGE_AFTER, \ PAGE_BOTH + from com.sun.star.uno import RuntimeException except ImportError: pass From ee151cde2a7bd04b574c6892432b33e2873b71bc Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Tue, 31 May 2011 12:59:05 +0200 Subject: [PATCH 90/97] Fixed bug #790382 by using the Mako template engine to pass Python variables into the template. --- openlp/plugins/remotes/html/index.html | 60 ++++++++++++------------ openlp/plugins/remotes/html/stage.html | 4 +- openlp/plugins/remotes/lib/httpserver.py | 38 +++++++++++++-- 3 files changed, 65 insertions(+), 37 deletions(-) diff --git a/openlp/plugins/remotes/html/index.html b/openlp/plugins/remotes/html/index.html index 6390b9446..b370d589e 100644 --- a/openlp/plugins/remotes/html/index.html +++ b/openlp/plugins/remotes/html/index.html @@ -27,7 +27,7 @@ --> - OpenLP 2.0 Remote + ${app_title} @@ -37,81 +37,81 @@
- Back -

Service Manager

- Refresh + ${back} +

${service_manager}

+ ${refresh}
- Back -

Slide Controller

- Refresh + ${back} +

${slide_controller}

+ ${refresh}
- Back -

Alerts

+ ${back} +

${alerts}

- +
- Show Alert + ${show_alert}
- + \ No newline at end of file diff --git a/openlp/plugins/remotes/html/stage.html b/openlp/plugins/remotes/html/stage.html index b67f0ccd6..c002ea68b 100644 --- a/openlp/plugins/remotes/html/stage.html +++ b/openlp/plugins/remotes/html/stage.html @@ -6,8 +6,8 @@ # --------------------------------------------------------------------------- # # Copyright (c) 2008-2011 Raoul Snyman # # Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael # -# Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin Khler, # -# Andreas Preikschat, Mattias Pldaru, Christian Richter, Philip Ridout, # +# Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin Köhler, # +# Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout, # # Jeffrey Smith, Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode # # Woldsund # # --------------------------------------------------------------------------- # diff --git a/openlp/plugins/remotes/lib/httpserver.py b/openlp/plugins/remotes/lib/httpserver.py index 9d29156f7..d9cae42d0 100644 --- a/openlp/plugins/remotes/lib/httpserver.py +++ b/openlp/plugins/remotes/lib/httpserver.py @@ -115,7 +115,6 @@ import logging import os import urlparse import re -from pprint import pformat try: import json @@ -123,10 +122,11 @@ except ImportError: import simplejson as json from PyQt4 import QtCore, QtNetwork +from mako.template import Template from openlp.core.lib import Receiver, PluginStatus from openlp.core.ui import HideMode -from openlp.core.utils import AppLocation +from openlp.core.utils import AppLocation, translate log = logging.getLogger(__name__) @@ -261,6 +261,7 @@ class HttpConnection(object): self.ready_read) QtCore.QObject.connect(self.socket, QtCore.SIGNAL(u'disconnected()'), self.disconnected) + self.translate() def _get_service_items(self): service_items = [] @@ -280,6 +281,27 @@ class HttpConnection(object): }) return service_items + def translate(self): + """ + Translate various strings in the mobile app. + """ + self.template_vars = { + 'app_title': translate('RemotePlugin.Mobile', 'OpenLP 2.0 Remote'), + 'stage_title': translate('RemotePlugin.Mobile', 'OpenLP 2.0 Stage View'), + 'service_manager': translate('RemotePlugin.Mobile', 'Service Manager'), + 'slide_controller': translate('RemotePlugin.Mobile', 'Slide Controller'), + 'alerts': translate('RemotePlugin.Mobile', 'Alerts'), + 'search': translate('RemotePlugin.Mobile', 'Search'), + 'back': translate('RemotePlugin.Mobile', 'Back'), + 'refresh': translate('RemotePlugin.Mobile', 'Refresh'), + 'blank': translate('RemotePlugin.Mobile', 'Blank'), + 'show': translate('RemotePlugin.Mobile', 'Show'), + 'prev': translate('RemotePlugin.Mobile', 'Prev'), + 'next': translate('RemotePlugin.Mobile', 'Next'), + 'text': translate('RemotePlugin.Mobile', 'Text'), + 'show_alert': translate('RemotePlugin.Mobile', 'Show Alert') + } + def ready_read(self): """ Data has been sent from the client. Respond to it @@ -327,8 +349,11 @@ class HttpConnection(object): if not path.startswith(self.parent.html_dir): return HttpResponse(code=u'404 Not Found') ext = os.path.splitext(filename)[1] + html = None if ext == u'.html': mimetype = u'text/html' + variables = self.template_vars + html = Template(filename=path, input_encoding=u'utf-8', output_encoding=u'utf-8').render(**variables) elif ext == u'.css': mimetype = u'text/css' elif ext == u'.js': @@ -343,9 +368,12 @@ class HttpConnection(object): mimetype = u'text/plain' file_handle = None try: - file_handle = open(path, u'rb') - log.debug(u'Opened %s' % path) - content = file_handle.read() + if html: + content = html + else: + file_handle = open(path, u'rb') + log.debug(u'Opened %s' % path) + content = file_handle.read() except IOError: log.exception(u'Failed to open %s' % path) return HttpResponse(code=u'404 Not Found') From 9f7a96c31514b9dc31c6d766c95b611e3d321c6a Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Tue, 31 May 2011 13:25:35 +0200 Subject: [PATCH 91/97] Fixed up some missing translations. --- openlp/plugins/remotes/html/stage.html | 3 ++- openlp/plugins/remotes/html/stage.js | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/openlp/plugins/remotes/html/stage.html b/openlp/plugins/remotes/html/stage.html index c002ea68b..c5d0872d0 100644 --- a/openlp/plugins/remotes/html/stage.html +++ b/openlp/plugins/remotes/html/stage.html @@ -27,12 +27,13 @@ --> - OpenLP 2.0 Stage View + ${stage_title} +