Merge branch 'master' into screen-flicker-fix

This commit is contained in:
Mateus Meyer Jiacomelli 2022-11-21 11:59:24 -03:00
commit 58a07e5058
3 changed files with 283 additions and 1 deletions

View File

@ -116,7 +116,11 @@ class WordProjectBible(BibleImport):
header_div = soup.find('div', 'textHeader')
chapters_p = header_div.find('p')
if not chapters_p:
chapters_p = soup.p
log.debug('Corrupted header, searching for span instead of a p')
chapters_p = header_div.find('span')
if not chapters_p:
log.debug('Cannot find chapters, using all p instead')
chapters_p = soup.p
log.debug(chapters_p)
for item in chapters_p.contents:
if self.stop_import_flag:

View File

@ -31,6 +31,7 @@ from tests.utils.constants import RESOURCE_PATH
TEST_PATH = RESOURCE_PATH / 'bibles'
INDEX_PAGE = (TEST_PATH / 'wordproject_index.htm').read_bytes().decode()
CHAPTER_PAGE = (TEST_PATH / 'wordproject_chapter.htm').read_bytes().decode()
CORRUPTED_CHAPTER_PAGE = (TEST_PATH / 'wordproject_chapter_corrupted.htm').read_bytes().decode()
@patch.object(Path, 'read_text')
@ -91,6 +92,35 @@ def test_process_chapters(mocked_read_text, settings):
assert mocked_process_verses.call_args_list == expected_process_verses_calls
@patch.object(Path, 'read_text')
def test_process_chapters_corrupted_header(mocked_read_text, settings):
"""
Test the process_chapters() method when there's a "corrupted" header with a span instead of a p
"""
# GIVEN: A WordProject importer and a bunch of mocked things
importer = WordProjectBible(MagicMock(), path='.', name='.', file_path=Path('kj.zip'))
importer.base_path = Path()
importer.stop_import_flag = False
importer.language_id = 'en'
mocked_read_text.return_value = CORRUPTED_CHAPTER_PAGE
mocked_db_book = MagicMock()
mocked_db_book.name = 'Genesis'
book_id = 1
book_link = '01/1.htm'
# WHEN: process_chapters() is called
with patch.object(importer, 'set_current_chapter') as mocked_set_current_chapter, \
patch.object(importer, 'process_verses') as mocked_process_verses:
importer.process_chapters(mocked_db_book, book_id, book_link)
# THEN: The right methods should have been called
expected_set_current_chapter_calls = [call('Genesis', ch) for ch in range(1, 51)]
expected_process_verses_calls = [call(mocked_db_book, 1, ch) for ch in range(1, 51)]
mocked_read_text.assert_called_once_with(encoding='utf-8', errors='ignore')
assert mocked_set_current_chapter.call_args_list == expected_set_current_chapter_calls
assert mocked_process_verses.call_args_list == expected_process_verses_calls
@patch.object(Path, 'read_text')
def test_process_verses(mocked_read_text, settings):
"""

View File

@ -0,0 +1,248 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Creation of the world, Genesis Chapter 1</title>
<meta name="description" content="Creation of the world, Genesis Chapter 1" />
<meta name="keywords" content="Holy Bible, Old Testament, scriptures, Creation, faith, heaven, hell, God, Jesus" />
<!-- Mobile viewport optimisation -->
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="../_assets/css/css.css" />
<link rel="stylesheet" type="text/css" href="../_assets/css/style.css" />
<link rel="stylesheet" type="text/css" href="../_assets/css/page-player.css" />
<!--[if lte IE 7]>
<link href="../_assets/css/iehacks.css" rel="stylesheet" type="text/css" />
<![endif]-->
<!-- google analytics -->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-39700598-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- google analytics -->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-39700598-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<a name="mytop"></a>
<body>
<header class="ym-noprint">
<div class="ym-wrapper">
<div class="ym-wbox">
<h1><strong>Word</strong><em>Project</em></h1>
</div>
</div>
</header>
<!--lang nav-->
<!--nav id="nav">
<div class="ym-wrapper">
<div class="ym-hlist">
<ul>
<li><a title="Home" href="../../../index.htm" target="_top">Home</a></li>
<li class="active"><a title="Bibles" href="../../../bibles/index.htm" target="_self">Bibles</a></li>
<li><a title="Audio Bible" href="../../../bibles/audio/01_english/b01.htm" target="_top">Audio</a></li>
<li><a title="Selected Bible Verses" href="../../../bibles/verses/english/index.htm" target="_top">Verses</a></li>
<li><a title="Parallel Bibles" href="../../../bibles/parallel/index.htm" target="_top">Multi</a></li>
<li><a title="Resourcces" href="../../../bibles/resources/index.htm" target="_top">Resources</a></li>
<li><a title="Search" href="../../../bibles/search/index.htm" target="_top">Search</a></li>
<li><a title="Download this Bible [language]" href="../../../download/bibles/index.htm" target="_top">Download</a></li>
</ul>
</div>
</div>
</nav-->
<div class="ym-wrapper ym-noprint">
<div class="ym-wbox">
<!--share buttons-->
<div style="margin: 10px 1px 5px 20px;" align="right">
<!-- Facebook -->
<a title="Click to share on Facebook" href="http://www.facebook.com/sharer.php?u=http://wordproject.org/bibles/kj/01/1.htm" target="_blank"><img src="../_assets/img/facebook_2.png" alt="facebook" /></a>
<!-- Twitter -->
<a title="Click to share on Twitter" href="http://twitter.com/share?url=http://wordproject.org/bibles/kj/01/1.htm&text=Read this page &hashtags=wordproject" target="_blank"><img src="../_assets/img/twitter_2.png" alt="twitter" /></a>
<!-- Google+ -->
<a title="Click to share on Google plus" href="https://plus.google.com/share?url=http://wordproject.org/bibles/kj/01/1.htm" target="_blank"><img src="../_assets/img/google+_2.png" alt="google" /></a>
<!-- LinkedIn -->
<a title="Click to share on Linkedin" href="http://www.linkedin.com/shareArticle?mini=true&url=http://www.wordproject.org" target="_blank"><img src="../_assets/img/linkin_2.png" alt="linkin" /></a></p>
</div>
<!--/share buttons-->
<div class=" ym-grid">
<div class="ym-g62 ym-gl breadCrumbs"> <!--a title="Home" href="http://www.wordproject.org/index.htm" target="_top">Home</a> / <a title="Bibles" href="../../index.htm" target="_self">Bibles</a--> / <a href="../index.htm" target="_self">KJV</a></div>
<div class="ym-g38 ym-gr alignRight ym-noprint"><a class="decreaseFont ym-button">-</a><a class="resetFont ym-button">Reset</a><a class="increaseFont ym-button">+</a>
</div>
</div>
</div>
</div>
<div id="main" class="ym-clearfix" role="main">
<div class="ym-wrapper">
<div class="ym-wbox">
<div class="textOptions">
<div class="textHeader">
<h2>Genesis</h2>
<a name="0"></a>
<span class="ym-noprint"> Chapter:
<span class="c1">1</span>
<a href="2.htm#0">2</a>
<a href="3.htm#0">3</a>
<a href="4.htm#0">4</a>
<a href="5.htm#0">5</a>
<a href="6.htm#0">6</a>
<a href="7.htm#0">7</a>
<a href="8.htm#0">8</a>
<a href="9.htm#0">9</a>
<a href="10.htm#0">10</a>
<a href="11.htm#0">11</a>
<a href="12.htm#0">12</a>
<a href="13.htm#0">13</a>
<a href="14.htm#0">14</a>
<a href="15.htm#0">15</a>
<a href="16.htm#0">16</a>
<a href="17.htm#0">17</a>
<a href="18.htm#0">18</a>
<a href="19.htm#0">19</a>
<a href="20.htm#0">20</a>
<a href="21.htm#0">21</a>
<a href="22.htm#0">22</a>
<a href="23.htm#0">23</a>
<a href="24.htm#0">24</a>
<a href="25.htm#0">25</a>
<a href="26.htm#0">26</a>
<a href="27.htm#0">27</a>
<a href="28.htm#0">28</a>
<a href="29.htm#0">29</a>
<a href="30.htm#0">30</a>
<a href="31.htm#0">31</a>
<a href="32.htm#0">32</a>
<a href="33.htm#0">33</a>
<a href="34.htm#0">34</a>
<a href="35.htm#0">35</a>
<a href="36.htm#0">36</a>
<a href="37.htm#0">37</a>
<a href="38.htm#0">38</a>
<a href="39.htm#0">39</a>
<a href="40.htm#0">40</a>
<a href="41.htm#0">41</a>
<a href="42.htm#0">42</a>
<a href="43.htm#0">43</a>
<a href="44.htm#0">44</a>
<a href="45.htm#0">45</a>
<a href="46.htm#0">46</a>
<a href="47.htm#0">47</a>
<a href="48.htm#0">48</a>
<a href="49.htm#0">49</a>
<a href="50.htm#0">50</a>
<!--end of chapters-->
</p>
</div>
<div class="textAudio ym-noprint"><ul class="playlist">
<li class="noMargin">
<!--start audio link--><a href="http://audio2.wordproject.com/bibles/app/audio/1/1/1.mp3">Genesis - Chapter 1 </a></li><!--/audioRef-->
</ul>
</div>
<!--end audio-->
<hr />
<div class="textBody" id="textBody">
<h3>Chapter 1</h3>
<!--... the Word of God:--></a>
<p><span class="verse" id="1">1</span> In the beginning God created the heaven and the earth.
<br /><span class="verse" id="2">2</span> And the earth was without form, and void; and darkness was upon the face of the deep. And the Spirit of God moved upon the face of the waters.
<br /><span class="verse" id="3">3</span> And God said, Let there be light: and there was light.
<br /><span class="verse" id="4">4</span> And God saw the light, that it was good: and God divided the light from the darkness.
<br /><span class="verse" id="5">5</span> And God called the light Day, and the darkness he called Night. And the evening and the morning were the first day.
<br /><span class="verse" id="6">6</span> And God said, Let there be a firmament in the midst of the waters, and let it divide the waters from the waters.
<br /><span class="verse" id="7">7</span> And God made the firmament, and divided the waters which were under the firmament from the waters which were above the firmament: and it was so.
<br /><span class="verse" id="8">8</span> And God called the firmament Heaven. And the evening and the morning were the second day.
<br /><span class="verse" id="9">9</span> And God said, Let the waters under the heaven be gathered together unto one place, and let the dry land appear: and it was so.
<br /><span class="verse" id="10">10</span> And God called the dry land Earth; and the gathering together of the waters called he Seas: and God saw that it was good.
<br /><span class="verse" id="11">11</span> And God said, Let the earth bring forth grass, the herb yielding seed, and the fruit tree yielding fruit after his kind, whose seed is in itself, upon the earth: and it was so.
<br /><span class="verse" id="12">12</span> And the earth brought forth grass, and herb yielding seed after his kind, and the tree yielding fruit, whose seed was in itself, after his kind: and God saw that it was good.
<br /><span class="verse" id="13">13</span> And the evening and the morning were the third day.
<br /><span class="verse" id="14">14</span> And God said, Let there be lights in the firmament of the heaven to divide the day from the night; and let them be for signs, and for seasons, and for days, and years:
<br /><span class="verse" id="15">15</span> And let them be for lights in the firmament of the heaven to give light upon the earth: and it was so.
<br /><span class="verse" id="16">16</span> And God made two great lights; the greater light to rule the day, and the lesser light to rule the night: he made the stars also.
<br /><span class="verse" id="17">17</span> And God set them in the firmament of the heaven to give light upon the earth,
<br /><span class="verse" id="18">18</span> And to rule over the day and over the night, and to divide the light from the darkness: and God saw that it was good.
<br /><span class="verse" id="19">19</span> And the evening and the morning were the fourth day.
<br /><span class="verse" id="20">20</span> And God said, Let the waters bring forth abundantly the moving creature that hath life, and fowl that may fly above the earth in the open firmament of heaven.
<br /><span class="verse" id="21">21</span> And God created great whales, and every living creature that moveth, which the waters brought forth abundantly, after their kind, and every winged fowl after his kind: and God saw that it was good.
<br /><span class="verse" id="22">22</span> And God blessed them, saying, Be fruitful, and multiply, and fill the waters in the seas, and let fowl multiply in the earth.
<br /><span class="verse" id="23">23</span> And the evening and the morning were the fifth day.
<br /><span class="verse" id="24">24</span> And God said, Let the earth bring forth the living creature after his kind, cattle, and creeping thing, and beast of the earth after his kind: and it was so.
<br /><span class="verse" id="25">25</span> And God made the beast of the earth after his kind, and cattle after their kind, and every thing that creepeth upon the earth after his kind: and God saw that it was good.
<br /><span class="verse" id="26">26</span> And God said, Let us make man in our image, after our likeness: and let them have dominion over the fish of the sea, and over the fowl of the air, and over the cattle, and over all the earth, and over every creeping thing that creepeth upon the earth.
<br /><span class="verse" id="27">27</span> So God created man in his own image, in the image of God created he him; male and female created he them.
<br /><span class="verse" id="28">28</span> And God blessed them, and God said unto them, Be fruitful, and multiply, and replenish the earth, and subdue it: and have dominion over the fish of the sea, and over the fowl of the air, and over every living thing that moveth upon the earth.
<br /><span class="verse" id="29">29</span> And God said, Behold, I have given you every herb bearing seed, which is upon the face of all the earth, and every tree, in the which is the fruit of a tree yielding seed; to you it shall be for meat.
<br /><span class="verse" id="30">30</span> And to every beast of the earth, and to every fowl of the air, and to every thing that creepeth upon the earth, wherein there is life, I have given every green herb for meat: and it was so.
<br /><span class="verse" id="31">31</span> And God saw every thing that he had made, and, behold, it was very good. And the evening and the morning were the sixth day.
</p>
<!--... sharper than any twoedged sword... -->
</div>
</div><!-- ym-wbox end -->
</div><!-- ym-wrapper end -->
</div><!-- ym-wrapper end -->
</div><!-- ym-wrapper end -->
<!--..sharper than any twoedged sword...-->
<div class="ym-wrapper">
<div class="ym-wbox">
<div class="alignRight ym-noprint">
<p><a title="Print this page" href="javascript:window.print()" class="ym-button">&nbsp;<img src="../_assets/img/printer.gif" alt="printer" width="25" height="25" align="absbottom" />&nbsp;</a>
<a class="ym-button" title="Page TOP" href="#mytop">&nbsp;<img src="../_assets/img/arrow_up.png" alt="arrowup" width="25" height="25" align="absbottom" />&nbsp;</a>
<!--next chapter start-->
<a class="ym-button" title="Next chapter" href="2.htm#0">&nbsp;<img src="../_assets/img/arrow_right.png" alt="arrowright" align="absbottom" />&nbsp;</a></p>
<!--next chapter end-->
</div>
</div>
</div>
<footer>
<div class="ym-wrapper">
<div class="ym-wbox">
<p class="alignCenter">Wordproject® is a registered name of the <a href="http://www.wordproject.org">International Biblical Association</a>, a non-profit organization registered in Macau, China. </p>
<p class="alignCenter"><a href="http://www.wordproject.org/contact/new/index.htm" target="_top">Contact</a> | <a href="http://www.wordproject.org/contact/new/disclaim.htm" target="_top"> Disclaimer</a> |
<a href="http://www.wordproject.org/contact/new/state.htm" target="_top">Statement of Faith</a> |
<a href="http://www.wordproject.org/contact/new/mstate.htm" target="_top">Mission</a> |
<a href="http://www.wordproject.org/contact/new/copyrights.htm" target="_top">Copyrights</a></p>
</div>
</div>
</footer>
</body>
</script><script type="text/javascript" src="../_assets/js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="../_assets/js/soundmanager2.js"></script>
<script type="text/javascript" src="../_assets/js/page-player.js"></script>
<script type="text/javascript" src="../_assets/js/script.js"></script>
<script type="text/javascript">
soundManager.setup({
url: '../_assets/swf/'
});
</script>
</html>