pylint sur requetes

This commit is contained in:
SebF 2021-10-10 16:53:12 +02:00
parent af09edea2b
commit b5ab062b3e
2 changed files with 39 additions and 38 deletions

View File

@ -1,7 +1,10 @@
#!/usr/bin/env python3
"""Module des requêtes"""
class requete:
class Requete:
"""Objet requête"""
nom: str
critere: str
champs: dict
@ -12,8 +15,8 @@ class requete:
self.champs = champs
reqs = []
champs_stationnement = {
REQS = []
CHAMPS_STATIONNEMENT = {
"amenity": {"export_json": "Non", "FR": "aménagement"},
"capacity": {"export_json": "Oui", "FR": "nombre d'emplacements"},
"access": {"export_json": "Oui", "FR": "accès"},
@ -25,7 +28,7 @@ champs_stationnement = {
"check_date:capacity": {"export_json": "Non", "FR": "date_vérification"},
"source": {"export_json": "Non", "FR": "source"},
}
champs_poi = {
CHAMPS_POI = {
"name": {"export_json": "Oui", "FR": ""},
"description": {"export_json": "Oui", "FR": ""},
"website": {"export_json": "Oui", "FR": ""},
@ -41,8 +44,7 @@ champs_poi = {
"office": {"export_json": "Oui", "FR": "Bureau"},
"opening_hours": {"export_json": "Oui", "FR": "Horaires"},
}
# fields api_adresse (issus du géocodage inversé)
champs_adresse = {
CHAMPS_ADRESSE = {
"api_adresse:geometry:coordinates:lon": {
"export_json": "Non",
"FR": "lon_adresse_etalab",
@ -71,73 +73,72 @@ champs_adresse = {
"api_adresse:properties:street": {"export_json": "Non", "FR": "rue_etalab"},
}
reqs.append(
requete(
REQS.append(
Requete(
"stationnements_velos_publics",
r'nwr["amenity"="bicycle_parking"](area:aire_de_recherche); - nwr["amenity"="bicycle_parking"]["access"~"(no|permit|private|customers)"](area:aire_de_recherche);',
dict(champs_stationnement, **champs_adresse),
dict(CHAMPS_STATIONNEMENT, **CHAMPS_ADRESSE),
)
)
reqs.append(
requete(
REQS.append(
Requete(
"stationnements_velos_non_publics",
r'nwr["amenity"="bicycle_parking"]["access"~"(no|permit|private|customers)"](area:aire_de_recherche);',
dict(champs_stationnement, **champs_adresse),
dict(CHAMPS_STATIONNEMENT, **CHAMPS_ADRESSE),
)
)
champ_local = {"service:bicycle:diy": {"export_json": "Non", "FR": ""}}
reqs.append(
requete(
CHAMP_LOCAL = {"service:bicycle:diy": {"export_json": "Non", "FR": ""}}
REQS.append(
Requete(
"ateliers_autoreparation",
r'nwr["service:bicycle:diy"="yes"](area:aire_de_recherche);',
dict(champ_local, **champs_poi, **champs_adresse),
dict(CHAMP_LOCAL, **CHAMPS_POI, **CHAMPS_ADRESSE),
)
)
champ_local = {"association": {"export_json": "Non", "FR": ""}}
reqs.append(
requete(
CHAMP_LOCAL = {"association": {"export_json": "Non", "FR": ""}}
REQS.append(
Requete(
"associations_velo",
r'nwr["association"="bicycle"](area:aire_de_recherche);',
dict(champ_local, **champs_poi, **champs_adresse),
dict(CHAMP_LOCAL, **CHAMPS_POI, **CHAMPS_ADRESSE),
)
)
champ_local = {"craft": {"export_json": "Non", "FR": ""}}
reqs.append(
requete(
CHAMP_LOCAL = {"craft": {"export_json": "Non", "FR": ""}}
REQS.append(
Requete(
"fabriquants_velo",
r'nwr["craft"="bicycle"](area:aire_de_recherche);',
dict(champ_local, **champs_poi, **champs_adresse),
dict(CHAMP_LOCAL, **CHAMPS_POI, **CHAMPS_ADRESSE),
)
)
champ_local = {"shop": {"export_json": "Non", "FR": ""}}
reqs.append(
requete(
CHAMP_LOCAL = {"shop": {"export_json": "Non", "FR": ""}}
REQS.append(
Requete(
"vendeurs_velo",
r'nwr["shop"="bicycle"](area:aire_de_recherche); nwr["service:bicycle:retail"="yes"](area:aire_de_recherche);',
dict(champ_local, **champs_poi, **champs_adresse),
dict(CHAMP_LOCAL, **CHAMPS_POI, **CHAMPS_ADRESSE),
)
)
champ_local = {"amenity": {"export_json": "Non", "FR": ""}}
reqs.append(
requete(
CHAMP_LOCAL = {"amenity": {"export_json": "Non", "FR": ""}}
REQS.append(
Requete(
"velos_libre_service",
r'nwr["amenity"="bicycle_rental"](area:aire_de_recherche);',
dict(champ_local, **champs_poi, **champs_adresse),
dict(CHAMP_LOCAL, **CHAMPS_POI, **CHAMPS_ADRESSE),
)
)
champ_local = {"service:bicycle:rental": {"export_json": "Non", "FR": ""}}
reqs.append(
requete(
CHAMP_LOCAL = {"service:bicycle:rental": {"export_json": "Non", "FR": ""}}
REQS.append(
Requete(
"location_velo",
r'nwr["service:bicycle:rental"="yes"](area:aire_de_recherche);',
dict(champ_local, **champs_poi, **champs_adresse),
dict(CHAMP_LOCAL, **CHAMPS_POI, **CHAMPS_ADRESSE),
)
)

View File

@ -152,7 +152,7 @@ def executer_requete_et_exporter_resultats(
def main():
"""Routine principale"""
for req in requetes.reqs:
for req in requetes.REQS:
for nb_essai in range(MAX_RETRY): # on tente max_retry fois
try:
executer_requete_et_exporter_resultats(