refactoring
This commit is contained in:
@@ -4,32 +4,33 @@ from CountryOptionsSetter import CountryOptionsSetter
|
||||
from DateProvider import DateProvider
|
||||
from HtmlUtils import getCountryOptions, getCountries
|
||||
from DateProvider import DateProvider
|
||||
from BatchCodeTablePersister import createAndSaveBatchCodeTables
|
||||
|
||||
|
||||
def updateBatchCodeTableHtmlFile(internationalVaersCovid19, batchCodeTableHtmlFile):
|
||||
countryOptions = getCountryOptions(getCountries(internationalVaersCovid19))
|
||||
_saveCountryOptions(countryOptions, batchCodeTableHtmlFile)
|
||||
_saveLastUpdatedBatchCodeTable(DateProvider().getLastUpdatedDataSource(), batchCodeTableHtmlFile)
|
||||
createAndSaveBatchCodeTables(internationalVaersCovid19, minADRsForLethality=100)
|
||||
_saveLastUpdatedBatchCodeTable(
|
||||
DateProvider().getLastUpdatedDataSource(),
|
||||
batchCodeTableHtmlFile)
|
||||
|
||||
|
||||
def _saveCountryOptions(countryOptions, batchCodeTableHtmlFile):
|
||||
HtmlTransformerUtil().applySoupTransformerToFile(
|
||||
file = batchCodeTableHtmlFile,
|
||||
soupTransformer =
|
||||
lambda soup:
|
||||
file=batchCodeTableHtmlFile,
|
||||
soupTransformer=lambda soup:
|
||||
BeautifulSoup(
|
||||
CountryOptionsSetter().setCountryOptions(html = str(soup), options = countryOptions),
|
||||
CountryOptionsSetter().setCountryOptions(
|
||||
html=str(soup),
|
||||
options=countryOptions),
|
||||
'lxml'))
|
||||
|
||||
|
||||
def _saveLastUpdatedBatchCodeTable(lastUpdated, batchCodeTableHtmlFile):
|
||||
def setLastUpdated(soup):
|
||||
soup.find(id = "last_updated").string.replace_with(lastUpdated.strftime(DateProvider.DATE_FORMAT))
|
||||
soup.find(id="last_updated").string.replace_with(
|
||||
lastUpdated.strftime(DateProvider.DATE_FORMAT))
|
||||
return soup
|
||||
|
||||
HtmlTransformerUtil().applySoupTransformerToFile(
|
||||
file = batchCodeTableHtmlFile,
|
||||
soupTransformer = setLastUpdated)
|
||||
|
||||
file=batchCodeTableHtmlFile,
|
||||
soupTransformer=setLastUpdated)
|
||||
|
||||
@@ -7,8 +7,7 @@ from HtmlUtils import getCountries
|
||||
def createAndSaveBatchCodeTables(internationalVaersCovid19, minADRsForLethality):
|
||||
batchCodeTableFactory = BatchCodeTableFactory(internationalVaersCovid19)
|
||||
_createAndSaveBatchCodeTablesForCountries(
|
||||
createBatchCodeTableForCountry=lambda country: batchCodeTableFactory.createBatchCodeTableByCountry(
|
||||
country),
|
||||
createBatchCodeTableForCountry=lambda country: batchCodeTableFactory.createBatchCodeTableByCountry(country),
|
||||
countries=getCountries(internationalVaersCovid19),
|
||||
minADRsForLethality=minADRsForLethality)
|
||||
_createAndSaveBatchCodeTableForCountry(
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
"from datetime import datetime\n",
|
||||
"from DateProvider import DateProvider\n",
|
||||
"from InternationalVaersCovid19Provider import getInternationalVaersCovid19\n",
|
||||
"from BatchCodeTableHtmlUpdater import updateBatchCodeTableHtmlFile"
|
||||
"from BatchCodeTableHtmlUpdater import updateBatchCodeTableHtmlFile\n",
|
||||
"from BatchCodeTablePersister import createAndSaveBatchCodeTables"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -78,6 +79,16 @@
|
||||
"updateBatchCodeTableHtmlFile(internationalVaersCovid19, batchCodeTableHtmlFile=\"../docs/batchCodeTable.html\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "0915aa5a",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"createAndSaveBatchCodeTables(internationalVaersCovid19, minADRsForLethality=100)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
|
||||
Reference in New Issue
Block a user