PEP fixes

This commit is contained in:
Philip Ridout 2016-08-07 12:20:53 +01:00
parent 2d9db0a0bd
commit 1abcff7519
3 changed files with 7 additions and 10 deletions

View File

@ -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

View File

@ -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)

View File

@ -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()