diff --git a/src/BatchCodeTableHtmlUpdater.py b/src/BatchCodeTableHtmlUpdater.py index d96f25b6293..8c9233b50ec 100644 --- a/src/BatchCodeTableHtmlUpdater.py +++ b/src/BatchCodeTableHtmlUpdater.py @@ -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) \ No newline at end of file diff --git a/src/HowBadIsMyBatch.ipynb b/src/HowBadIsMyBatch.ipynb index 6394bbdb54c..13bfc0a8733 100644 --- a/src/HowBadIsMyBatch.ipynb +++ b/src/HowBadIsMyBatch.ipynb @@ -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\")" ] }, { diff --git a/src/VAERSFileDownloader.py b/src/VAERSFileDownloader.py index fb512fd4003..55d9edc4567 100644 --- a/src/VAERSFileDownloader.py +++ b/src/VAERSFileDownloader.py @@ -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) \ No newline at end of file