From c226979f2434c2b14e43021688dbde3fd7e4abe4 Mon Sep 17 00:00:00 2001 From: M2j Date: Fri, 17 Dec 2010 23:10:29 +0100 Subject: [PATCH] Format fixes, comment fixes and biblegateway.csv updated --- .../plugins/bibles/forms/bibleimportform.py | 19 +-- openlp/plugins/bibles/lib/__init__.py | 22 +-- openlp/plugins/bibles/lib/http.py | 8 +- openlp/plugins/bibles/lib/manager.py | 2 +- openlp/plugins/bibles/lib/mediaitem.py | 1 - .../plugins/bibles/resources/biblegateway.csv | 157 +++++++++--------- .../plugins/bibles/resources/bibleserver.csv | 4 +- .../bibles/resources/crosswalkbooks.csv | 2 +- 8 files changed, 105 insertions(+), 110 deletions(-) diff --git a/openlp/plugins/bibles/forms/bibleimportform.py b/openlp/plugins/bibles/forms/bibleimportform.py index 67c292c5c..a454404d9 100644 --- a/openlp/plugins/bibles/forms/bibleimportform.py +++ b/openlp/plugins/bibles/forms/bibleimportform.py @@ -339,31 +339,27 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): """ Load the list of Crosswalk and BibleGateway bibles. """ - # Load and store Crosswalk Bibles. + # Load Crosswalk Bibles. filepath = AppLocation.get_directory(AppLocation.PluginsDir) filepath = os.path.join(filepath, u'bibles', u'resources') books_file = None try: self.web_bible_list[WebDownload.Crosswalk] = {} books_file = open( - os.path.join(filepath, u'crosswalkbooks.csv'), 'r') + os.path.join(filepath, u'crosswalkbooks.csv'), '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 = line[0] - name = line[1] - if not isinstance(ver, unicode): - ver = unicode(ver, u'utf8') - if not isinstance(name, unicode): - name = unicode(name, u'utf8') + ver = unicode(line[0], u'utf-8') + name = unicode(line[1], u'utf-8') self.web_bible_list[WebDownload.Crosswalk][ver] = name.strip() except IOError: log.exception(u'Crosswalk resources missing') finally: if books_file: books_file.close() - # Load and store BibleGateway Bibles. + # Load BibleGateway Bibles. books_file = None try: self.web_bible_list[WebDownload.BibleGateway] = {} @@ -385,8 +381,7 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): finally: if books_file: books_file.close() - - # Load and store Bibleserver Bibles. + # Load and Bibleserver Bibles. filepath = AppLocation.get_directory(AppLocation.PluginsDir) filepath = os.path.join(filepath, u'bibles', u'resources') books_file = None @@ -402,7 +397,7 @@ class BibleImportForm(QtGui.QWizard, Ui_BibleImportWizard): name = unicode(line[1], u'utf-8') self.web_bible_list[WebDownload.Bibleserver][ver] = name.strip() except IOError, UnicodeError: - log.exception(u'Bibelserver resources could not be imported') + log.exception(u'Bibelserver resources missing') finally: if books_file: books_file.close() diff --git a/openlp/plugins/bibles/lib/__init__.py b/openlp/plugins/bibles/lib/__init__.py index 7a35508fc..6cb33bcce 100644 --- a/openlp/plugins/bibles/lib/__init__.py +++ b/openlp/plugins/bibles/lib/__init__.py @@ -46,18 +46,18 @@ def get_reference_match(match_type): # verse range match: (:)?(-(:)??)? range_string = str(r'(?:(?P[0-9]+)%(sep_v)s)?(?P' r'[0-9]+)(?P%(sep_r)s(?:(?:(?P[0-9]+)%(sep_v)s)?' - r'(?P[0-9]+)|%(sep_e)s)?)?' % separators) + r'(?P[0-9]+)|%(sep_e)s)?)?') % separators if match_type == u'range': return re.compile(r'^\s*' + range_string + r'\s*$', re.UNICODE) elif match_type == u'range_separator': return re.compile(separators[u'sep_l']) elif match_type == u'full': - # full reference match: ((,|(?=$)))+ - return re.compile(str(r'^\s*(?!\s)(?P[\d]*[^\d]+)(?((,|(?=$)))+ + return re.compile(str(r'^\s*(?!\s)(?P[\d]*[^\d]+)(?(?:' + range_string + r'(?:%(sep_l)s|(?=\s*$)))+)\s*$') % separators, re.UNICODE) else: - return separators[match_type] + return separators[match_type] def parse_reference(reference): """ @@ -69,9 +69,9 @@ def parse_reference(reference): - Each reference starts with the book name. A chapter name is manditory. ``John 3`` refers to Gospel of John chapter 3 - - A reference range can be given after a range seperator. + - A reference range can be given after a range separator. ``John 3-5`` refers to John chapters 3 to 5 - - Single verses can be addressed after a verse seperator + - Single verses can be addressed after a verse separator ``John 3:16`` refers to John chapter 3 verse 16 ``John 3:16-4:3`` refers to John chapter 3 verse 16 to chapter 4 verse 3 - After a verse reference all further single values are treat as verse in @@ -82,7 +82,7 @@ def parse_reference(reference): number of verse references. It is not possible to refer to verses in additional books. ``John 3:16,18`` refers to John chapter 3 verses 16 and 18 - ``John 3:16-18,20`` refers to John chapter 3 verses 16 to 18 to 20 + ``John 3:16-18,20`` refers to John chapter 3 verses 16 to 18 and 20 ``John 3:16-18,4:1`` refers to John chapter 3 verses 16 to 18 and chapter 3 verse 1 - If there is a range separator without further verse declaration the last @@ -97,11 +97,11 @@ def parse_reference(reference): 2. ``(?P[0-9]+)`` The verse reference ``from_verse`` is manditory 3. ``(?P%(sep_r)s(?:`` ... ``|%(sep_e)s)?)?`` - A ``range_to`` declaration is optional. It starts with a range seperator + A ``range_to`` declaration is optional. It starts with a range separator and contains optional a chapter and verse declaration or a end separator. 4. ``(?:(?P[0-9]+)%(sep_v)s)?`` - The ``to_chapter`` reference with seperator is equivalent to group 1. + The ``to_chapter`` reference with separator is equivalent to group 1. 5. ``(?P[0-9]+)`` The ``to_verse`` reference is equivalent to group 2. @@ -126,7 +126,6 @@ def parse_reference(reference): Returns None or a reference list. """ - log.debug('parse_reference("%s")', reference) match = get_reference_match(u'full').match(reference) if match: @@ -135,7 +134,7 @@ def parse_reference(reference): ranges = match.group(u'ranges') range_list = get_reference_match(u'range_separator').split(ranges) ref_list = [] - chapter = 0 + chapter = None for this_range in range_list: range_match = get_reference_match(u'range').match(this_range) from_chapter = range_match.group(u'from_chapter') @@ -169,6 +168,7 @@ def parse_reference(reference): to_chapter = chapter else: to_chapter = to_verse + to_verse = None # Append references to the list if has_range: if not from_verse: diff --git a/openlp/plugins/bibles/lib/http.py b/openlp/plugins/bibles/lib/http.py index bd24b3f46..218f7212e 100644 --- a/openlp/plugins/bibles/lib/http.py +++ b/openlp/plugins/bibles/lib/http.py @@ -250,13 +250,13 @@ class BSExtract(object): def get_bible_chapter(self, version, bookname, chapter): """ - Access and decode bibles via http://m.Bibleserver.com + Access and decode bibles via Bibleserver mobile website ``version`` The version of the bible like NIV for New International Version ``bookname`` - Text name of in english e.g. 'gen' for Genesis + Text name of bible book e.g. Genesis, 1. John, 1John or Offenbarung ``chapter`` Chapter number @@ -291,11 +291,11 @@ class BSExtract(object): finally: if not content: return None - verse_number = re.compile(r'v\d{5}(\d{3}) verse') + verse_number = re.compile(r'v(\d{2})(\d{3})(\d{3}) verse') verses = {} for verse in content: Receiver.send_message(u'openlp_process_events') - versenumber = int(verse_number.sub(r'\1', verse[u'class'])) + versenumber = int(verse_number.sub(r'\3', verse[u'class'])) verses[versenumber] = verse.contents[1].rstrip(u'\n') return SearchResults(bookname, chapter, verses) diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 39d8b644c..93f301713 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -312,7 +312,7 @@ class BibleManager(object): 'Scripture Reference Error'), translate('BiblesPlugin.BibleManager', 'You did not enter a ' 'search keyword.\nYou can separate different keywords by a ' - 'space to search for all of your keywords and you can seperate ' + 'space to search for all of your keywords and you can separate ' 'them by a comma to search for one of them.')) return None diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index cced544b9..c206bd309 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -906,7 +906,6 @@ class BibleMediaItem(MediaManagerItem): ``verse`` The verse number (int). """ - verse_separator = get_reference_match(u'sep_v_display') if not self.parent.settings_tab.show_new_chapters or \ old_chapter != chapter: diff --git a/openlp/plugins/bibles/resources/biblegateway.csv b/openlp/plugins/bibles/resources/biblegateway.csv index 14f167897..ad8052704 100644 --- a/openlp/plugins/bibles/resources/biblegateway.csv +++ b/openlp/plugins/bibles/resources/biblegateway.csv @@ -1,80 +1,81 @@ +João Ferreira de Almeida Atualizada,AA +التفسير التطبيقى للكتاب المقدس,ALAB +Shqip,ALB +Amplified Bible,AMP Amuzgo de Guerrero,AMU -Arabic Life Application Bible,ALAB -Bulgarian Bible,BULG -1940 Bulgarian Bible,BG1940 -Chinanteco de Comaltepec,CCO -Cakchiquel Occidental,CKW -Haitian Creole Version,HCV -Slovo na cestu,SNC -Dette er Biblen pÃ¥ dansk,DN1933 -Hoffnung für Alle,HOF -Luther Bibel 1545,LUTH1545 -New International Version,NIV -New American Standard Bible,NASB -The Message,MSG -Amplified Bible,AMP -New Living Translation,NLT -King James Version,KJV -English Standard Version,ESV -Contemporary English Version,CEV -New King James Version,NKJV -New Century Version,NCV -21st Century King James Version,KJ21 -American Standard Version,ASV -Young's Literal Translation,YLT -Darby Translation,DARBY -Holman Christian Standard Bible,HCSB -New International Reader's Version,NIRV -Wycliffe New Testament,WYC -Worldwide English (New Testament),WE -New International Version - UK,NIVUK -Today's New International Version,TNIV +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 -Nueva Versión Internacional,NVI -Reina-Valera 1995,RVR1995 -Castilian,CST -Reina-Valera Antigua,RVA -Biblia en Lenguaje Sencillo,BLS -La Biblia de las Américas,LBLA -Louis Segond,LSG -La Bible du Semeur,BDS -1881 Westcott-Hort New Testament,WHNU -1550 Stephanus New Testament,TR1550 -1894 Scrivener New Testament,TR1894 -The Westminster Leningrad Codex,WLC -Hiligaynon Bible,HLGN -Croatian Bible,CRO -Hungarian Károli,KAR -Icelandic Bible,ICELAND -La Nuova Diodati,LND -La Parola è Vita,LM -Jacalteco - Oriental,JAC -Kekchi,KEK -Korean Bible,KOREAN -Maori Bible,MAORI -Macedonian New Testament,MNT -Mam - Central,MVC -Mam de Todos Santos Chuchumatán,MVJ -Reimer 2001,REIMER -Náhuatl de Guerrero,NGU -Het Boek,HTB -Det Norsk Bibelselskap 1930,DNB1930 -Levande Bibeln,LB -O Livro,OL -João Ferreira de Almeida Atualizada,AA -Quiché - Centro Occidental,QUT -Romanian,RMNN -Romanian,TLCR -Russian Synodal Version,RUSV -Slovo Zhizny,SZ -Nádej pre kazdého,NPK -Albanian Bible,ALB -Levande Bibeln,SVL -Svenska 1917,SV1917 -Swahili New Testament,SNT -Ang Salita ng Diyos,SND -Ukrainian Bible,UKR -Uspanteco,USP -1934 Vietnamese Bible,VIET -Chinese Union Version (Simplified),CUVS -Chinese Union Version (Traditional),CUV +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/bibleserver.csv b/openlp/plugins/bibles/resources/bibleserver.csv index d73bf1678..c0d109f97 100644 --- a/openlp/plugins/bibles/resources/bibleserver.csv +++ b/openlp/plugins/bibles/resources/bibleserver.csv @@ -27,7 +27,7 @@ En Levende Bok (NOR), NOR Nádej pre kazdého, NPK Noua traducere în limba românã, NTR Nueva Versión Internacional, NVI -Hebrew OT, OT +הברית הישנה, OT Słowo Życia, POL O Livro, PRT Новый перевод на русский язык, RUS @@ -36,4 +36,4 @@ Schlachter 2000, SLT En Levande Bok (SWE), SVL Today's New International Version, TNIV Türkçe, TR -Vulgata, VUL +Biblia Vulgata, VUL diff --git a/openlp/plugins/bibles/resources/crosswalkbooks.csv b/openlp/plugins/bibles/resources/crosswalkbooks.csv index 0b6de47de..7957bfdc8 100644 --- a/openlp/plugins/bibles/resources/crosswalkbooks.csv +++ b/openlp/plugins/bibles/resources/crosswalkbooks.csv @@ -24,4 +24,4 @@ New International Reader's Version,nrv The Darby Translation,dby The Webster Bible,wbt The Latin Vulgate,vul -Weymouth New Testament,wnt \ No newline at end of file +Weymouth New Testament,wnt