refactoring

This commit is contained in:
frankknoll
2022-11-22 15:51:53 +01:00
parent 8d1f38dfb6
commit 447c2ed552
5 changed files with 60 additions and 95 deletions

View File

@@ -2,6 +2,17 @@ from bs4 import BeautifulSoup
from HtmlTransformerUtil import HtmlTransformerUtil
from CountryOptionsSetter import CountryOptionsSetter
from DateProvider import DateProvider
from HtmlUtils import getCountryOptions, getCountries
from DateProvider import DateProvider
from BatchCodeTablePersister import createAndSaveBatchCodeTables
def updateBatchCodeTableHtmlFile(internationalVaersCovid19):
countryOptions = getCountryOptions(getCountries(internationalVaersCovid19))
saveCountryOptions(countryOptions)
saveLastUpdatedBatchCodeTable(DateProvider().getLastUpdatedDataSource())
createAndSaveBatchCodeTables(internationalVaersCovid19, minADRsForLethality=100)
def saveCountryOptions(countryOptions):
HtmlTransformerUtil().applySoupTransformerToFile(
@@ -12,6 +23,7 @@ def saveCountryOptions(countryOptions):
CountryOptionsSetter().setCountryOptions(html = str(soup), options = countryOptions),
'lxml'))
def saveLastUpdatedBatchCodeTable(lastUpdated):
def setLastUpdated(soup):
soup.find(id = "last_updated").string.replace_with(lastUpdated.strftime(DateProvider.DATE_FORMAT))
@@ -19,4 +31,5 @@ def saveLastUpdatedBatchCodeTable(lastUpdated):
HtmlTransformerUtil().applySoupTransformerToFile(
file = "../docs/batchCodeTable.html",
soupTransformer = setLastUpdated)
soupTransformer = setLastUpdated)