lhpapi 1.0.2__tar.gz → 1.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {lhpapi-1.0.2 → lhpapi-1.0.3}/.gitignore +4 -4
- {lhpapi-1.0.2 → lhpapi-1.0.3}/CHANGELOG.md +4 -0
- {lhpapi-1.0.2 → lhpapi-1.0.3}/PKG-INFO +2 -2
- {lhpapi-1.0.2 → lhpapi-1.0.3}/pyproject.toml +1 -1
- {lhpapi-1.0.2 → lhpapi-1.0.3}/src/lhpapi/api_utils.py +9 -18
- {lhpapi-1.0.2 → lhpapi-1.0.3}/src/lhpapi/bb_api.py +1 -0
- {lhpapi-1.0.2 → lhpapi-1.0.3}/src/lhpapi/be_api.py +1 -1
- {lhpapi-1.0.2 → lhpapi-1.0.3}/LICENSE +0 -0
- {lhpapi-1.0.2 → lhpapi-1.0.3}/README.md +0 -0
- {lhpapi-1.0.2 → lhpapi-1.0.3}/src/lhpapi/__init__.py +0 -0
- {lhpapi-1.0.2 → lhpapi-1.0.3}/src/lhpapi/bw_api.py +0 -0
- {lhpapi-1.0.2 → lhpapi-1.0.3}/src/lhpapi/by_api.py +0 -0
- {lhpapi-1.0.2 → lhpapi-1.0.3}/src/lhpapi/hb_api.py +0 -0
- {lhpapi-1.0.2 → lhpapi-1.0.3}/src/lhpapi/he_api.py +0 -0
- {lhpapi-1.0.2 → lhpapi-1.0.3}/src/lhpapi/hh_api.py +0 -0
- {lhpapi-1.0.2 → lhpapi-1.0.3}/src/lhpapi/mv_api.py +0 -0
- {lhpapi-1.0.2 → lhpapi-1.0.3}/src/lhpapi/ni_api.py +0 -0
- {lhpapi-1.0.2 → lhpapi-1.0.3}/src/lhpapi/nw_api.py +0 -0
- {lhpapi-1.0.2 → lhpapi-1.0.3}/src/lhpapi/rp_api.py +0 -0
- {lhpapi-1.0.2 → lhpapi-1.0.3}/src/lhpapi/sh_api.py +0 -0
- {lhpapi-1.0.2 → lhpapi-1.0.3}/src/lhpapi/sl_api.py +0 -0
- {lhpapi-1.0.2 → lhpapi-1.0.3}/src/lhpapi/sn_api.py +0 -0
- {lhpapi-1.0.2 → lhpapi-1.0.3}/src/lhpapi/st_api.py +0 -0
- {lhpapi-1.0.2 → lhpapi-1.0.3}/src/lhpapi/th_api.py +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/.pytest_cache
|
|
2
|
-
/dist
|
|
3
|
-
/src/lhpapi/__pycache__
|
|
4
|
-
/tests/__pycache__
|
|
1
|
+
/.pytest_cache
|
|
2
|
+
/dist
|
|
3
|
+
/src/lhpapi/__pycache__
|
|
4
|
+
/tests/__pycache__
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: lhpapi
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.3
|
|
4
4
|
Summary: API to retrieve data from the Länderübergreifendes Hochwasser Portal (LHP)
|
|
5
5
|
Project-URL: Homepage, https://github.com/stephan192/lhpapi
|
|
6
6
|
Project-URL: Issues, https://github.com/stephan192/lhpapi/issues
|
|
@@ -52,24 +52,6 @@ def fetch_json(url: str, timeout: float = 10.0) -> Any:
|
|
|
52
52
|
return json_data
|
|
53
53
|
|
|
54
54
|
|
|
55
|
-
def fetch_soup(
|
|
56
|
-
url: str, timeout: float = 10.0, remove_xml: bool = False
|
|
57
|
-
) -> BeautifulSoup:
|
|
58
|
-
"""Fetch data via soup."""
|
|
59
|
-
response = get(url=url, timeout=timeout)
|
|
60
|
-
# Override encoding by real educated guess (required for e.g. SH)
|
|
61
|
-
response.encoding = response.apparent_encoding
|
|
62
|
-
response.raise_for_status()
|
|
63
|
-
if remove_xml and (
|
|
64
|
-
(response.text.find('<?xml version="1.0" encoding="ISO-8859-15" ?>')) == 0
|
|
65
|
-
):
|
|
66
|
-
text = response.text[response.text.find("<!DOCTYPE html>") :]
|
|
67
|
-
soup = BeautifulSoup(text, "lxml")
|
|
68
|
-
else:
|
|
69
|
-
soup = BeautifulSoup(response.text, "lxml")
|
|
70
|
-
return soup
|
|
71
|
-
|
|
72
|
-
|
|
73
55
|
def fetch_text(url: str, timeout: float = 10.0, forced_encoding: str = None) -> str:
|
|
74
56
|
"""Fetch data via text."""
|
|
75
57
|
response = get(url=url, timeout=timeout)
|
|
@@ -82,6 +64,15 @@ def fetch_text(url: str, timeout: float = 10.0, forced_encoding: str = None) ->
|
|
|
82
64
|
return response.text
|
|
83
65
|
|
|
84
66
|
|
|
67
|
+
def fetch_soup(
|
|
68
|
+
url: str, timeout: float = 10.0, forced_encoding: str = None
|
|
69
|
+
) -> BeautifulSoup:
|
|
70
|
+
"""Fetch data via soup."""
|
|
71
|
+
text = fetch_text(url=url, timeout=timeout, forced_encoding=forced_encoding)
|
|
72
|
+
soup = BeautifulSoup(text, "lxml")
|
|
73
|
+
return soup
|
|
74
|
+
|
|
75
|
+
|
|
85
76
|
def calc_stage(level: float, stage_levels: list[float]) -> int:
|
|
86
77
|
"""Calc stage from level and stage levels."""
|
|
87
78
|
if (level is None) or all(sl is None for sl in stage_levels):
|
|
@@ -21,7 +21,7 @@ def init_BE(ident: str) -> StaticData: # pylint: disable=invalid-name
|
|
|
21
21
|
# Get data
|
|
22
22
|
page = fetch_soup(
|
|
23
23
|
"https://wasserportal.berlin.de/start.php?anzeige=tabelle_ow&messanzeige=ms_ow_berlin",
|
|
24
|
-
|
|
24
|
+
forced_encoding="ISO-8859-15",
|
|
25
25
|
)
|
|
26
26
|
# Parse data
|
|
27
27
|
table = page.find("table", id="pegeltab")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|