From 0270d385a222474c540bcdaaa62447580da2e72b Mon Sep 17 00:00:00 2001 From: frankknoll Date: Tue, 10 Oct 2023 10:50:12 +0200 Subject: [PATCH] refactoring --- src/HowBadIsMyBatch.ipynb | 3 ++- src/SymptomsCausedByVaccines/HtmlUpdater.py | 13 +++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/HowBadIsMyBatch.ipynb b/src/HowBadIsMyBatch.ipynb index fb3c5cb6559..b87a97ec1c1 100644 --- a/src/HowBadIsMyBatch.ipynb +++ b/src/HowBadIsMyBatch.ipynb @@ -433,6 +433,7 @@ "outputs": [], "source": [ "from SymptomsCausedByVaccines.HtmlUpdater import updateHtmlFile\n", + "from SymptomsCausedByVaccines.Analyzer import Analyzer\n", "import pandas as pd" ] }, @@ -468,7 +469,7 @@ "outputs": [], "source": [ "updateHtmlFile(\n", - " symptomByVaccine,\n", + " vaccines = Analyzer(symptomByVaccine).getVaccines(),\n", " htmlFile = \"../docs/SymptomsCausedByVaccines/index.html\",\n", " lastUpdated = dateProvider.getLastUpdatedDataSource())" ] diff --git a/src/SymptomsCausedByVaccines/HtmlUpdater.py b/src/SymptomsCausedByVaccines/HtmlUpdater.py index 9028c5c3c2e..0e9cd8ede52 100644 --- a/src/SymptomsCausedByVaccines/HtmlUpdater.py +++ b/src/SymptomsCausedByVaccines/HtmlUpdater.py @@ -1,27 +1,28 @@ from bs4 import BeautifulSoup from HtmlTransformerUtil import HtmlTransformerUtil from DateProvider import DateProvider -from SymptomsCausedByVaccines.Analyzer import Analyzer from SymptomsCausedByVaccines.HtmlUtils import getVaccineOptions from SymptomsCausedByVaccines.OptionsSetter import OptionsSetter -def updateHtmlFile(symptomByVaccine, htmlFile, lastUpdated): - vaccineOptions = getVaccineOptions(Analyzer(symptomByVaccine).getVaccines()) - _saveVaccineOptions(vaccineOptions, htmlFile) +def updateHtmlFile(vaccines, htmlFile, lastUpdated): + _saveVaccineOptions( + vaccineOptions = getVaccineOptions(vaccines), + htmlFile = htmlFile, + vaccineSelectElementId = 'vaccineSelect') saveLastUpdated2HtmlFile( lastUpdated = lastUpdated, htmlFile = htmlFile, lastUpdatedElementId = 'last_updated') -def _saveVaccineOptions(vaccineOptions, htmlFile): +def _saveVaccineOptions(vaccineOptions, htmlFile, vaccineSelectElementId): HtmlTransformerUtil().applySoupTransformerToFile( file=htmlFile, soupTransformer = lambda soup: BeautifulSoup( OptionsSetter().setOptions( html = str(soup), - selectElementId = 'vaccineSelect', + selectElementId = vaccineSelectElementId, options = vaccineOptions), 'lxml'))