reformat most things
This commit is contained in:
parent
bd7c781adb
commit
835494d29f
7 changed files with 85 additions and 50 deletions
|
|
@ -6,7 +6,6 @@ from rec import floorplan, routing
|
|||
import re
|
||||
import datetime
|
||||
|
||||
|
||||
_DATA_DIR = pathlib.Path("data/rs/")
|
||||
|
||||
|
||||
|
|
@ -59,10 +58,10 @@ class Listing:
|
|||
def path_floorplan_file(self, order, name) -> pathlib.Path:
|
||||
self.path_floorplan_folder().mkdir(parents=True, exist_ok=True)
|
||||
return self.path_floorplan_folder() / f"{order}_{name}"
|
||||
|
||||
|
||||
def path_last_seen_listing(self) -> pathlib.Path:
|
||||
return self.path_listing() / "last_seen.json"
|
||||
|
||||
|
||||
def dump_listing(self, d: dict):
|
||||
with open(self.path_listing_json(), "w") as f:
|
||||
json.dump(d, f)
|
||||
|
|
@ -121,7 +120,7 @@ class Listing:
|
|||
"estimated_sqm": estimated_sqm,
|
||||
"text": model_output,
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
with open(self.path_floorplan_ocr_json(), "w") as f:
|
||||
json.dump(objs, f)
|
||||
|
|
@ -168,7 +167,7 @@ class Listing:
|
|||
if self._cached is None:
|
||||
with open(self.path_listing_json()) as f:
|
||||
return json.load(f)
|
||||
|
||||
|
||||
@property
|
||||
def detailobject(self):
|
||||
if self._cached is None:
|
||||
|
|
@ -179,7 +178,7 @@ class Listing:
|
|||
@property
|
||||
def price(self) -> float:
|
||||
return self.detailobject["property"]["price"]
|
||||
|
||||
|
||||
@property
|
||||
def tenure_type(self) -> str:
|
||||
return self.detailobject["property"]["tenureType"]
|
||||
|
|
@ -211,7 +210,7 @@ class Listing:
|
|||
if len(matches):
|
||||
return float(matches[0])
|
||||
return None
|
||||
|
||||
|
||||
@property
|
||||
def updateDaysAgo(self) -> int:
|
||||
ts = self.detailobject["property"]["updateDate"] / 1000
|
||||
|
|
@ -223,7 +222,7 @@ class Listing:
|
|||
def last_seen(self) -> int:
|
||||
if not self.path_last_seen_listing().exists():
|
||||
return None
|
||||
|
||||
|
||||
with open(self.path_last_seen_listing(), 'r') as f:
|
||||
datetime_str = json.load(f)
|
||||
dt = datetime.datetime.fromisoformat(datetime_str)
|
||||
|
|
@ -249,11 +248,11 @@ class Listing:
|
|||
except:
|
||||
print(self.identifier)
|
||||
return False
|
||||
|
||||
|
||||
@property
|
||||
def isRemoved(self) -> bool:
|
||||
return not self.detailobject["property"]["visible"]
|
||||
|
||||
|
||||
@property
|
||||
def status(self) -> str:
|
||||
if self.isRemoved:
|
||||
|
|
@ -263,25 +262,36 @@ class Listing:
|
|||
|
||||
def dict_nicely(self):
|
||||
return {
|
||||
"identifier": self.identifier,
|
||||
"sqm_ocr": self.sqm_ocr,
|
||||
"price": self.price,
|
||||
"price_per_sqm": self.price_per_sqm,
|
||||
"url": self.url,
|
||||
"bedrooms": self.bedrooms,
|
||||
"travel_time_fastest": None
|
||||
if len(self.travel_time) == 0
|
||||
else self.travel_time[0],
|
||||
"travel_time_second": None
|
||||
if len(self.travel_time) < 2
|
||||
else self.travel_time[1],
|
||||
"lease_left": self.leaseLeft,
|
||||
"service_charge": self.serviceCharge,
|
||||
"development": self.development,
|
||||
"tenure_type": self.tenure_type,
|
||||
"updated_days": self.updateDaysAgo,
|
||||
"status": self.status,
|
||||
"last_seen": self.last_seen,
|
||||
"identifier":
|
||||
self.identifier,
|
||||
"sqm_ocr":
|
||||
self.sqm_ocr,
|
||||
"price":
|
||||
self.price,
|
||||
"price_per_sqm":
|
||||
self.price_per_sqm,
|
||||
"url":
|
||||
self.url,
|
||||
"bedrooms":
|
||||
self.bedrooms,
|
||||
"travel_time_fastest":
|
||||
None if len(self.travel_time) == 0 else self.travel_time[0],
|
||||
"travel_time_second":
|
||||
None if len(self.travel_time) < 2 else self.travel_time[1],
|
||||
"lease_left":
|
||||
self.leaseLeft,
|
||||
"service_charge":
|
||||
self.serviceCharge,
|
||||
"development":
|
||||
self.development,
|
||||
"tenure_type":
|
||||
self.tenure_type,
|
||||
"updated_days":
|
||||
self.updateDaysAgo,
|
||||
"status":
|
||||
self.status,
|
||||
"last_seen":
|
||||
self.last_seen,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue