mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
clean up sanitise postcode
This commit is contained in:
parent
e5583aac1f
commit
714478a99a
1 changed files with 7 additions and 1 deletions
|
|
@ -47,8 +47,14 @@ class EpcClientService:
|
|||
latest = max(results, key=lambda r: r.registration_date)
|
||||
return self.get_by_certificate_number(latest.certificate_number)
|
||||
|
||||
@staticmethod
|
||||
def _normalise_postcode(postcode: str) -> str:
|
||||
"""Return the postcode with all spaces removed and uppercased."""
|
||||
return postcode.replace(" ", "").upper()
|
||||
|
||||
def search_by_postcode(self, postcode: str) -> list[EpcSearchResult]:
|
||||
return call_with_retry(lambda: self._search(postcode=postcode))
|
||||
normalised = self._normalise_postcode(postcode)
|
||||
return call_with_retry(lambda: self._search(postcode=normalised))
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# Private helperEpcRateLimpolarss
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue