adding last_updated to VaccineDistributionByZipcode.html

This commit is contained in:
frankknoll
2023-06-16 21:53:07 +02:00
parent 7b0b59da25
commit f268bf28f8
3 changed files with 23 additions and 20 deletions

View File

@@ -5,29 +5,27 @@ from HtmlUtils import getBatchcodeOptions, getBatchcodes
from DateProvider import DateProvider
def updateBatchCodeTableHtmlFile(batchCodeTable, batchCodeTableHtmlFile):
def updateBatchCodeTableHtmlFile(batchCodeTable, batchCodeTableHtmlFile, lastUpdated):
batchcodeOptions = getBatchcodeOptions(getBatchcodes(batchCodeTable.sort_values(by = 'Adverse Reaction Reports', ascending = False)))
_saveBatchcodeOptions(batchcodeOptions, batchCodeTableHtmlFile)
saveLastUpdatedBatchCodeTable(
DateProvider().getLastUpdatedDataSource(),
batchCodeTableHtmlFile)
saveLastUpdated2HtmlFile(lastUpdated, batchCodeTableHtmlFile)
def _saveBatchcodeOptions(batchcodeOptions, batchCodeTableHtmlFile):
HtmlTransformerUtil().applySoupTransformerToFile(
file=batchCodeTableHtmlFile,
soupTransformer=lambda soup:
soupTransformer = lambda soup:
BeautifulSoup(
BatchcodeOptionsSetter().setBatchcodeOptions(
html=str(soup),
options=batchcodeOptions),
'lxml'))
def saveLastUpdatedBatchCodeTable(lastUpdated, batchCodeTableHtmlFile):
def saveLastUpdated2HtmlFile(lastUpdated, htmlFile):
def setLastUpdated(soup):
soup.find(id="last_updated").string.replace_with(
lastUpdated.strftime(DateProvider.DATE_FORMAT))
return soup
HtmlTransformerUtil().applySoupTransformerToFile(
file=batchCodeTableHtmlFile,
soupTransformer=setLastUpdated)
file = htmlFile,
soupTransformer = setLastUpdated)