Skip to content

Commit

Permalink
chore: format
Browse files Browse the repository at this point in the history
  • Loading branch information
cullenwatson committed Sep 18, 2023
1 parent 588689c commit 8e140a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion homeharvest/core/scrapers/zillow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ def _parse_properties(self, property_data: dict):
home_info = result["hdpData"]["homeInfo"]
address_data = {
"street_address": home_info["streetAddress"],
"unit": parse_address_two(home_info['unit']) if 'unit' in home_info else None,
"unit": parse_address_two(home_info["unit"])
if "unit" in home_info
else None,
"city": home_info["city"],
"state": home_info["state"],
"zip_code": home_info["zipcode"],
Expand Down
7 changes: 6 additions & 1 deletion homeharvest/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
def parse_address_two(street_address: str):
if not street_address:
return None
apt_match = re.search(r"(APT\s*[\dA-Z]+|#[\dA-Z]+|UNIT\s*[\dA-Z]+|LOT\s*[\dA-Z]+)$", street_address, re.I)
apt_match = re.search(
r"(APT\s*[\dA-Z]+|#[\dA-Z]+|UNIT\s*[\dA-Z]+|LOT\s*[\dA-Z]+)$",
street_address,
re.I,
)

if apt_match:
apt_str = apt_match.group().strip()
Expand All @@ -13,6 +17,7 @@ def parse_address_two(street_address: str):
else:
return None


if __name__ == "__main__":
print(parse_address_two("810 E Colter St APT 32"))
print(parse_address_two("1234 Elm Street apt 2B"))
Expand Down

0 comments on commit 8e140a0

Please sign in to comment.