1313
1414
1515def remove_troublesome_chars (string : str ):
16+ """Remove chars that cause trouble when pushed into postgres."""
1617 if type (string ) is not str :
1718 return string
1819 troublesome_chars = {'"' : "" , "'" : "" , "\n " : "" }
@@ -22,13 +23,15 @@ def remove_troublesome_chars(string: str):
2223
2324
2425def retry_get (url , retries = 3 , timeout = 4 ):
26+ """Retry a query for a variable amount of tries."""
2527 retry = Retry (total = retries )
2628 with requests .Session () as session :
2729 session .mount ("https://" , HTTPAdapter (max_retries = retry ))
2830 return session .get (url , timeout = timeout )
2931
3032
3133def geojsonToFeatureCollection (geojson : dict ) -> dict :
34+ """Take a GeoJson and wrap it in a FeatureCollection."""
3235 if geojson ["type" ] != "FeatureCollection" :
3336 collection = {
3437 "type" : "FeatureCollection" ,
@@ -39,6 +42,7 @@ def geojsonToFeatureCollection(geojson: dict) -> dict:
3942
4043
4144def chunks (arr , n_objects ):
45+ """Return a list of list with n_objects in each sublist."""
4246 return [
4347 arr [i * n_objects : (i + 1 ) * n_objects ]
4448 for i in range ((len (arr ) + n_objects - 1 ) // n_objects )
@@ -130,9 +134,7 @@ def remove_noise_and_add_user_info(json: dict) -> dict:
130134
131135
132136def ohsome (request : dict , area : str , properties = None ) -> dict :
133- """
134- Request data from Ohsome API.
135- """
137+ """Request data from Ohsome API."""
136138 url = OHSOME_API_LINK + request ["endpoint" ]
137139 data = {"bpolys" : area , "filter" : request ["filter" ]}
138140 if properties :
0 commit comments