From 1abcff75190cccd8284114ffe8f875129ad60e14 Mon Sep 17 00:00:00 2001 From: Philip Ridout Date: Sun, 7 Aug 2016 12:20:53 +0100 Subject: [PATCH] PEP fixes --- openlp/plugins/bibles/lib/bibleimport.py | 1 + openlp/plugins/bibles/lib/osis.py | 7 +++---- .../functional/openlp_plugins/bibles/test_bibleimport.py | 9 +++------ 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/openlp/plugins/bibles/lib/bibleimport.py b/openlp/plugins/bibles/lib/bibleimport.py index 58669ed59..faf6f6587 100644 --- a/openlp/plugins/bibles/lib/bibleimport.py +++ b/openlp/plugins/bibles/lib/bibleimport.py @@ -67,6 +67,7 @@ class BibleImport(BibleDB): """ Parse and clean the supplied file by removing any elements or tags we don't use. :param filename: The filename of the xml file to parse. Str + :param use_objectify: Use the objectify parser rather than the etree parser. (Bool) :param elements: A tuple of element names (Str) to remove along with their content. :param tags: A tuple of element names (Str) to remove, preserving their content. :return: The root element of the xml document diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index 219abf3b2..dfecfdeec 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -23,10 +23,10 @@ import logging from lxml import etree -from openlp.core.common import languages, translate, trace_error_handler +from openlp.core.common import translate, trace_error_handler from openlp.core.lib.ui import critical_error_message_box from openlp.plugins.bibles.lib.bibleimport import BibleImport -from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB +from openlp.plugins.bibles.lib.db import BiblesResourcesDB log = logging.getLogger(__name__) @@ -69,6 +69,7 @@ REMOVABLE_TAGS = ('{http://www.bibletechnologies.net/2003/OSIS/namespace}p', '{http://www.bibletechnologies.net/2003/OSIS/namespace}cell', '{http://www.bibletechnologies.net/2003/OSIS/namespace}caption') + def replacement(match): return match.group(2).upper() @@ -103,8 +104,6 @@ class OSISBible(BibleImport): if not language_id: return False num_books = int(osis_bible_tree.xpath("count(//ns:div[@type='book'])", namespaces=namespace)) - - # Precompile a few xpath-querys verse_in_chapter = etree.XPath('count(//ns:chapter[1]/ns:verse)', namespaces=namespace) text_in_verse = etree.XPath('count(//ns:verse[1]/text())', namespaces=namespace) diff --git a/tests/functional/openlp_plugins/bibles/test_bibleimport.py b/tests/functional/openlp_plugins/bibles/test_bibleimport.py index 1a8a2ad17..e2076df55 100644 --- a/tests/functional/openlp_plugins/bibles/test_bibleimport.py +++ b/tests/functional/openlp_plugins/bibles/test_bibleimport.py @@ -56,7 +56,6 @@ class TestBibleImport(TestCase): self.mock_log = self.log_patcher.start() self.setup_patcher.start() - def get_language_id_language_found_test(self): """ Test get_language_id() when called with a name found in the languages list @@ -103,10 +102,8 @@ class TestBibleImport(TestCase): """ # GIVEN: A mocked languages.get_language which returns None a mocked BibleDB.get_language which returns a # language id. - with patch('openlp.core.common.languages.get_language', - return_value=None) as mocked_languages_get_language, \ - patch('openlp.plugins.bibles.lib.db.BibleDB.get_language', - return_value=40) as mocked_db_get_language: + with patch('openlp.core.common.languages.get_language', return_value=None) as mocked_languages_get_language, \ + patch('openlp.plugins.bibles.lib.db.BibleDB.get_language', return_value=40) as mocked_db_get_language: self.mock_log.error.reset_mock() instance = BibleImport(MagicMock()) instance.save_meta = MagicMock() @@ -128,7 +125,7 @@ class TestBibleImport(TestCase): # GIVEN: A mocked languages.get_language which returns None a mocked BibleDB.get_language which returns a # language id. with patch('openlp.core.common.languages.get_language', return_value=None) as mocked_languages_get_language, \ - patch('openlp.plugins.bibles.lib.db.BibleDB.get_language', return_value=None) as mocked_db_get_language: + patch('openlp.plugins.bibles.lib.db.BibleDB.get_language', return_value=None) as mocked_db_get_language: self.mock_log.error.reset_mock() instance = BibleImport(MagicMock()) instance.save_meta = MagicMock()