Skip to content

Commit

Permalink
add line filter to get_directions
Browse files Browse the repository at this point in the history
  • Loading branch information
drosoCode committed Jun 20, 2023
1 parent 11497b7 commit 60dc3bc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions idfm_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ async def get_destinations(self, stop_id: str, direction_name: Optional[str] = N
Args:
stop_id: A string indicating the id of the depart stop area
direction_name: The direction of a train
line_id: A string indicating id of a line (if not specified, all schedules for this stop/direction will be returned regardless of the line)
line_id: A string indicating id of a line (if not specified, all destinations for this stop will be returned regardless of the line)
Returns:
A list of string representing the stations names
"""
Expand All @@ -133,17 +133,18 @@ async def get_destinations(self, stop_id: str, direction_name: Optional[str] = N
ret.add(i.destination_name)
return list(ret)

async def get_directions(self, stop_id: str) -> List[str]:
async def get_directions(self, stop_id: str, line_id: Optional[str] = None) -> List[str]:
"""
Returns the available directions for a specified line
Args:
stop_id: A string indicating the id of the depart stop area
line_id: A string indicating id of a line (if not specified, all directions for this stop will be returned regardless of the line)
Returns:
A list of string representing the stations names
"""
ret = set()
for i in await self.get_traffic(stop_id):
for i in await self.get_traffic(stop_id, line_id=line_id):
ret.add(i.direction)
return list(ret)

Expand Down

0 comments on commit 60dc3bc

Please sign in to comment.