Skip to content

Commit

Permalink
fix: check for suite
Browse files Browse the repository at this point in the history
  • Loading branch information
cullenwatson committed Sep 18, 2023
1 parent 4726764 commit 086bcfd
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions homeharvest/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ def parse_address_two(street_address: str) -> tuple:
return street_address, None

apt_match = re.search(
r"(APT\s*[\dA-Z]+|#[\dA-Z]+|UNIT\s*[\dA-Z]+|LOT\s*[\dA-Z]+)$",
r"(APT\s*[\dA-Z]+|#[\dA-Z]+|UNIT\s*[\dA-Z]+|LOT\s*[\dA-Z]+|SUITE\s*[\dA-Z]+)$",
street_address,
re.I,
)

if apt_match:
apt_str = apt_match.group().strip()
cleaned_apt_str = re.sub(r"(APT\s*|UNIT\s*|LOT\s*)", "#", apt_str, flags=re.I)
cleaned_apt_str = re.sub(
r"(APT\s*|UNIT\s*|LOT\s*|SUITE\s*)", "#", apt_str, flags=re.I
)

main_address = street_address.replace(
apt_str, ""
).strip() # Remove the matched part from the original address
main_address = street_address.replace(apt_str, "").strip()
return main_address, cleaned_apt_str
else:
return street_address, None
Expand Down Expand Up @@ -45,3 +45,4 @@ def parse_unit(street_address: str):
print(parse_address_two("1234 Elm Street apt 2B"))
print(parse_address_two("1234 Elm Street UNIT 3A"))
print(parse_address_two("1234 Elm Street unit 3A"))
print(parse_address_two("1234 Elm Street SuIte 3A"))

0 comments on commit 086bcfd

Please sign in to comment.