refactoring
This commit is contained in:
@@ -27,6 +27,7 @@
|
|||||||
"from datetime import datetime\n",
|
"from datetime import datetime\n",
|
||||||
"from HtmlTransformerUtil import HtmlTransformerUtil\n",
|
"from HtmlTransformerUtil import HtmlTransformerUtil\n",
|
||||||
"from ColumnsAdder import ColumnsAdder\n",
|
"from ColumnsAdder import ColumnsAdder\n",
|
||||||
|
"from KreisOptionsSetter import KreisOptionsSetter\n",
|
||||||
"\n",
|
"\n",
|
||||||
"pd.set_option('display.max_rows', 100)\n",
|
"pd.set_option('display.max_rows', 100)\n",
|
||||||
"pd.set_option('display.max_columns', None)\n",
|
"pd.set_option('display.max_columns', None)\n",
|
||||||
@@ -210,36 +211,6 @@
|
|||||||
"kreisOptions = ['<option selected=\"\" value=\"de\">Alle Landkreise</option>'] + getKreisOptions(kreisValues)"
|
"kreisOptions = ['<option selected=\"\" value=\"de\">Alle Landkreise</option>'] + getKreisOptions(kreisValues)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"id": "9eb453d0",
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"from bs4 import BeautifulSoup\n",
|
|
||||||
"\n",
|
|
||||||
"\n",
|
|
||||||
"class KreisOptionsSetter:\n",
|
|
||||||
"\n",
|
|
||||||
" def setKreisOptions(self, html, options):\n",
|
|
||||||
" soup = self._setKreisOptions(self._parse(html), self._parseOptions(options))\n",
|
|
||||||
" return str(soup)\n",
|
|
||||||
"\n",
|
|
||||||
" def _setKreisOptions(self, soup, options):\n",
|
|
||||||
" kreisSelect = soup.find(id = \"kreisSelect\")\n",
|
|
||||||
" kreisSelect.clear()\n",
|
|
||||||
" for option in options:\n",
|
|
||||||
" kreisSelect.append(option)\n",
|
|
||||||
" return soup\n",
|
|
||||||
"\n",
|
|
||||||
" def _parseOptions(self, options):\n",
|
|
||||||
" return [self._parse(option).option for option in options]\n",
|
|
||||||
"\n",
|
|
||||||
" def _parse(self, html):\n",
|
|
||||||
" return BeautifulSoup(html, 'lxml')\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
|
|||||||
21
src/intensivstationen/KreisOptionsSetter.py
Normal file
21
src/intensivstationen/KreisOptionsSetter.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
|
|
||||||
|
class KreisOptionsSetter:
|
||||||
|
|
||||||
|
def setKreisOptions(self, html, options):
|
||||||
|
soup = self._setKreisOptions(self._parse(html), self._parseOptions(options))
|
||||||
|
return str(soup)
|
||||||
|
|
||||||
|
def _setKreisOptions(self, soup, options):
|
||||||
|
kreisSelect = soup.find(id = "kreisSelect")
|
||||||
|
kreisSelect.clear()
|
||||||
|
for option in options:
|
||||||
|
kreisSelect.append(option)
|
||||||
|
return soup
|
||||||
|
|
||||||
|
def _parseOptions(self, options):
|
||||||
|
return [self._parse(option).option for option in options]
|
||||||
|
|
||||||
|
def _parse(self, html):
|
||||||
|
return BeautifulSoup(html, 'lxml')
|
||||||
Reference in New Issue
Block a user