Compare commits

...

6 Commits

Author SHA1 Message Date
Profitroll
0a374236b4 Commented annoying type errors 2022-09-23 23:00:49 +02:00
Profitroll
f8e7fae9e3 Integrated classes, added "raw_response" argument 2022-09-23 23:00:30 +02:00
Profitroll
74107ceb1b Allowed classes to function 2022-09-23 22:59:48 +02:00
Profitroll
ab02e13825 Created some classes 2022-09-23 22:58:45 +02:00
Profitroll
45a59ff6f6 Added "isodate" to requirements 2022-09-23 22:58:21 +02:00
Profitroll
977ac2d559 Updated to version 0.2.0 2022-09-23 22:58:05 +02:00
16 changed files with 285 additions and 136 deletions

View File

@ -25,7 +25,8 @@ If you have everything listed in [requirements](#requirements), then let's begin
```py
import pyrmv
accessId = "Something" # Set API key
# Set API key
accessId = "Something"
# Get origin's and destination's location
origin = pyrmv.raw.stop_by_name(accessid, "Frankfurt Hauptbahnhof", maxNo=3)[0]["StopLocation"]

View File

@ -8,19 +8,20 @@ Small module that makes your journey with RMV REST API somehow easier. Based ful
```py
import pyrmv
accessId = "Something" # Set API key
# Set API key
accessId = "Something"
# Get origin's and destination's location
origin = pyrmv.raw.stop_by_name(accessid, "Frankfurt Hauptbahnhof", maxNo=3)[0]["StopLocation"]
destination = pyrmv.raw.stop_by_coords(accessid, 50.099613, 8.685449, maxNo=3)[0]["StopLocation"]
origin = pyrmv.raw.stop_by_name(accessid, "Frankfurt Hauptbahnhof", maxNo=1)[0]
destination = pyrmv.raw.stop_by_coords(accessid, 50.099613, 8.685449, maxNo=1)[0]
# Find a trip by locations got
trip = pyrmv.raw.trip_find(accessId, originId=origin["id"], destExtId=destination["id"])
trip = pyrmv.raw.trip_find(accessId, originId=origin.id, destExtId=destination.id)
```
"""
__name__ = "pyrmv"
__version__ = "0.1.9"
__version__ = "0.2.0"
__license__ = "MIT License"
__author__ = "Profitroll"
@ -28,4 +29,5 @@ from . import raw
from . import errors
from . import utility
from . import methods
from . import classes
from .methods import *

8
pyrmv/classes/Gis.py Normal file
View File

@ -0,0 +1,8 @@
from isodate import parse_duration
class Gis():
def __init__(self, ref: str, route: dict):
self.ref = ref
self.dist = route["dist"]
self.duration = parse_duration(route["durS"])
self.geo = route["dirGeo"]

2
pyrmv/classes/Journey.py Normal file
View File

@ -0,0 +1,2 @@
class Journey():
pass

20
pyrmv/classes/Leg.py Normal file
View File

@ -0,0 +1,20 @@
from pyrmv.classes.Gis import Gis
from pyrmv.classes.Stop import StopTrip
from isodate import parse_duration
class Leg():
def __init__(self, data: dict):
self.origin = StopTrip(data["Origin"])
self.destination = StopTrip(data["Destination"])
if "GisRef" in data:
self.gis = Gis(data["GisRef"]["ref"], data["GisRoute"])
else:
self.gis = None
self.index = data["idx"]
self.name = data["name"]
self.type = data["type"]
self.duration = parse_duration(data["duration"])
if "dist" in data:
self.distance = data["dist"]
else:
self.distance = None

3
pyrmv/classes/Product.py Normal file
View File

@ -0,0 +1,3 @@
class Product():
def __init__(self):
pass

26
pyrmv/classes/Stop.py Normal file
View File

@ -0,0 +1,26 @@
from time import strptime
class Stop():
def __init__(self, data: dict):
self.name = data["name"]
self.id = data["id"]
if "extId" in data:
self.ext_id = data["extId"]
else:
self.ext_id = None
self.lon = data["lon"]
self.lat = data["lat"]
def __str__(self) -> str:
return f"Stop {self.name} at {self.lon}, {self.lat}"
class StopTrip(Stop):
def __init__(self, data: dict):
self.type = data["type"]
self.date = strptime(data["date"], "%Y-%m-%d")
self.time = strptime(data["time"], "%H:%M:%S")
super().__init__(data)
def __str__(self) -> str:
return f"Stop {self.name} at {self.lon}, {self.lat} at {self.time} {self.date}"

25
pyrmv/classes/Trip.py Normal file
View File

@ -0,0 +1,25 @@
from pyrmv.classes.Leg import Leg
from pyrmv.classes.Stop import StopTrip
from isodate import parse_duration
class Trip():
def __init__(self, data: dict):
self.raw_data = data
self.origin = StopTrip(data["Origin"])
self.destination = StopTrip(data["Destination"])
legs = []
for leg in data["LegList"]["Leg"]:
legs.append(Leg(leg))
self.legs = legs
self.calculation = data["calculation"]
self.index = data["idx"]
self.id = data["tripId"]
self.ctx_recon = data["ctxRecon"]
self.duration = parse_duration(data["duration"])
self.real_time_duration = parse_duration(data["rtDuration"])
self.checksum = data["checksum"]
self.transfer_count = data["transferCount"]
def __str__(self) -> str:
return f"Trip from {self.origin.name} to {self.destination.name} lasting {self.duration} ({self.real_time_duration}) with {len(self.legs)} legs and {self.transfer_count} transfers"

View File

View File

@ -1,3 +1,4 @@
from datetime import datetime
from requests import get
from typing import List, Union
from xmltodict import parse as xmlparse
@ -11,7 +12,22 @@ except ImportError:
# 2.24. Departure Board (departureBoard)
def board_departure(accessId: str,
json: bool = True
json: bool = True,
id: str = None, # type: ignore
extId: str = None, # type: ignore
direction: str = None, # type: ignore
date: Union[str, datetime] = None, # type: ignore
time: Union[str, datetime] = None, # type: ignore
duration: int = 60,
maxJourneys: int = -1,
products: int = None, # type: ignore
operators: Union[str, list] = None, # type: ignore
lines: Union[str, list] = None, # type: ignore
filterEquiv: bool = True,
attributes: Union[str, list] = None, # type: ignore
platforms: int = None, # type: ignore
passlist: bool = False,
boardType: Literal["DEP", "DEP_EQUIVS", "DEP_MAST", "DEP_STATION"] = "DEP"
) -> dict:
if json:
@ -22,7 +38,10 @@ def board_departure(accessId: str,
payload = {}
for var, val in locals().items():
if str(var) not in ["json", "headers", "payload"]:
if str(var) == "boardType":
if val != None:
payload["type"] = val
elif str(var) not in ["json", "headers", "payload"]:
if val != None:
payload[str(var)] = val

View File

@ -14,38 +14,38 @@ except ImportError:
# 2.37. HIM Search (himsearch)
def him_search(accessId: str,
json: bool = True,
dateB: Union[str, datetime] = None,
dateE: Union[str, datetime] = None,
timeB: Union[str, datetime] = None,
timeE: Union[str, datetime] = None,
weekdays: Union[str, OrderedDict[str, bool]] = None,
himIds: Union[str, list] = None,
dateB: Union[str, datetime] = None, # type: ignore
dateE: Union[str, datetime] = None, # type: ignore
timeB: Union[str, datetime] = None, # type: ignore
timeE: Union[str, datetime] = None, # type: ignore
weekdays: Union[str, OrderedDict[str, bool]] = None, # type: ignore
himIds: Union[str, list] = None, # type: ignore
hierarchicalView: bool = False,
operators: Union[str, list] = None,
categories: Union[str, list] = None,
channels: Union[str, list] = None,
companies: Union[str, list] = None,
lines: Union[str, list] = None,
lineids: Union[str, list] = None,
stations: Union[str, list] = None,
fromstation: str = None,
tostation: str = None,
bothways: bool = None,
trainnames: Union[str, list] = None,
metas: Union[str, list] = None,
himcategory: str = None,
himtags: Union[str, list] = None,
regions: Union[str, list] = None,
himtext: Union[str, list] = None,
himtexttags: Union[str, list] = None,
additionalfields: Union[str, list, dict] = None,
operators: Union[str, list] = None, # type: ignore
categories: Union[str, list] = None, # type: ignore
channels: Union[str, list] = None, # type: ignore
companies: Union[str, list] = None, # type: ignore
lines: Union[str, list] = None, # type: ignore
lineids: Union[str, list] = None, # type: ignore
stations: Union[str, list] = None, # type: ignore
fromstation: str = None, # type: ignore
tostation: str = None, # type: ignore
bothways: bool = None, # type: ignore
trainnames: Union[str, list] = None, # type: ignore
metas: Union[str, list] = None, # type: ignore
himcategory: str = None, # type: ignore
himtags: Union[str, list] = None, # type: ignore
regions: Union[str, list] = None, # type: ignore
himtext: Union[str, list] = None, # type: ignore
himtexttags: Union[str, list] = None, # type: ignore
additionalfields: Union[str, list, dict] = None, # type: ignore
poly: bool = False,
searchmode: Literal["MATCH", "NOMATCH", "TFMATCH"] = None,
affectedJourneyMode: Literal["ALL", "OFF"] = None,
affectedJourneyStopMode: Literal["ALL", "IMP", "OFF"] = None,
orderBy: Union[str, list] = None,
minprio: Union[str, int] = None,
maxprio: Union[str, int] = None
searchmode: Literal["MATCH", "NOMATCH", "TFMATCH"] = None, # type: ignore
affectedJourneyMode: Literal["ALL", "OFF"] = None, # type: ignore
affectedJourneyStopMode: Literal["ALL", "IMP", "OFF"] = None, # type: ignore
orderBy: Union[str, list] = None, # type: ignore
minprio: Union[str, int] = None, # type: ignore
maxprio: Union[str, int] = None # type: ignore
) -> dict:
"""The himSearch will return a list of HIM messages if matched by the given criteria as well as affected
products if any.

View File

@ -1,6 +1,7 @@
from requests import get
from typing import Union
from typing import List, Union
from xmltodict import parse as xmlparse
from pyrmv.classes.Stop import Stop
from pyrmv.utility.find_exception import find_exception
@ -15,15 +16,16 @@ def stop_by_coords(accessId: str,
originCoordLong: Union[str, float],
lang: Literal["de", "da", "en", "es", "fr", "hu", "it", "nl", "no", "pl", "sv", "tr"] = "en",
json: bool = True,
raw_response: bool = False,
radius: Union[int, float] = 1000,
maxNo: int = 10,
stopType: Literal["S", "P", "SP", "SE", "SPE"] = "S",
locationSelectionMode: Literal["SLCT_N", "SLCT_A"] = None,
products: int = None,
meta: str = None,
sattributes: Union[str, list] = None,
sinfotexts: Union[str, list] = None
) -> dict:
locationSelectionMode: Literal["SLCT_N", "SLCT_A"] = None, # type: ignore
products: int = None, # type: ignore
meta: str = None, # type: ignore
sattributes: Union[str, list] = None, # type: ignore
sinfotexts: Union[str, list] = None # type: ignore
) -> Union[dict, List[Stop]]:
"""The location.nearbystops service returns a list of stops around a given center coordinate (within a
radius of 1000m). The returned results are ordered by their distance to the center coordinate.
@ -34,7 +36,8 @@ def stop_by_coords(accessId: str,
* originCoordLat (Union[str, float]): Latitude of centre coordinate.
* originCoordLong (Union[str, float]): Longitude of centre coordinate.
* lang (Literal["de","da","en","es","fr","hu","it","nl","no","pl","sv","tr"], optional): The language of response. Defaults to "en".
* json (bool, optional): Whether response should be retrieved as JSON. XML is returned if False. Defaults to True.
* json (bool, optional): Whether response should be retrieved as JSON. XML is returned if False. Only matters if raw_response is True. Defaults to True.
* raw_response (bool, optional): Whether response should be returned as `dict` instead of `List[Stop]`. Defaults to False.
* radius (Union[int, float], optional): Search radius in meter around the given coordinate if any. Defaults to 1000.
* maxNo (int, optional): Maximum number of returned stops. Defaults to 10.
* stopType (Literal["S", "P", "SP", "SE", "SPE"], optional): Type filter for location types. Defaults to "S".
@ -56,7 +59,7 @@ def stop_by_coords(accessId: str,
payload = {}
for var, val in locals().items():
if str(var) not in ["json", "headers", "payload"]:
if str(var) not in ["json", "headers", "payload", "raw_response"]:
if val != None:
payload[str(var)] = val
@ -64,7 +67,13 @@ def stop_by_coords(accessId: str,
find_exception(output.json())
if json:
return output.json()
if raw_response:
if json:
return output.json()
else:
return xmlparse(output.content)
else:
return xmlparse(output.content)
stops = []
for stop in output.json()["stopLocationOrCoordLocation"]:
stops.append(Stop(stop["StopLocation"]))
return stops

View File

@ -1,6 +1,7 @@
from requests import get
from typing import Union
from typing import List, Union
from xmltodict import parse as xmlparse
from pyrmv.classes.Stop import Stop
from pyrmv.utility.find_exception import find_exception
@ -14,19 +15,20 @@ def stop_by_name(accessId: str,
inputString: str,
lang: Literal["de", "da", "en", "es", "fr", "hu", "it", "nl", "no", "pl", "sv", "tr"] = "en",
json: bool = True,
raw_response: bool = False,
maxNo: int = 10,
stopType: Literal["A", "ALL", "AP", "P", "S", "SA", "SP"] = "ALL",
locationSelectionMode: Literal["SLCT_N", "SLCT_A"] = None,
products: int = None,
coordLat: Union[str, float] = None,
coordLong: Union[str, float] = None,
locationSelectionMode: Literal["SLCT_N", "SLCT_A"] = None, # type: ignore
products: int = None, # type: ignore
coordLat: Union[str, float] = None, # type: ignore
coordLong: Union[str, float] = None, # type: ignore
radius: Union[int, float] = 1000,
refineId: str = None,
meta: str = None,
stations: Union[str, list] = None,
sattributes: Union[str, list] = None,
refineId: str = None, # type: ignore
meta: str = None, # type: ignore
stations: Union[str, list] = None, # type: ignore
sattributes: Union[str, list] = None, # type: ignore
filterMode: Literal["DIST_PERI", "EXCL_PERI", "SLCT_PERI"] = "DIST_PERI"
) -> dict:
) -> Union[dict, List[Stop]]:
"""The location.name service can be used to perform a pattern matching of a user input and to retrieve a list
of possible matches in the journey planner database. Possible matches might be stops/stations, points of
interest and addresses.
@ -41,7 +43,8 @@ def stop_by_name(accessId: str,
* accessId (str): Access ID for identifying the requesting client. Get your key on [RMV website](https://opendata.rmv.de/site/start.html).
* inputString (str): Search for that token.
* lang (Literal["de","da","en","es","fr","hu","it","nl","no","pl","sv","tr"], optional): The language of response. Defaults to "en".
* json (bool, optional): Whether response should be retrieved as JSON. XML is returned if False. Defaults to True.
* json (bool, optional): Whether response should be retrieved as JSON. XML is returned if False. Only matters if raw_response is True. Defaults to True.
* raw_response (bool, optional): Whether response should be returned as `dict` instead of `List[Stop]`. Defaults to False.
* maxNo (int, optional): Maximum number of returned stops. In range 1-1000. Defaults to 10.
* stopType (Literal["A", "ALL", "AP", "P", "S", "SA", "SP"], optional): Type filter for location types. Defaults to "ALL".
* locationSelectionMode (str, optional): Selection mode for locations. "SLCT_N": Not selectable, "SLCT_A": Selectable. Defaults to None.
@ -70,7 +73,7 @@ def stop_by_name(accessId: str,
if str(var) == "inputString":
if val != None:
payload["input"] = val
if str(var) not in ["json", "headers", "payload"]:
elif str(var) not in ["json", "headers", "payload", "raw_response"]:
if val != None:
payload[str(var)] = val
@ -78,7 +81,13 @@ def stop_by_name(accessId: str,
find_exception(output.json())
if json:
return output.json()
if raw_response:
if json:
return output.json()
else:
return xmlparse(output.content)
else:
return xmlparse(output.content)
stops = []
for stop in output.json()["stopLocationOrCoordLocation"]:
stops.append(Stop(stop["StopLocation"]))
return stops

View File

@ -1,6 +1,8 @@
from datetime import datetime
from requests import get
from typing import List, Union
from xmltodict import parse as xmlparse
from pyrmv.classes.Trip import Trip
from pyrmv.utility.find_exception import find_exception
@ -13,88 +15,89 @@ except ImportError:
def trip_find(accessId: str,
lang: Literal["de", "da", "en", "es", "fr", "hu", "it", "nl", "no", "pl", "sv", "tr"] = "en",
json: bool = True,
raw_response: bool = False,
originId: str = None,
originExtId: str = None,
originCoordLat: Union[str, float] = None,
originCoordLong: Union[str, float] = None,
originCoordName: str = None,
originId: str = None, # type: ignore
originExtId: str = None, # type: ignore
originCoordLat: Union[str, float] = None, # type: ignore
originCoordLong: Union[str, float] = None, # type: ignore
originCoordName: str = None, # type: ignore
destId: str = None,
destExtId: str = None,
destCoordLat: Union[str, float] = None,
destCoordLong: Union[str, float] = None,
destCoordName: str = None,
destId: str = None, # type: ignore
destExtId: str = None, # type: ignore
destCoordLat: Union[str, float] = None, # type: ignore
destCoordLong: Union[str, float] = None, # type: ignore
destCoordName: str = None, # type: ignore
via: str = None,
viaId: str = None,
via: str = None, # type: ignore
viaId: str = None, # type: ignore
viaWaitTime: int = 0,
avoid: str = None,
avoidId: str = None,
avoid: str = None, # type: ignore
avoidId: str = None, # type: ignore
viaGis: str = None,
viaGis: str = None, # type: ignore
changeTimePercent: int = 100,
minChangeTime: int = None,
maxChangeTime: int = None,
addChangeTime: int = None,
maxChange: int = None,
minChangeTime: int = None, # type: ignore
maxChangeTime: int = None, # type: ignore
addChangeTime: int = None, # type: ignore
maxChange: int = None, # type: ignore
date: str = None,
time: str = None,
date: Union[str, datetime] = None, # type: ignore
time: Union[str, datetime] = None, # type: ignore
searchForArrival: bool = False,
numF: int = None,
numB: int = None,
numF: int = None, # type: ignore
numB: int = None, # type: ignore
context: str = None,
context: str = None, # type: ignore
poly: bool = False,
polyEnc: Literal["DLT", "GPA", "N"] = "N",
passlist: bool = False,
products: str = None,
operators: Union[str, list] = None,
products: int = None, # type: ignore
operators: Union[str, list] = None, # type: ignore
attributes: Union[str, list] = None,
sattributes: Union[str, list] = None,
fattributes: Union[str, list] = None,
lines: Union[str, list] = None,
lineids: Union[str, list] = None,
attributes: Union[str, list] = None, # type: ignore
sattributes: Union[str, list] = None, # type: ignore
fattributes: Union[str, list] = None, # type: ignore
lines: Union[str, list] = None, # type: ignore
lineids: Union[str, list] = None, # type: ignore
avoidPaths: List[Literal["SW", "EA", "ES", "RA", "CB"]] = None,
avoidPaths: List[Literal["SW", "EA", "ES", "RA", "CB"]] = None, # type: ignore
originWalk: Union[str, list] = None,
originBike: Union[str, list] = None,
originCar: Union[str, list] = None,
originTaxi: Union[str, list] = None,
originPark: Union[str, list] = None,
originMeta: Union[str, list] = None,
originWalk: Union[str, list] = None, # type: ignore
originBike: Union[str, list] = None, # type: ignore
originCar: Union[str, list] = None, # type: ignore
originTaxi: Union[str, list] = None, # type: ignore
originPark: Union[str, list] = None, # type: ignore
originMeta: Union[str, list] = None, # type: ignore
destWalk: Union[str, list] = None,
destBike: Union[str, list] = None,
destCar: Union[str, list] = None,
destTaxi: Union[str, list] = None,
destPark: Union[str, list] = None,
destMeta: Union[str, list] = None,
destWalk: Union[str, list] = None, # type: ignore
destBike: Union[str, list] = None, # type: ignore
destCar: Union[str, list] = None, # type: ignore
destTaxi: Union[str, list] = None, # type: ignore
destPark: Union[str, list] = None, # type: ignore
destMeta: Union[str, list] = None, # type: ignore
totalWalk: Union[str, list] = None,
totalBike: Union[str, list] = None,
totalCar: Union[str, list] = None,
totalTaxi: Union[str, list] = None,
totalMeta: Union[str, list] = None,
totalWalk: Union[str, list] = None, # type: ignore
totalBike: Union[str, list] = None, # type: ignore
totalCar: Union[str, list] = None, # type: ignore
totalTaxi: Union[str, list] = None, # type: ignore
totalMeta: Union[str, list] = None, # type: ignore
gisProducts: str = None,
gisProducts: str = None, # type: ignore
includeIv: bool = False,
ivOnly: bool = False,
mobilityProfile: str = None,
mobilityProfile: str = None, # type: ignore
bikeCarriage: bool = False,
bikeCarriageType: Literal["SINGLEBIKES", "SMALLGROUPS", "LARGEGROUPS"] = None,
bikeCarriageType: Literal["SINGLEBIKES", "SMALLGROUPS", "LARGEGROUPS"] = None, # type: ignore
sleepingCar: bool = False,
couchetteCoach: bool = False,
@ -103,26 +106,26 @@ def trip_find(accessId: str,
eco: bool = False,
ecoCmp: bool = False,
ecoParams: str = None,
ecoParams: str = None, # type: ignore
rtMode: Literal["FULL", "INFOS", "OFF", "REALTIME", "SERVER_DEFAULT"] = None,
rtMode: Literal["FULL", "INFOS", "OFF", "REALTIME", "SERVER_DEFAULT"] = None, # type: ignore
unsharp: bool = False,
trainFilter: str = None,
trainFilter: str = None, # type: ignore
economic: bool = False,
groupFilter: str = None,
groupFilter: str = None, # type: ignore
blockingList: str = None,
blockedEdges: str = None,
blockingList: str = None, # type: ignore
blockedEdges: str = None, # type: ignore
trainComposition: bool = False,
includeEarlier: bool = False,
withICTAlternatives: bool = False,
tariff: bool = None,
tariff: bool = None, # type: ignore
trafficMessages: bool = False,
travellerProfileData: str = None,
travellerProfileData: str = None, # type: ignore
withFreq: bool = True
) -> dict:
) -> Union[dict, List[Trip]]:
"""The trip service calculates a trip from a specified origin to a specified destination. These might be
stop/station IDs or coordinates based on addresses and points of interest validated by the location service or
coordinates freely defined by the client.
@ -132,7 +135,8 @@ def trip_find(accessId: str,
### Args:
* accessId (str): Access ID for identifying the requesting client. Get your key on [RMV website](https://opendata.rmv.de/site/start.html).
* lang (Literal["de","da","en","es","fr","hu","it","nl","no","pl","sv","tr"], optional): The language of response. Defaults to "en".
* json (bool, optional): Whether response should be retrieved as JSON. XML is returned if False. Defaults to True.
* json (bool, optional): Whether response should be retrieved as JSON. XML is returned if False. Only matters if raw_response is True. Defaults to True.
* raw_response (bool, optional): Whether response should be returned as `dict` instead of `List[Trip]`. Defaults to False.
* originId (str, optional): Specifies the station/stop ID of the origin for the trip. Such ID can be retrieved from stopByName() or stopByCoords(). Defaults to None.
* originExtId (str, optional): Deprecated. Please use originId as it supports external IDs. Specifies the external station/stop ID of the origin for the trip. Such ID can be retrieved from stopByName() or stopByCoords(). Defaults to None.
* originCoordLat (Union[str, float], optional): Latitude of station/stop coordinate of the trip's origin. The coordinate can be retrieved from stopByName() or stopByCoords(). Defaults to None.
@ -228,7 +232,19 @@ def trip_find(accessId: str,
payload = {}
for var, val in locals().items():
if str(var) not in ["json", "headers", "payload"]:
if str(var) == "date":
if val != None:
if isinstance(val, datetime):
payload[str(var)] = val.strftime("%Y-%m-%d")
else:
payload[str(var)] = val
elif str(var) == "time":
if val != None:
if isinstance(val, datetime):
payload[str(var)] = val.strftime("%H:%M")
else:
payload[str(var)] = val
elif str(var) not in ["json", "headers", "payload", "raw_response"]:
if val != None:
payload[str(var)] = val
@ -236,7 +252,13 @@ def trip_find(accessId: str,
find_exception(output.json())
if json:
return output.json()
if raw_response:
if json:
return output.json()
else:
return xmlparse(output.content)
else:
return xmlparse(output.content)
trips = []
for trip in output.json()["Trip"]:
trips.append(Trip(trip))
return trips

View File

@ -1,2 +1,3 @@
requests
xmltodict
xmltodict
isodate

View File

@ -2,10 +2,10 @@ from setuptools import setup
setup(
name="pyrmv",
version="0.1.9",
version="0.2.0",
author="Profitroll",
description="Small module that makes your journey with RMV REST API somehow easier.",
long_description="Small module that makes your journey with RMV REST API somehow easier. Based fully on official RMV API reference and HAFAS documentation.\n\n# Usage\n\n```py\nimport pyrmv\n\naccessId = \"Something\" # Set API key\n\n# Get origin's and destination's location\norigin = pyrmv.raw.stop_by_name(accessid, \"Frankfurt Hauptbahnhof\", maxNo=3)[0][\"StopLocation\"]\ndestination = pyrmv.raw.stop_by_coords(accessid, 50.099613, 8.685449, maxNo=3)[0][\"StopLocation\"]\n\n# Find a trip by locations got\ntrip = pyrmv.raw.trip_find(accessId, originId=origin[\"id\"], destExtId=destination[\"id\"])\n```\n\n# Frequently Asked Questions\n\n- Why are there raw versions and formatted ones?\n- Some methods work slightly different\n- Documentation is not perfectly clear\n\n## Why are there raw versions and formatted ones?\n\nFor the purposes of my projects I don't really need all the stuff RMV gives (even though it's not much).\nI only need some specific things. However I do understand that in some cases other users may find\nthose methods quite useful so I implemented them as well.\n\n\n## Some methods work slightly different\n\nCan be. Not all function arguments written may work perfectly because I simply did not test each and\nevery request. Some of arguments may be irrelevant in my use-case and the others are used quite rare at all.\nJust [make an issue](https://git.end-play.xyz/profitroll/PythonRMV/issues/new) and I'll implement it correct when I'll have some free time.\n\n## Documentation is not perfectly clear\n\nOf course docs cannot be perfect as a python docstring, especially if sometimes I don't\nknow how things should correctly work. That's why you get HAFAS API docs in addition to your\nRMV API key. Just use my functions together with those docs, if you want to build something\nreally sophisticated. However I'm not sure whether RMV supports that many HAFAS features publicly.\n\n# To-Do\n- [ ] arrivalBoard (board_arrival) \n- [ ] departureBoard (board_departure) \n- [x] himsearch (him_search) \n- [ ] journeyDetail (journey_detail)\n- [x] location.nearbystops (stop_by_coords) \n- [x] location.name (stop_by_name) \n- [x] trip (trip_find) \n- [ ] recon (trip_recon)",
long_description="## PythonRMV\n\nSmall module that makes your journey with RMV REST API somehow easier. Based fully on official RMV API reference and HAFAS documentation.\n\n## Usage\n\n```py\nimport pyrmv\n\n# Set API key\naccessId = \"Something\"\n\n# Get origin's and destination's location\norigin = pyrmv.raw.stop_by_name(accessid, \"Frankfurt Hauptbahnhof\", maxNo=3)[0][\"StopLocation\"]\ndestination = pyrmv.raw.stop_by_coords(accessid, 50.099613, 8.685449, maxNo=3)[0][\"StopLocation\"]\n\n## Find a trip by locations got\ntrip = pyrmv.raw.trip_find(accessId, originId=origin[\"id\"], destExtId=destination[\"id\"])\n```\n\n## Frequently Asked Questions\n\n- Why are there raw versions and formatted ones?\n- Some methods work slightly different\n- Documentation is not perfectly clear\n\n### Why are there raw versions and formatted ones?\n\nFor the purposes of my projects I don't really need all the stuff RMV gives (even though it's not much).\nI only need some specific things. However I do understand that in some cases other users may find\nthose methods quite useful so I implemented them as well.\n\n\n### Some methods work slightly different\n\nCan be. Not all function arguments written may work perfectly because I simply did not test each and\nevery request. Some of arguments may be irrelevant in my use-case and the others are used quite rare at all.\nJust [make an issue](https://git.end-play.xyz/profitroll/PythonRMV/issues/new) and I'll implement it correct when I'll have some free time.\n\n### Documentation is not perfectly clear\n\nOf course docs cannot be perfect as a python docstring, especially if sometimes I don't\nknow how things should correctly work. That's why you get HAFAS API docs in addition to your\nRMV API key. Just use my functions together with those docs, if you want to build something\nreally sophisticated. However I'm not sure whether RMV supports that many HAFAS features publicly.\n\n## To-Do\n- [ ] arrivalBoard (board_arrival) \n- [ ] departureBoard (board_departure) \n- [x] himsearch (him_search) \n- [ ] journeyDetail (journey_detail)\n- [x] location.nearbystops (stop_by_coords) \n- [x] location.name (stop_by_name) \n- [x] trip (trip_find) \n- [ ] recon (trip_recon)",
long_description_content_type="text/markdown",
author_email="profitroll@end-play.xyz",
url="https://git.end-play.xyz/profitroll/PythonRMV",
@ -19,11 +19,13 @@ setup(
"pyrmv.raw",
"pyrmv.errors",
"pyrmv.methods",
"pyrmv.utility"
"pyrmv.utility",
"pyrmv.classes"
],
install_requires=[
"requests",
"xmltodict"
"xmltodict",
"isodate"
],
classifiers=[
"Development Status :: 1 - Planning",