refactoring

This commit is contained in:
frankknoll
2022-12-14 22:13:59 +01:00
parent 88996c7ada
commit eab69db9fd
2 changed files with 15 additions and 20 deletions

View File

@@ -34,7 +34,7 @@
"from Datawrapper import Datawrapper\n",
"from MedianOfFreeBedsByKreisTableFactory import MedianOfFreeBedsByKreisTableFactory\n",
"from TimeseriesReader import readTimeseries\n",
"from IntensivstationenHtmlFileUpdater import saveKreisOptions\n",
"from IntensivstationenHtmlFileUpdater import saveLastUpdatedIntensivstationen, saveKreisOptions\n",
"\n",
"pd.set_option('display.max_rows', 100)\n",
"pd.set_option('display.max_columns', None)\n",
@@ -65,23 +65,6 @@
"print('needsUpdate:', needsUpdate)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "af101279",
"metadata": {},
"outputs": [],
"source": [
"def saveLastUpdatedIntensivstationen(lastUpdated):\n",
" def setLastUpdated(soup):\n",
" soup.find(id = \"Datenstand\").string.replace_with(lastUpdated.strftime(DateProvider.INTENSIVSTATIONEN_DATE_FORMAT))\n",
" return soup\n",
"\n",
" HtmlTransformerUtil().applySoupTransformerToFile(\n",
" file = \"../../docs/intensivstationen.html\",\n",
" soupTransformer = setLastUpdated)"
]
},
{
"cell_type": "code",
"execution_count": null,
@@ -89,7 +72,7 @@
"metadata": {},
"outputs": [],
"source": [
"saveLastUpdatedIntensivstationen(dateProvider.getLastUpdatedDataSource())"
"saveLastUpdatedIntensivstationen(dateProvider.getLastUpdatedDataSource(), toHtmlFile = \"../../docs/intensivstationen.html\")"
]
},
{
@@ -194,7 +177,7 @@
"metadata": {},
"outputs": [],
"source": [
"saveKreisOptions(kreisOptions, toHtmlFile=\"../../docs/intensivstationen.html\")"
"saveKreisOptions(kreisOptions, toHtmlFile = \"../../docs/intensivstationen.html\")"
]
},
{

View File

@@ -1,6 +1,18 @@
from bs4 import BeautifulSoup
from HtmlTransformerUtil import HtmlTransformerUtil
from DateProvider import DateProvider
from KreisOptionsSetter import KreisOptionsSetter
from HtmlTransformerUtil import HtmlTransformerUtil
def saveLastUpdatedIntensivstationen(lastUpdated, toHtmlFile):
def setLastUpdated(soup):
soup.find(id = "Datenstand").string.replace_with(lastUpdated.strftime(DateProvider.INTENSIVSTATIONEN_DATE_FORMAT))
return soup
HtmlTransformerUtil().applySoupTransformerToFile(
file = toHtmlFile,
soupTransformer = setLastUpdated)
def saveKreisOptions(kreisOptions, toHtmlFile):