refactoring.

This commit is contained in:
Christophe Boulanger 2019-12-11 09:32:09 +01:00
parent 17cbebe1b1
commit a327a2b374
1 changed files with 17 additions and 12 deletions

View File

@ -100,8 +100,8 @@ class ImioLiegeLisrue(BaseResource):
streets = []
known_street_labels = {}
for item in lisrues:
if item.get("rue") or item.get("libelle"):
street_label = item.get("rue") or item.get("libelle")
if self.include_all_of_belgium:
street_label = item.get("libelle")
elif item.get("libelleMinuscule"):
street_label = "%s %s" % (
item.get("particuleMinuscule") or "",
@ -119,19 +119,17 @@ class ImioLiegeLisrue(BaseResource):
else:
street_label = street_label.strip()
streets.append(
{
"id": item.get("codeRue") or item.get("codeStreet"),
"text": street_label,
}
)
if self.profile == "LIEGE_V2":
if (
item.get("statutVO") is not None
and item.get("statutVO").get("code") == "1"
):
if self.include_all_of_belgium:
streets.append({
"id": item.get("codeRue") or item.get("codeStreet"),
"text": street_label,}
)
elif item.get("statutVO") is not None and item.get("statutVO").get("code") == 1:
streets.append(
{
"id": item.get("codeRue") or item.get("codeStreet"),
"text": street_label,
"codeCommissariat": item.get("commissariat").get(
"codeCommissariat"
)
@ -144,6 +142,13 @@ class ImioLiegeLisrue(BaseResource):
else "",
}
)
else:
continue
else:
streets.append({
"id": item.get("codeRue") or item.get("codeStreet"),
"text": street_label,}
)
return {"data": streets}
@endpoint()