herepy 3.6.3__tar.gz → 3.6.4__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.
- {herepy-3.6.3 → herepy-3.6.4}/PKG-INFO +1 -1
- {herepy-3.6.3 → herepy-3.6.4}/herepy/__init__.py +1 -1
- {herepy-3.6.3 → herepy-3.6.4}/herepy/geocoder_api.py +20 -10
- {herepy-3.6.3 → herepy-3.6.4}/herepy/routing_api.py +3 -15
- {herepy-3.6.3 → herepy-3.6.4}/herepy/utils.py +11 -4
- {herepy-3.6.3 → herepy-3.6.4}/herepy.egg-info/PKG-INFO +1 -1
- {herepy-3.6.3 → herepy-3.6.4}/tests/test_geocoder_api.py +50 -2
- {herepy-3.6.3 → herepy-3.6.4}/tests/test_routing_api.py +19 -0
- {herepy-3.6.3 → herepy-3.6.4}/tests/test_utils.py +8 -0
- {herepy-3.6.3 → herepy-3.6.4}/COPYING +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/LICENSE +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/MANIFEST.in +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/NOTICE +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/README.rst +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/herepy/destination_weather_api.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/herepy/error.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/herepy/ev_charging_stations_api.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/herepy/fleet_telematics_api.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/herepy/geocoder_autocomplete_api.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/herepy/geocoder_reverse_api.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/herepy/here_api.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/herepy/here_enum.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/herepy/isoline_routing_api.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/herepy/map_image_api.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/herepy/map_tile_api.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/herepy/mercator_projection.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/herepy/models.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/herepy/objects.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/herepy/places_api.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/herepy/platform/__init__.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/herepy/platform/tour_planning_api.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/herepy/polling.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/herepy/public_transit_api.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/herepy/py.typed +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/herepy/rme_api.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/herepy/traffic_api.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/herepy/vector_tile_api.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/herepy.egg-info/SOURCES.txt +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/herepy.egg-info/dependency_links.txt +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/herepy.egg-info/requires.txt +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/herepy.egg-info/top_level.txt +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/requirements.txt +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/setup.cfg +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/setup.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/tests/test_destination_weather_api.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/tests/test_enum.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/tests/test_ev_charging_stations_api.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/tests/test_fleet_telematics_api.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/tests/test_geocoder_autocomplete_api.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/tests/test_geocoder_reverse_api.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/tests/test_isoline_routing_api.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/tests/test_map_image_api.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/tests/test_map_tile_api.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/tests/test_mercator_projection.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/tests/test_models.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/tests/test_places_api.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/tests/test_publictransit_api.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/tests/test_rme_api.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/tests/test_traffic_api.py +0 -0
- {herepy-3.6.3 → herepy-3.6.4}/tests/test_vector_tile_api.py +0 -0
|
@@ -6,7 +6,7 @@ __author__ = "Abdullah Selek"
|
|
|
6
6
|
__email__ = "abdullahselek.os@gmail.com"
|
|
7
7
|
__copyright__ = "Copyright (c) 2017 Abdullah Selek"
|
|
8
8
|
__license__ = "MIT License"
|
|
9
|
-
__version__ = "3.6.
|
|
9
|
+
__version__ = "3.6.4"
|
|
10
10
|
__url__ = "https://github.com/abdullahselek/HerePy"
|
|
11
11
|
__download_url__ = "https://pypi.org/pypi/herepy"
|
|
12
12
|
__description__ = "A library that provides a Python interface to the HERE APIs"
|
|
@@ -106,11 +106,12 @@ class GeocoderApi(HEREApi):
|
|
|
106
106
|
|
|
107
107
|
def address_with_details(
|
|
108
108
|
self,
|
|
109
|
-
city: str,
|
|
110
|
-
country: str,
|
|
111
|
-
lang: str = "en-US",
|
|
112
109
|
house_number: Optional[int] = None,
|
|
113
110
|
street: Optional[str] = None,
|
|
111
|
+
city: Optional[str] = None,
|
|
112
|
+
postal_code: Optional[str] = None,
|
|
113
|
+
country: Optional[str] = None,
|
|
114
|
+
lang: str = "en-US",
|
|
114
115
|
) -> Optional[GeocoderResponse]:
|
|
115
116
|
"""Geocodes with given address details
|
|
116
117
|
Args:
|
|
@@ -122,6 +123,8 @@ class GeocoderApi(HEREApi):
|
|
|
122
123
|
city name.
|
|
123
124
|
country (str):
|
|
124
125
|
country name.
|
|
126
|
+
postal_code (str):
|
|
127
|
+
postal code.
|
|
125
128
|
lang (str):
|
|
126
129
|
BCP47 compliant Language Code.
|
|
127
130
|
Returns:
|
|
@@ -129,16 +132,23 @@ class GeocoderApi(HEREApi):
|
|
|
129
132
|
Raises:
|
|
130
133
|
HEREError"""
|
|
131
134
|
|
|
132
|
-
|
|
135
|
+
qq_params = []
|
|
133
136
|
if house_number is not None:
|
|
134
|
-
|
|
135
|
-
if street
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
qq_params.append(f"houseNumber={house_number}")
|
|
138
|
+
if street:
|
|
139
|
+
qq_params.append(f"street={street}")
|
|
140
|
+
if city:
|
|
141
|
+
qq_params.append(f"city={city}")
|
|
142
|
+
if postal_code:
|
|
143
|
+
qq_params.append(f"postalCode={postal_code}")
|
|
144
|
+
if country:
|
|
145
|
+
qq_params.append(f"country={country}")
|
|
146
|
+
|
|
147
|
+
if len(qq_params) == 0:
|
|
148
|
+
raise HEREError("At least one of the parameters should be provided")
|
|
139
149
|
|
|
140
150
|
data = {
|
|
141
|
-
"qq":
|
|
151
|
+
"qq": ";".join(qq_params),
|
|
142
152
|
"apiKey": self._api_key,
|
|
143
153
|
"lang": lang,
|
|
144
154
|
}
|
|
@@ -457,17 +457,9 @@ class RoutingApi(HEREApi):
|
|
|
457
457
|
if alternatives:
|
|
458
458
|
data["alternatives"] = alternatives
|
|
459
459
|
if avoid:
|
|
460
|
-
|
|
461
|
-
values = list(avoid.values())[0]
|
|
462
|
-
data["avoid"] = {
|
|
463
|
-
key: ",".join(values),
|
|
464
|
-
}
|
|
460
|
+
data["avoid"] = {key: ",".join(vals) for key, vals in avoid.items()}
|
|
465
461
|
if exclude:
|
|
466
|
-
|
|
467
|
-
values = list(avoid.values())[0]
|
|
468
|
-
data["exclude"] = {
|
|
469
|
-
key: ",".join(values),
|
|
470
|
-
}
|
|
462
|
+
data["exclude"] = {key: ",".join(vals) for key, vals in exclude.items()}
|
|
471
463
|
if units:
|
|
472
464
|
data["units"] = units.__str__()
|
|
473
465
|
if lang:
|
|
@@ -477,11 +469,7 @@ class RoutingApi(HEREApi):
|
|
|
477
469
|
if span_fields:
|
|
478
470
|
data["spans"] = ",".join([field.__str__() for field in span_fields])
|
|
479
471
|
if truck:
|
|
480
|
-
|
|
481
|
-
values = list(avoid.values())[0]
|
|
482
|
-
data["truck"] = {
|
|
483
|
-
key: ",".join(values),
|
|
484
|
-
}
|
|
472
|
+
data["truck"] = {key: ",".join(vals) for key, vals in truck.items()}
|
|
485
473
|
if scooter:
|
|
486
474
|
data["scooter"] = scooter
|
|
487
475
|
|
|
@@ -18,16 +18,23 @@ class Utils(object):
|
|
|
18
18
|
parameters (dict):
|
|
19
19
|
dictionary of query parameters to be converted.
|
|
20
20
|
Returns:
|
|
21
|
-
A URL-encoded string in "key=value&key=value" form
|
|
21
|
+
A URL-encoded string in "key=value&key=value" form. If the parameter value is
|
|
22
|
+
a dict, the encoded string is converted to "main_key[sub_key]=sub_value".
|
|
22
23
|
"""
|
|
23
24
|
if parameters is None:
|
|
24
25
|
return None
|
|
25
26
|
if not isinstance(parameters, dict):
|
|
26
27
|
raise HEREError("`parameters` must be a dict.")
|
|
27
28
|
else:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
)
|
|
29
|
+
parameters = dict((k, v) for k, v in parameters.items() if v is not None)
|
|
30
|
+
result = dict()
|
|
31
|
+
for key, value in parameters.items():
|
|
32
|
+
if isinstance(value, dict):
|
|
33
|
+
for sub_key, sub_value in value.items():
|
|
34
|
+
result[f"{key}[{sub_key}]"] = sub_value
|
|
35
|
+
else:
|
|
36
|
+
result[key] = value
|
|
37
|
+
return urlencode(result)
|
|
31
38
|
|
|
32
39
|
@staticmethod
|
|
33
40
|
def build_url(url, extra_params=None):
|
|
@@ -94,7 +94,8 @@ class GeocoderApiTest(unittest.TestCase):
|
|
|
94
94
|
street="Barbaros",
|
|
95
95
|
city="Istanbul",
|
|
96
96
|
country="Turkey",
|
|
97
|
-
house_number=34
|
|
97
|
+
house_number=34,
|
|
98
|
+
postal_code="34353",
|
|
98
99
|
)
|
|
99
100
|
self.assertTrue(response)
|
|
100
101
|
self.assertIsInstance(response, herepy.GeocoderResponse)
|
|
@@ -136,7 +137,54 @@ class GeocoderApiTest(unittest.TestCase):
|
|
|
136
137
|
)
|
|
137
138
|
self.assertTrue(response)
|
|
138
139
|
self.assertIsInstance(response, herepy.GeocoderResponse)
|
|
139
|
-
|
|
140
|
+
|
|
141
|
+
@responses.activate
|
|
142
|
+
def test_address_with_detail_without_country(self):
|
|
143
|
+
with open("testdata/models/geocoder.json", "r") as f:
|
|
144
|
+
expected_response = f.read()
|
|
145
|
+
responses.add(
|
|
146
|
+
responses.GET,
|
|
147
|
+
"https://geocode.search.hereapi.com/v1/geocode",
|
|
148
|
+
expected_response,
|
|
149
|
+
status=200,
|
|
150
|
+
)
|
|
151
|
+
response = self._api.address_with_details(
|
|
152
|
+
street="Barbaros",
|
|
153
|
+
city="Istanbul",
|
|
154
|
+
country= None
|
|
155
|
+
)
|
|
156
|
+
self.assertTrue(response)
|
|
157
|
+
self.assertIsInstance(response, herepy.GeocoderResponse)
|
|
158
|
+
|
|
159
|
+
@responses.activate
|
|
160
|
+
def test_address_with_detail_with_only_country(self):
|
|
161
|
+
with open("testdata/models/geocoder.json") as f:
|
|
162
|
+
expected_response = f.read()
|
|
163
|
+
responses.add(
|
|
164
|
+
responses.GET,
|
|
165
|
+
"https://geocode.search.hereapi.com/v1/geocode",
|
|
166
|
+
expected_response,
|
|
167
|
+
status=200,
|
|
168
|
+
)
|
|
169
|
+
response = self._api.address_with_details(
|
|
170
|
+
country="FR",
|
|
171
|
+
)
|
|
172
|
+
self.assertTrue(response)
|
|
173
|
+
self.assertIsInstance(response, herepy.GeocoderResponse)
|
|
174
|
+
|
|
175
|
+
@responses.activate
|
|
176
|
+
def test_address_with_detail_without_any_detail_raise(self):
|
|
177
|
+
with open("testdata/models/geocoder.json") as f:
|
|
178
|
+
expected_response = f.read()
|
|
179
|
+
responses.add(
|
|
180
|
+
responses.GET,
|
|
181
|
+
"https://geocode.search.hereapi.com/v1/geocode",
|
|
182
|
+
expected_response,
|
|
183
|
+
status=200,
|
|
184
|
+
)
|
|
185
|
+
with self.assertRaises(herepy.HEREError):
|
|
186
|
+
self._api.address_with_details(country="")
|
|
187
|
+
|
|
140
188
|
@responses.activate
|
|
141
189
|
def test_addresswithdetails_whenerroroccurred(self):
|
|
142
190
|
with open("testdata/models/geocoder_error.json", "r") as f:
|
|
@@ -1215,3 +1215,22 @@ class RoutingApiTest(unittest.TestCase):
|
|
|
1215
1215
|
)
|
|
1216
1216
|
self.assertTrue(response)
|
|
1217
1217
|
self.assertIsInstance(response, herepy.RoutingResponseV8)
|
|
1218
|
+
|
|
1219
|
+
@responses.activate
|
|
1220
|
+
def test_route_v8_url_parameters_multiple(self):
|
|
1221
|
+
responses.add(
|
|
1222
|
+
responses.GET,
|
|
1223
|
+
"https://router.hereapi.com/v8/routes",
|
|
1224
|
+
"{}",
|
|
1225
|
+
status=200,
|
|
1226
|
+
match=[
|
|
1227
|
+
responses.matchers.query_param_matcher(
|
|
1228
|
+
{"truck[height]": "15000", "truck[width]": "3000"}, strict_match=False
|
|
1229
|
+
)
|
|
1230
|
+
],
|
|
1231
|
+
)
|
|
1232
|
+
self._api.route_v8(transport_mode=herepy.RoutingTransportMode.truck,
|
|
1233
|
+
origin=[41.9798, -87.8801],
|
|
1234
|
+
destination=[41.9043, -87.9216],
|
|
1235
|
+
truck={"height": ["15000"], "width": ["3000"]}
|
|
1236
|
+
)
|
|
@@ -29,3 +29,11 @@ class UtilsTest(unittest.TestCase):
|
|
|
29
29
|
"https://geocoder.cit.api.here.com/6.2/geocode.json", data
|
|
30
30
|
)
|
|
31
31
|
self.assertTrue(url)
|
|
32
|
+
|
|
33
|
+
def test_build_url_sub_data(self):
|
|
34
|
+
data = {
|
|
35
|
+
"key1": "val",
|
|
36
|
+
"key2": {"sub_key": "sub_val", "sub_key2": "sub_val2"},
|
|
37
|
+
}
|
|
38
|
+
url = Utils.build_url("https://router.hereapi.com/v8/routes", data)
|
|
39
|
+
self.assertEqual(url, "https://router.hereapi.com/v8/routes?key1=val&key2%5Bsub_key%5D=sub_val&key2%5Bsub_key2%5D=sub_val2")
|
|
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
|
|
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
|
|
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
|