Skip to content
This repository was archived by the owner on Jun 10, 2025. It is now read-only.

Commit dc96611

Browse files
authored
Merge pull request #152 from KaartGroup/variable_lines
Handle variable numbers of lines in Overpass status page
2 parents 7804c87 + ddf9a50 commit dc96611

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

overpass/api.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,13 @@ def _api_status() -> dict:
148148

149149
available_re = re.compile(r'\d(?= slots? available)')
150150
available_slots = int(
151-
available_re.search(lines[3]).group()
152-
if available_re.search(lines[3])
153-
else 0
151+
next(
152+
(
153+
available_re.search(line).group()
154+
for line in lines
155+
if available_re.search(line)
156+
), 0
157+
)
154158
)
155159

156160
waiting_re = re.compile(r'(?<=Slot available after: )[\d\-TZ:]{20}')
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Connected as: 0123456789
2+
Current time: 2022-06-15T22:13:27Z
3+
Announced endpoint: lz4.overpass-api.de/api/
4+
Rate limit: 2
5+
2 slots available now.
6+
Currently running queries (pid, space limit, time limit, start time):

tests/test_api.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ def test_geojson_live():
8989
@pytest.mark.parametrize(
9090
"response,slots_available,slots_running,slots_waiting",
9191
[
92+
(
93+
"tests/overpass_status/no_slots_waiting_six_lines.txt",
94+
2,
95+
(),
96+
()
97+
),
9298
(
9399
"tests/overpass_status/no_slots_waiting.txt",
94100
2,

0 commit comments

Comments
 (0)