From 5dfa477ca7238865250786751ad4954b5d7511b9 Mon Sep 17 00:00:00 2001 From: SebF Date: Sun, 10 Oct 2021 16:31:54 +0200 Subject: [PATCH] pylint sur les erreurs --- osm_vc63/errors.py | 13 ++++++++++--- osm_vc63/utils.py | 4 ++-- recup_donnees_OSM_Overpass.py | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/osm_vc63/errors.py b/osm_vc63/errors.py index 11dd585..07f40f7 100644 --- a/osm_vc63/errors.py +++ b/osm_vc63/errors.py @@ -1,7 +1,10 @@ #!/usr/bin/env python3 +"""Errors module""" -class Api_error(Exception): +class ApiError(Exception): + """Api exception""" + def __init__(self, http_code, message="erreur appel API"): self.http_code = http_code self.message = message @@ -11,9 +14,13 @@ class Api_error(Exception): return f"{self.http_code} -> {self.message}" -class Overpass_error(Api_error): +class OverpassError(ApiError): + """Overpass exception""" + pass -class Geo_api_error(Api_error): +class GeoApiError(ApiError): + """GeoApi exception""" + pass diff --git a/osm_vc63/utils.py b/osm_vc63/utils.py index 5943d8a..b4def3a 100644 --- a/osm_vc63/utils.py +++ b/osm_vc63/utils.py @@ -119,7 +119,7 @@ class Utils: response = requests.get(self.overpass_url, params={"data": overpass_query}) if response.status_code != 200: - raise errors.Overpass_error(response.status_code) + raise errors.OverpassError(response.status_code) return response.json() @@ -131,7 +131,7 @@ class Utils: response = requests.get(url, params={"lon": str(lon), "lat": str(lat)}) if response.status_code != 200: - raise errors.Geo_api_error(response.status_code) + raise errors.GeoApiError(response.status_code) return response.json() diff --git a/recup_donnees_OSM_Overpass.py b/recup_donnees_OSM_Overpass.py index c77d34b..5f46281 100644 --- a/recup_donnees_OSM_Overpass.py +++ b/recup_donnees_OSM_Overpass.py @@ -147,7 +147,7 @@ def main(): req.nom, req.critere, aire_de_recherche, req.champs ) break - except errors.Api_error: + except errors.ApiError: if nb_essai == max_retry: print("trop d'erreurs d'API - abandon")