Skip to content

Commit

Permalink
linter
Browse files Browse the repository at this point in the history
  • Loading branch information
LukePrior committed Mar 12, 2024
1 parent 92852ce commit 591de3d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions code/nbn.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,17 @@ def get_nbn_loc_id(self, key: str, address: str) -> str:
result = self.get_nbn_data_json(self.LOOKUP_URL + urllib.parse.quote(address))
suggestions = result.get("suggestions", [])
suggestions = [s for s in suggestions if "id" in s and s["id"].startswith("LOC")]
suggestions = sorted(suggestions, key=lambda s: difflib.SequenceMatcher(None, address, s["formattedAddress"]).ratio(), reverse=True)
suggestions = sorted(
suggestions,
key=lambda s: difflib.SequenceMatcher(None, address, s["formattedAddress"]).ratio(),
reverse=True
)
if suggestions:
loc_id = result["suggestions"][0]["id"]
CACHE[key] = loc_id # cache indefinitely
return loc_id
else:
# In future use the NBN Nearby API with lat/long to get suggestions and then if close enough match to the address use that.
# In future use the NBN Nearby API with lat/long to get suggestions.
logging.warning("No valid suggestions for %s", address)

def get_nbn_loc_details(self, place_id: str) -> dict:
Expand Down

0 comments on commit 591de3d

Please sign in to comment.