refactoring
This commit is contained in:
@@ -7,16 +7,16 @@ from DateProvider import DateProvider
|
||||
from BatchCodeTablePersister import createAndSaveBatchCodeTables
|
||||
|
||||
|
||||
def updateBatchCodeTableHtmlFile(internationalVaersCovid19):
|
||||
def updateBatchCodeTableHtmlFile(internationalVaersCovid19, batchCodeTableHtmlFile):
|
||||
countryOptions = getCountryOptions(getCountries(internationalVaersCovid19))
|
||||
saveCountryOptions(countryOptions)
|
||||
saveLastUpdatedBatchCodeTable(DateProvider().getLastUpdatedDataSource())
|
||||
_saveCountryOptions(countryOptions, batchCodeTableHtmlFile)
|
||||
_saveLastUpdatedBatchCodeTable(DateProvider().getLastUpdatedDataSource(), batchCodeTableHtmlFile)
|
||||
createAndSaveBatchCodeTables(internationalVaersCovid19, minADRsForLethality=100)
|
||||
|
||||
|
||||
def saveCountryOptions(countryOptions):
|
||||
def _saveCountryOptions(countryOptions, batchCodeTableHtmlFile):
|
||||
HtmlTransformerUtil().applySoupTransformerToFile(
|
||||
file = "../docs/batchCodeTable.html",
|
||||
file = batchCodeTableHtmlFile,
|
||||
soupTransformer =
|
||||
lambda soup:
|
||||
BeautifulSoup(
|
||||
@@ -24,12 +24,12 @@ def saveCountryOptions(countryOptions):
|
||||
'lxml'))
|
||||
|
||||
|
||||
def saveLastUpdatedBatchCodeTable(lastUpdated):
|
||||
def _saveLastUpdatedBatchCodeTable(lastUpdated, batchCodeTableHtmlFile):
|
||||
def setLastUpdated(soup):
|
||||
soup.find(id = "last_updated").string.replace_with(lastUpdated.strftime(DateProvider.DATE_FORMAT))
|
||||
return soup
|
||||
|
||||
HtmlTransformerUtil().applySoupTransformerToFile(
|
||||
file = "../docs/batchCodeTable.html",
|
||||
file = batchCodeTableHtmlFile,
|
||||
soupTransformer = setLastUpdated)
|
||||
|
||||
@@ -10,7 +10,13 @@
|
||||
"import pandas as pd\n",
|
||||
"\n",
|
||||
"pd.set_option('display.max_rows', 100)\n",
|
||||
"pd.set_option('display.max_columns', None)"
|
||||
"pd.set_option('display.max_columns', None)\n",
|
||||
"\n",
|
||||
"from VAERSFileDownloader import updateVAERSFiles\n",
|
||||
"from datetime import datetime\n",
|
||||
"from DateProvider import DateProvider\n",
|
||||
"from InternationalVaersCovid19Provider import getInternationalVaersCovid19\n",
|
||||
"from BatchCodeTableHtmlUpdater import updateBatchCodeTableHtmlFile"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -20,9 +26,7 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from datetime import datetime\n",
|
||||
"\n",
|
||||
"print(datetime.now().strftime(\"%d.%m.%Y, %H:%M:%S Uhr\"))"
|
||||
"print(datetime.now().strftime(\"%d.%m.%Y, %H:%M:%S Uhr\"))\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -32,7 +36,6 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from DateProvider import DateProvider\n",
|
||||
"dateProvider = DateProvider()\n",
|
||||
"print(' lastUpdated:', dateProvider.getLastUpdated())\n",
|
||||
"print('lastUpdatedDataSource:', dateProvider.getLastUpdatedDataSource()) \n",
|
||||
@@ -59,17 +62,7 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"pwd = getWorkingDirectory()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "501f6c7b",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"pwd"
|
||||
"getWorkingDirectory()"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -83,45 +76,11 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "9ccc73b3",
|
||||
"id": "a793dff0",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# FK-TODO: das Modell erst dann laden, wenn es wirklich gebraucht wird\n",
|
||||
"from VAERSFileDownloader import downloadVAERSFileAndUnzip"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "9a9e4d1e",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"if needsUpdate:\n",
|
||||
" workingDirectory = getWorkingDirectory()\n",
|
||||
" downloadVAERSFileAndUnzip('2022VAERSData.zip', workingDirectory)\n",
|
||||
" downloadVAERSFileAndUnzip('NonDomesticVAERSData.zip', workingDirectory)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "2f0f9b4b",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from BatchCodeTableHtmlUpdater import updateBatchCodeTableHtmlFile"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "62132e68",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from InternationalVaersCovid19Provider import getInternationalVaersCovid19"
|
||||
"updateVAERSFiles(needsUpdate, getWorkingDirectory())"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -142,7 +101,7 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"updateBatchCodeTableHtmlFile(internationalVaersCovid19)"
|
||||
"updateBatchCodeTableHtmlFile(internationalVaersCovid19, batchCodeTableHtmlFile=\"../docs/batchCodeTable.html\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@@ -55,3 +55,8 @@ def downloadVAERSFileAndUnzip(file, workingDirectory):
|
||||
unzipAndRemove(
|
||||
zipFile = downloadedFile,
|
||||
dstDir = workingDirectory + '/VAERS/')
|
||||
|
||||
def updateVAERSFiles(needsUpdate, workingDirectory):
|
||||
if needsUpdate:
|
||||
downloadVAERSFileAndUnzip('2022VAERSData.zip', workingDirectory)
|
||||
downloadVAERSFileAndUnzip('NonDomesticVAERSData.zip', workingDirectory)
|
||||
Reference in New Issue
Block a user