HomeHarvest/homeharvest/core/scrapers/models.py

85 lines
1.7 KiB
Python
Raw Normal View History

2023-09-15 15:17:37 -07:00
from dataclasses import dataclass
from enum import Enum
2023-09-17 16:30:37 -07:00
class SiteName(Enum):
ZILLOW = "zillow"
REDFIN = "redfin"
REALTOR = "realtor.com"
2023-09-15 15:17:37 -07:00
class ListingType(Enum):
FOR_SALE = "for_sale"
FOR_RENT = "for_rent"
SOLD = "sold"
2023-09-17 16:30:37 -07:00
class PropertyType(Enum):
HOUSE = "HOUSE"
CONDO = "CONDO"
2023-09-17 16:52:34 -07:00
TOWNHOUSE = "TOWNHOUSE"
2023-09-17 16:30:37 -07:00
SINGLE_FAMILY = "SINGLE_FAMILY"
MULTI_FAMILY = "MULTI_FAMILY"
2023-09-17 16:52:34 -07:00
MANUFACTURED = "MANUFACTURED"
APARTMENT = "APARTMENT"
2023-09-17 16:30:37 -07:00
LAND = "LAND"
OTHER = "OTHER"
@classmethod
def from_int_code(cls, code):
mapping = {
1: cls.HOUSE,
2: cls.CONDO,
3: cls.TOWNHOUSE,
4: cls.MULTI_FAMILY,
5: cls.LAND,
6: cls.OTHER,
8: cls.SINGLE_FAMILY,
13: cls.SINGLE_FAMILY,
}
return mapping.get(code, cls.OTHER)
2023-09-15 15:17:37 -07:00
@dataclass
class Address:
address_one: str
city: str
state: str
zip_code: str
address_two: str | None = None
2023-09-17 16:30:37 -07:00
@dataclass()
class Realty:
2023-09-18 08:16:59 -07:00
site_name: str
2023-09-15 15:17:37 -07:00
address: Address
2023-09-15 16:03:17 -07:00
url: str
2023-09-17 16:30:37 -07:00
listing_type: ListingType | None = None
2023-09-15 16:03:17 -07:00
2023-09-17 16:30:37 -07:00
@dataclass
class Property(Realty):
price: int | None = None
2023-09-15 16:03:17 -07:00
beds: int | None = None
2023-09-17 13:06:31 -07:00
baths: float | None = None
2023-09-15 16:03:17 -07:00
stories: int | None = None
year_built: int | None = None
square_feet: int | None = None
price_per_square_foot: int | None = None
mls_id: str | None = None
2023-09-17 16:30:37 -07:00
agent_name: str | None = None
property_type: PropertyType | None = None
2023-09-17 13:06:31 -07:00
lot_size: int | None = None
description: str | None = None
@dataclass
2023-09-17 16:30:37 -07:00
class Building(Realty):
2023-09-17 13:06:31 -07:00
num_units: int | None = None
min_unit_price: int | None = None
max_unit_price: int | None = None
avg_unit_price: int | None = None