refactoring

This commit is contained in:
frankknoll
2022-03-08 11:51:19 +01:00
parent b9b448411c
commit de17ea4acb

View File

@@ -38,10 +38,10 @@
"from time import sleep\n",
"from selenium import webdriver\n",
"\n",
"INTENSIVSTATIONEN_DATE_FORMAT = \"%d.%m.%Y, %H:%M Uhr\"\n",
"\n",
"class DateProvider:\n",
" \n",
" INTENSIVSTATIONEN_DATE_FORMAT = \"%d.%m.%Y, %H:%M Uhr\"\n",
"\n",
" def __init__(self):\n",
" self.lastUpdatedIntensivstationen = None\n",
" self.lastUpdatedOriginal = None\n",
@@ -54,7 +54,7 @@
" htmlContent = requests.get(\"https://knollfrank.github.io/HowBadIsMyBatch/intensivstationen.html\").text\n",
" soup = BeautifulSoup(htmlContent, \"lxml\")\n",
" dateStr = soup.find(id = \"Datenstand\").text\n",
" self.lastUpdatedIntensivstationen = datetime.strptime(dateStr, INTENSIVSTATIONEN_DATE_FORMAT)\n",
" self.lastUpdatedIntensivstationen = datetime.strptime(dateStr, DateProvider.INTENSIVSTATIONEN_DATE_FORMAT)\n",
" \n",
" return self.lastUpdatedIntensivstationen\n",
"\n",
@@ -110,7 +110,7 @@
" with open(file) as fp:\n",
" soup = BeautifulSoup(fp, 'lxml')\n",
"\n",
" soup.find(id = \"Datenstand\").string.replace_with(lastUpdated.strftime(INTENSIVSTATIONEN_DATE_FORMAT))\n",
" soup.find(id = \"Datenstand\").string.replace_with(lastUpdated.strftime(DateProvider.INTENSIVSTATIONEN_DATE_FORMAT))\n",
"\n",
" with open(file, \"w\") as fp:\n",
" fp.write(str(soup))"