Skip to content

Commit

Permalink
Bug fix beautiful soup not needed anymore as github returns json inst…
Browse files Browse the repository at this point in the history
…ead of html
  • Loading branch information
birgits committed Oct 30, 2023
1 parent d2093ce commit a42c685
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
22 changes: 11 additions & 11 deletions examples/electromobility_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"outputs": [],
"source": [
"import os\n",
"\n",
"import json\n",
"import geopandas as gpd\n",
"import pandas as pd\n",
"import requests\n",
Expand All @@ -53,7 +53,6 @@
"\n",
"from copy import deepcopy\n",
"from pathlib import Path\n",
"from bs4 import BeautifulSoup\n",
"\n",
"from edisgo.edisgo import EDisGo\n",
"from edisgo.tools.logger import setup_logger\n",
Expand Down Expand Up @@ -415,11 +414,6 @@
"source": [
"# Download SimBEV data\n",
"\n",
"def listFD(url, ext=\"\"):\n",
" page = requests.get(url).text\n",
" soup = BeautifulSoup(page, \"html.parser\")\n",
" return [node.get(\"href\").split(\"/\")[-1] for node in soup.find_all(\"a\") if node.get(\"href\").endswith(ext)]\n",
"\n",
"def download_simbev_example_data():\n",
"\n",
" raw_url = (\"https://raw.githubusercontent.com/openego/eDisGo/dev/\" +\n",
Expand All @@ -435,7 +429,9 @@
" # download files\n",
" url = (f\"https://github.com/openego/eDisGo/tree/dev/\" +\n",
" f\"tests/data/simbev_example_scenario/{ags}/\")\n",
" filenames = [f for f in listFD(url, \"csv\")]\n",
" page = requests.get(url).text\n",
" items = json.loads(page)[\"payload\"][\"tree\"][\"items\"]\n",
" filenames = [f[\"name\"] for f in items if \"csv\" in f[\"name\"]]\n",
"\n",
" for file in filenames:\n",
" req = requests.get(f\"{raw_url}/{ags}/{file}\")\n",
Expand Down Expand Up @@ -473,7 +469,9 @@
" # download files\n",
" url = (\"https://github.com/openego/eDisGo/tree/dev/\" +\n",
" \"tests/data/tracbev_example_scenario/\")\n",
" filenames = [f for f in listFD(url, \"gpkg\")]\n",
" page = requests.get(url).text\n",
" items = json.loads(page)[\"payload\"][\"tree\"][\"items\"]\n",
" filenames = [f[\"name\"] for f in items if \"gpkg\" in f[\"name\"]]\n",
"\n",
" for file in filenames:\n",
" req = requests.get(\n",
Expand All @@ -493,7 +491,9 @@
"cell_type": "code",
"execution_count": null,
"id": "1d65e6d6",
"metadata": {},
"metadata": {
"scrolled": true
},
"outputs": [],
"source": [
"edisgo.import_electromobility(\n",
Expand Down Expand Up @@ -776,7 +776,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.5"
"version": "3.8.18"
},
"toc": {
"base_numbering": 1,
Expand Down
1 change: 0 additions & 1 deletion rtd_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
beautifulsoup4
dash < 2.9.0
demandlib
docutils == 0.16.0
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def read(fname):


requirements = [
"beautifulsoup4",
"contextily",
"dash < 2.9.0",
"demandlib",
Expand Down

0 comments on commit a42c685

Please sign in to comment.