Flatten repo structure: move crawler/ to root, remove vqa/ and immoweb/
The crawler subdirectory was the only active project. Moving it to the repo root simplifies paths and removes the unnecessary nesting. The vqa/ and immoweb/ directories were legacy/unused and have been removed. Updated .drone.yml, .gitignore, .claude/ docs, and skills to reflect the new flat structure.
This commit is contained in:
parent
e2247be700
commit
eafbc1ac52
221 changed files with 70 additions and 146140 deletions
47
rec/route_serializer.py
Normal file
47
rec/route_serializer.py
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
import dataclasses
|
||||
import json
|
||||
from typing import List
|
||||
|
||||
from models.listing import DestinationMode, Route, RouteLegStep
|
||||
from rec import routing
|
||||
|
||||
|
||||
class RouteSerializer:
|
||||
@staticmethod
|
||||
def serialize(routing_info: dict[DestinationMode, list[Route]]) -> str:
|
||||
return json.dumps(
|
||||
{
|
||||
json.dumps(dataclasses.asdict(destination_mode)): [
|
||||
json.dumps(dataclasses.asdict(route)) for route in routes
|
||||
]
|
||||
for destination_mode, routes in routing_info.items()
|
||||
}
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def deserialize(route_data_json: str) -> dict[DestinationMode, List[Route]]:
|
||||
json_data = json.loads(route_data_json)
|
||||
destination_routes = {}
|
||||
for destination_mode_str, routes_json in json_data.items():
|
||||
parsed_destination = json.loads(destination_mode_str)
|
||||
destination_mode = DestinationMode(
|
||||
destination_address=parsed_destination["destination_address"],
|
||||
travel_mode=routing.TravelMode(parsed_destination["travel_mode"]),
|
||||
)
|
||||
parsed_route = json.loads(routes_json[0])
|
||||
routes = [
|
||||
Route(
|
||||
legs=[
|
||||
RouteLegStep(
|
||||
distance_meters=step["distance_meters"],
|
||||
duration_s=step["duration_s"],
|
||||
travel_mode=routing.TravelMode(step["travel_mode"]),
|
||||
)
|
||||
for step in parsed_route["legs"]
|
||||
],
|
||||
distance_meters=parsed_route["distance_meters"],
|
||||
duration_s=int(parsed_route["duration_s"]),
|
||||
)
|
||||
]
|
||||
destination_routes[destination_mode] = routes
|
||||
return destination_routes
|
||||
Loading…
Add table
Add a link
Reference in a new issue