parameterize data path when fetching listings
This commit is contained in:
parent
ea56555884
commit
48d379567b
3 changed files with 28 additions and 11 deletions
|
|
@ -6,17 +6,15 @@ from rec import floorplan, routing
|
|||
import re
|
||||
import datetime
|
||||
|
||||
_DATA_DIR = pathlib.Path("data/rs/")
|
||||
|
||||
|
||||
@dataclass()
|
||||
class Listing:
|
||||
identifier: int
|
||||
_cached: Dict = None
|
||||
data_dir: pathlib.Path = pathlib.Path("data/rs/")
|
||||
|
||||
@staticmethod
|
||||
def get_all_listings() -> List["Listing"]:
|
||||
listing_paths = sorted(list(_DATA_DIR.glob("*/listing.json")))
|
||||
def get_all_listings(self) -> List["Listing"]:
|
||||
listing_paths = sorted(list(self.data_dir.glob("*/listing.json")))
|
||||
identifiers = []
|
||||
for listing_path in listing_paths:
|
||||
with open(listing_path) as f:
|
||||
|
|
@ -26,7 +24,7 @@ class Listing:
|
|||
return identifiers
|
||||
|
||||
def path_listing(self) -> pathlib.Path:
|
||||
p = _DATA_DIR / str(self.identifier)
|
||||
p = self.data_dir / str(self.identifier)
|
||||
p.mkdir(parents=True, exist_ok=True)
|
||||
return p
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue