refactoring

This commit is contained in:
frankknoll
2022-12-14 10:51:45 +01:00
parent d313d33d58
commit bc1b76710c

View File

@@ -6,12 +6,26 @@
"id": "9de5907f-18f5-4cb1-903e-26028ff1fa03", "id": "9de5907f-18f5-4cb1-903e-26028ff1fa03",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [
"import os\n",
"\n",
"module_path = os.path.abspath(os.path.join('..'))\n",
"if module_path not in sys.path:\n",
" sys.path.append(module_path)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "640be762",
"metadata": {},
"outputs": [],
"source": [ "source": [
"import pandas as pd\n", "import pandas as pd\n",
"from urllib import request\n", "from urllib import request\n",
"import os\n",
"from DateProvider import DateProvider\n", "from DateProvider import DateProvider\n",
"from datetime import datetime\n", "from datetime import datetime\n",
"from HtmlTransformerUtil import HtmlTransformerUtil\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",
@@ -52,30 +66,6 @@
"print('needsUpdate:', needsUpdate)" "print('needsUpdate:', needsUpdate)"
] ]
}, },
{
"cell_type": "code",
"execution_count": null,
"id": "03784154",
"metadata": {},
"outputs": [],
"source": [
"from bs4 import BeautifulSoup\n",
"\n",
"class HtmlTransformerUtil:\n",
" \n",
" def applySoupTransformerToFile(self, file, soupTransformer):\n",
" self._writeSoup(soupTransformer(self._readSoup(file)), file)\n",
"\n",
" def _readSoup(self, file):\n",
" with open(file) as fp:\n",
" soup = BeautifulSoup(fp, 'lxml')\n",
" return soup\n",
"\n",
" def _writeSoup(self, soup, file):\n",
" with open(file, \"w\") as fp:\n",
" fp.write(str(soup)) \n"
]
},
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": null,