refactoring
This commit is contained in:
@@ -2,13 +2,16 @@ from bs4 import BeautifulSoup
|
||||
from HtmlTransformerUtil import HtmlTransformerUtil
|
||||
from BatchcodeOptionsSetter import BatchcodeOptionsSetter
|
||||
from HtmlUtils import getBatchcodeOptions, getBatchcodes
|
||||
from DateProvider import DateProvider
|
||||
from SymptomsCausedByVaccines.HtmlUpdater import saveLastUpdated2HtmlFile
|
||||
|
||||
|
||||
def updateBatchCodeTableHtmlFile(batchCodeTable, batchCodeTableHtmlFile, lastUpdated):
|
||||
batchcodeOptions = getBatchcodeOptions(getBatchcodes(batchCodeTable.sort_values(by = 'Adverse Reaction Reports', ascending = False)))
|
||||
_saveBatchcodeOptions(batchcodeOptions, batchCodeTableHtmlFile)
|
||||
saveLastUpdated2HtmlFile(lastUpdated, batchCodeTableHtmlFile)
|
||||
saveLastUpdated2HtmlFile(
|
||||
lastUpdated = lastUpdated,
|
||||
htmlFile = batchCodeTableHtmlFile,
|
||||
lastUpdatedElementId = 'last_updated')
|
||||
|
||||
def _saveBatchcodeOptions(batchcodeOptions, batchCodeTableHtmlFile):
|
||||
HtmlTransformerUtil().applySoupTransformerToFile(
|
||||
@@ -19,13 +22,3 @@ def _saveBatchcodeOptions(batchcodeOptions, batchCodeTableHtmlFile):
|
||||
html=str(soup),
|
||||
options=batchcodeOptions),
|
||||
'lxml'))
|
||||
|
||||
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 = htmlFile,
|
||||
soupTransformer = setLastUpdated)
|
||||
|
||||
Reference in New Issue
Block a user