forked from openlp/openlp
PEP fixes
This commit is contained in:
parent
2d9db0a0bd
commit
1abcff7519
@ -67,6 +67,7 @@ class BibleImport(BibleDB):
|
|||||||
"""
|
"""
|
||||||
Parse and clean the supplied file by removing any elements or tags we don't use.
|
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 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 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.
|
:param tags: A tuple of element names (Str) to remove, preserving their content.
|
||||||
:return: The root element of the xml document
|
:return: The root element of the xml document
|
||||||
|
@ -23,10 +23,10 @@
|
|||||||
import logging
|
import logging
|
||||||
from lxml import etree
|
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.core.lib.ui import critical_error_message_box
|
||||||
from openlp.plugins.bibles.lib.bibleimport import BibleImport
|
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__)
|
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}cell',
|
||||||
'{http://www.bibletechnologies.net/2003/OSIS/namespace}caption')
|
'{http://www.bibletechnologies.net/2003/OSIS/namespace}caption')
|
||||||
|
|
||||||
|
|
||||||
def replacement(match):
|
def replacement(match):
|
||||||
return match.group(2).upper()
|
return match.group(2).upper()
|
||||||
|
|
||||||
@ -103,8 +104,6 @@ class OSISBible(BibleImport):
|
|||||||
if not language_id:
|
if not language_id:
|
||||||
return False
|
return False
|
||||||
num_books = int(osis_bible_tree.xpath("count(//ns:div[@type='book'])", namespaces=namespace))
|
num_books = int(osis_bible_tree.xpath("count(//ns:div[@type='book'])", namespaces=namespace))
|
||||||
|
|
||||||
|
|
||||||
# Precompile a few xpath-querys
|
# Precompile a few xpath-querys
|
||||||
verse_in_chapter = etree.XPath('count(//ns:chapter[1]/ns:verse)', namespaces=namespace)
|
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)
|
text_in_verse = etree.XPath('count(//ns:verse[1]/text())', namespaces=namespace)
|
||||||
|
@ -56,7 +56,6 @@ class TestBibleImport(TestCase):
|
|||||||
self.mock_log = self.log_patcher.start()
|
self.mock_log = self.log_patcher.start()
|
||||||
self.setup_patcher.start()
|
self.setup_patcher.start()
|
||||||
|
|
||||||
|
|
||||||
def get_language_id_language_found_test(self):
|
def get_language_id_language_found_test(self):
|
||||||
"""
|
"""
|
||||||
Test get_language_id() when called with a name found in the languages list
|
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
|
# GIVEN: A mocked languages.get_language which returns None a mocked BibleDB.get_language which returns a
|
||||||
# language id.
|
# language id.
|
||||||
with patch('openlp.core.common.languages.get_language',
|
with patch('openlp.core.common.languages.get_language', return_value=None) as mocked_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:
|
||||||
patch('openlp.plugins.bibles.lib.db.BibleDB.get_language',
|
|
||||||
return_value=40) as mocked_db_get_language:
|
|
||||||
self.mock_log.error.reset_mock()
|
self.mock_log.error.reset_mock()
|
||||||
instance = BibleImport(MagicMock())
|
instance = BibleImport(MagicMock())
|
||||||
instance.save_meta = MagicMock()
|
instance.save_meta = MagicMock()
|
||||||
|
Loading…
Reference in New Issue
Block a user