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

Commit bb4ca74

Browse files
committed
chore:formatting and imports
1 parent 7ae9068 commit bb4ca74

File tree

5 files changed

+19
-47
lines changed

5 files changed

+19
-47
lines changed

overpass/api.py

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def __init__(self, *args, **kwargs):
6060

6161
if self.debug:
6262
import http.client as http_client
63+
6364
http_client.HTTPConnection.debuglevel = 1
6465

6566
# You must initialize logging,
@@ -70,7 +71,9 @@ def __init__(self, *args, **kwargs):
7071
requests_log.setLevel(logging.DEBUG)
7172
requests_log.propagate = True
7273

73-
def get(self, query, responseformat="geojson", verbosity="body", build=True, date=''):
74+
def get(
75+
self, query, responseformat="geojson", verbosity="body", build=True, date=""
76+
):
7477
"""Pass in an Overpass query in Overpass QL.
7578
7679
:param query: the Overpass QL query to send to the endpoint
@@ -89,7 +92,7 @@ def get(self, query, responseformat="geojson", verbosity="body", build=True, dat
8992
date = datetime.fromisoformat(date)
9093
except ValueError:
9194
# The 'Z' in a standard overpass date will throw fromisoformat() off
92-
date = datetime.strptime(date, '%Y-%m-%dT%H:%M:%SZ')
95+
date = datetime.strptime(date, "%Y-%m-%dT%H:%M:%SZ")
9396
# Construct full Overpass query
9497
if build:
9598
full_query = self._construct_ql_query(
@@ -142,34 +145,26 @@ def _api_status() -> dict:
142145
r = requests.get(endpoint)
143146
lines = tuple(r.text.splitlines())
144147

145-
available_re = re.compile(r'\d(?= slots? available)')
148+
available_re = re.compile(r"\d(?= slots? available)")
146149
available_slots = int(
147-
next(
148-
(
149-
m.group()
150-
for line in lines
151-
if (m := available_re.search(line))
152-
), 0
153-
)
150+
next((m.group() for line in lines if (m := available_re.search(line))), 0)
154151
)
155152

156-
waiting_re = re.compile(r'(?<=Slot available after: )[\d\-TZ:]{20}')
153+
waiting_re = re.compile(r"(?<=Slot available after: )[\d\-TZ:]{20}")
157154
waiting_slots = tuple(
158155
datetime.strptime(m.group(), "%Y-%m-%dT%H:%M:%S%z")
159156
for line in lines
160157
if (m := waiting_re.search(line))
161158
)
162159

163160
current_idx = next(
164-
i for i, word in enumerate(lines)
165-
if word.startswith('Currently running queries')
161+
i
162+
for i, word in enumerate(lines)
163+
if word.startswith("Currently running queries")
166164
)
167-
running_slots = tuple(tuple(line.split()) for line in lines[current_idx + 1:])
165+
running_slots = tuple(tuple(line.split()) for line in lines[current_idx + 1 :])
168166
running_slots_datetimes = tuple(
169-
datetime.strptime(
170-
slot[3], "%Y-%m-%dT%H:%M:%S%z"
171-
)
172-
for slot in running_slots
167+
datetime.strptime(slot[3], "%Y-%m-%dT%H:%M:%S%z") for slot in running_slots
173168
)
174169

175170
return {
@@ -217,11 +212,10 @@ def slot_available_countdown(self) -> int:
217212
return max(
218213
ceil(
219214
(
220-
self.slot_available_datetime -
221-
datetime.now(timezone.utc)
215+
self.slot_available_datetime - datetime.now(timezone.utc)
222216
).total_seconds()
223217
),
224-
0
218+
0,
225219
)
226220
except TypeError:
227221
# Can't subtract from None, which means slot is available now
@@ -246,7 +240,8 @@ def _construct_ql_query(self, userquery, responseformat, verbosity, date):
246240
if responseformat == "geojson":
247241
template = self._GEOJSON_QUERY_TEMPLATE
248242
complete_query = template.format(
249-
query=raw_query, verbosity=verbosity, date=date)
243+
query=raw_query, verbosity=verbosity, date=date
244+
)
250245
else:
251246
template = self._QUERY_TEMPLATE
252247
complete_query = template.format(

overpass/errors.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
# Copyright 2015-2018 Martijn van Exel.
2-
# This file is part of the overpass-api-python-wrapper project
3-
# which is licensed under Apache 2.0.
4-
# See LICENSE.txt for the full license text.
5-
6-
71
class OverpassError(Exception):
82
"""An error during your request occurred.
93
Super class for all Overpass api errors."""
4+
105
pass
116

127

@@ -26,6 +21,7 @@ def __init__(self, timeout):
2621

2722
class MultipleRequestsError(OverpassError):
2823
"""You are trying to run multiple requests at the same time."""
24+
2925
pass
3026

3127

overpass/queries.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
3-
# Copyright 2015-2018 Martijn van Exel.
4-
# This file is part of the overpass-api-python-wrapper project
5-
# which is licensed under Apache 2.0.
6-
# See LICENSE.txt for the full license text.
7-
8-
91
class MapQuery(object):
102
"""Query to retrieve complete ways and relations in an area."""
113

overpass/utils.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
# Copyright 2015-2018 Martijn van Exel.
2-
# This file is part of the overpass-api-python-wrapper project
3-
# which is licensed under Apache 2.0.
4-
# See LICENSE.txt for the full license text.
5-
6-
71
class Utils(object):
82

93
@staticmethod

tests/test_api.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
# Copyright 2015-2018 Martijn van Exel.
2-
# This file is part of the overpass-api-python-wrapper project
3-
# which is licensed under Apache 2.0.
4-
# See LICENSE.txt for the full license text.
5-
61
import json
72
import os
83
from datetime import datetime, timezone

0 commit comments

Comments
 (0)