apyefa 0.0.7__py3-none-any.whl → 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of apyefa might be problematic. Click here for more details.
- apyefa/client.py +543 -52
- apyefa/commands/__init__.py +12 -0
- apyefa/commands/command.py +97 -53
- apyefa/commands/command_add_info.py +60 -0
- apyefa/commands/command_coord.py +45 -0
- apyefa/commands/command_departures.py +4 -5
- apyefa/commands/command_geoobject.py +42 -0
- apyefa/commands/command_line_list.py +46 -0
- apyefa/commands/command_line_stop.py +39 -0
- apyefa/commands/command_serving_lines.py +8 -18
- apyefa/commands/command_stop_finder.py +4 -6
- apyefa/commands/command_stop_list.py +48 -0
- apyefa/commands/command_system_info.py +3 -3
- apyefa/commands/command_trip.py +26 -5
- apyefa/data_classes.py +190 -65
- apyefa/helpers.py +61 -0
- apyefa-1.0.0.dist-info/METADATA +125 -0
- apyefa-1.0.0.dist-info/RECORD +27 -0
- apyefa-0.0.7.dist-info/METADATA +0 -430
- apyefa-0.0.7.dist-info/RECORD +0 -21
- {apyefa-0.0.7.dist-info → apyefa-1.0.0.dist-info}/LICENSE +0 -0
- {apyefa-0.0.7.dist-info → apyefa-1.0.0.dist-info}/WHEEL +0 -0
- {apyefa-0.0.7.dist-info → apyefa-1.0.0.dist-info}/top_level.txt +0 -0
apyefa/commands/__init__.py
CHANGED
|
@@ -1,15 +1,27 @@
|
|
|
1
1
|
from .command import Command
|
|
2
|
+
from .command_add_info import CommandAdditionalInfo
|
|
3
|
+
from .command_coord import CommandCoord
|
|
2
4
|
from .command_departures import CommandDepartures
|
|
5
|
+
from .command_geoobject import CommandGeoObject
|
|
6
|
+
from .command_line_list import CommandLineList
|
|
7
|
+
from .command_line_stop import CommandLineStop
|
|
3
8
|
from .command_serving_lines import CommandServingLines
|
|
4
9
|
from .command_stop_finder import CommandStopFinder
|
|
10
|
+
from .command_stop_list import CommandStopList
|
|
5
11
|
from .command_system_info import CommandSystemInfo
|
|
6
12
|
from .command_trip import CommandTrip
|
|
7
13
|
|
|
8
14
|
__all__ = [
|
|
9
15
|
"Command",
|
|
10
16
|
"CommandDepartures",
|
|
17
|
+
"CommandAdditionalInfo",
|
|
18
|
+
"CommandCoord",
|
|
19
|
+
"CommandGeoObject",
|
|
11
20
|
"CommandStopFinder",
|
|
21
|
+
"CommandStopList",
|
|
12
22
|
"CommandSystemInfo",
|
|
23
|
+
"CommandLineStop",
|
|
24
|
+
"CommandLineList",
|
|
13
25
|
"CommandTrip",
|
|
14
26
|
"CommandServingLines",
|
|
15
27
|
]
|
apyefa/commands/command.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import logging
|
|
2
2
|
from abc import abstractmethod
|
|
3
|
+
from datetime import date, datetime
|
|
3
4
|
|
|
4
5
|
from voluptuous import MultipleInvalid, Schema
|
|
5
6
|
|
|
@@ -7,107 +8,150 @@ from apyefa.commands.parsers.rapid_json_parser import RapidJsonParser
|
|
|
7
8
|
from apyefa.exceptions import EfaFormatNotSupported, EfaParameterError
|
|
8
9
|
from apyefa.helpers import is_date, is_datetime, is_time
|
|
9
10
|
|
|
10
|
-
from ..data_classes import CoordFormat
|
|
11
|
-
|
|
12
11
|
_LOGGER = logging.getLogger(__name__)
|
|
13
12
|
|
|
14
13
|
|
|
15
14
|
class Command:
|
|
16
|
-
def __init__(self, name: str,
|
|
15
|
+
def __init__(self, name: str, format: str) -> None:
|
|
17
16
|
self._name: str = name
|
|
18
|
-
self._macro: str = macro
|
|
19
17
|
self._parameters: dict[str, str] = {}
|
|
20
|
-
self._format
|
|
18
|
+
self._format = format
|
|
21
19
|
|
|
22
|
-
self.add_param("outputFormat",
|
|
23
|
-
self.add_param("coordOutputFormat", CoordFormat.WGS84.value)
|
|
20
|
+
self.add_param("outputFormat", format)
|
|
24
21
|
|
|
25
|
-
def add_param(self, param: str, value: str):
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
def add_param(self, param: str, value: str | bool):
|
|
23
|
+
"""
|
|
24
|
+
Adds a parameter and its value to the command's parameters.
|
|
28
25
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
Args:
|
|
27
|
+
param (str): The name of the parameter to add.
|
|
28
|
+
value (str | bool): The value of the parameter. If the value is a boolean,
|
|
29
|
+
it will be converted to "1" for True and "0" for False.
|
|
30
|
+
|
|
31
|
+
Raises:
|
|
32
|
+
EfaParameterError: If the parameter is not allowed for this command.
|
|
33
|
+
"""
|
|
34
|
+
if not param or value is None:
|
|
35
|
+
return
|
|
33
36
|
|
|
34
37
|
_LOGGER.debug(f'Add parameter "{param}" with value "{value}"')
|
|
35
38
|
|
|
39
|
+
if isinstance(value, bool):
|
|
40
|
+
value = "1" if value else "0"
|
|
41
|
+
|
|
36
42
|
self._parameters.update({param: value})
|
|
37
43
|
|
|
38
44
|
_LOGGER.debug("Updated parameters:")
|
|
39
45
|
_LOGGER.debug(self._parameters)
|
|
40
46
|
|
|
41
|
-
def add_param_datetime(self,
|
|
42
|
-
|
|
43
|
-
|
|
47
|
+
def add_param_datetime(self, arg_date: str | datetime | date):
|
|
48
|
+
"""
|
|
49
|
+
Adds date and/or time parameters to the command based on the provided argument.
|
|
44
50
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
self.add_param("itdTime", date.split(" ")[1].replace(":", ""))
|
|
48
|
-
elif is_date(date):
|
|
49
|
-
self.add_param("itdDate", date)
|
|
50
|
-
elif is_time(date):
|
|
51
|
-
self.add_param("itdTime", date.replace(":", ""))
|
|
52
|
-
else:
|
|
53
|
-
raise ValueError("Date(time) provided in invalid format")
|
|
51
|
+
Parameters:
|
|
52
|
+
arg_date (str | datetime | date): The date and/or time to be added. It can be a string, datetime object, or date object.
|
|
54
53
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
self.validate()
|
|
54
|
+
Raises:
|
|
55
|
+
ValueError: If the provided date(time) is in an invalid format.
|
|
58
56
|
|
|
59
|
-
|
|
57
|
+
Notes:
|
|
58
|
+
- If arg_date is a datetime object, both date and time parameters are added.
|
|
59
|
+
- If arg_date is a date object, only the date parameter is added.
|
|
60
|
+
- If arg_date is a string, it will be checked if it is a valid datetime, date, or time string.
|
|
61
|
+
"""
|
|
62
|
+
if not arg_date:
|
|
63
|
+
return
|
|
60
64
|
|
|
61
|
-
|
|
62
|
-
|
|
65
|
+
if isinstance(arg_date, datetime):
|
|
66
|
+
self.add_param("itdDate", arg_date.strftime("%Y%m%d"))
|
|
67
|
+
self.add_param("itdTime", arg_date.strftime("%H%M"))
|
|
68
|
+
elif isinstance(arg_date, date):
|
|
69
|
+
self.add_param("itdDate", arg_date.strftime("%Y%m%d"))
|
|
70
|
+
elif is_datetime(arg_date):
|
|
71
|
+
self.add_param("itdDate", arg_date.split(" ")[0])
|
|
72
|
+
self.add_param("itdTime", arg_date.split(" ")[1].replace(":", ""))
|
|
73
|
+
elif is_date(arg_date):
|
|
74
|
+
self.add_param("itdDate", arg_date)
|
|
75
|
+
elif is_time(arg_date):
|
|
76
|
+
self.add_param("itdTime", arg_date.replace(":", ""))
|
|
77
|
+
else:
|
|
78
|
+
raise ValueError(f'Date(time) "{arg_date}" provided in invalid format')
|
|
63
79
|
|
|
64
|
-
def
|
|
65
|
-
"""
|
|
80
|
+
def validate_params(self):
|
|
81
|
+
"""
|
|
82
|
+
Validates the parameters against the schema.
|
|
66
83
|
|
|
67
84
|
Raises:
|
|
68
|
-
EfaParameterError:
|
|
85
|
+
EfaParameterError: If the parameters are invalid
|
|
69
86
|
"""
|
|
70
|
-
params_schema = self._get_params_schema()
|
|
71
87
|
|
|
72
88
|
try:
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
_LOGGER.error("Parameters validation failed", exc_info=exc)
|
|
77
|
-
raise EfaParameterError(str(exc)) from exc
|
|
89
|
+
self._get_params_schema()(self._parameters)
|
|
90
|
+
except MultipleInvalid as e:
|
|
91
|
+
raise EfaParameterError(f"Invalid parameter(s) detected: {str(e)}")
|
|
78
92
|
|
|
79
|
-
def
|
|
80
|
-
""
|
|
93
|
+
def __str__(self) -> str:
|
|
94
|
+
return f"{self._name}" + self._get_params_as_str()
|
|
81
95
|
|
|
82
|
-
|
|
83
|
-
dict: parameters extended with default values
|
|
96
|
+
def _get_params_as_str(self) -> str:
|
|
84
97
|
"""
|
|
98
|
+
Converts the parameters dictionary to a query string.
|
|
85
99
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
def _get_params_as_str(self) -> str:
|
|
91
|
-
"""Return parameters concatenated with &
|
|
100
|
+
If the parameters dictionary is empty, returns an empty string.
|
|
101
|
+
Otherwise, returns a string starting with '?' followed by the
|
|
102
|
+
parameters in 'key=value' format, joined by '&'.
|
|
92
103
|
|
|
93
104
|
Returns:
|
|
94
|
-
str:
|
|
105
|
+
str: The query string representation of the parameters.
|
|
95
106
|
"""
|
|
96
107
|
if not self._parameters:
|
|
97
108
|
return ""
|
|
98
109
|
|
|
99
|
-
return "
|
|
110
|
+
return "?" + "&".join([f"{k}={str(v)}" for k, v in self._parameters.items()])
|
|
100
111
|
|
|
101
112
|
@abstractmethod
|
|
102
113
|
def parse(self, data: str):
|
|
114
|
+
"""
|
|
115
|
+
Parses the given data.
|
|
116
|
+
|
|
117
|
+
Args:
|
|
118
|
+
data (str): The data to be parsed.
|
|
119
|
+
|
|
120
|
+
Raises:
|
|
121
|
+
NotImplementedError: If the method is not implemented by a subclass.
|
|
122
|
+
"""
|
|
103
123
|
raise NotImplementedError("Abstract method not implemented")
|
|
104
124
|
|
|
105
125
|
@abstractmethod
|
|
106
126
|
def _get_params_schema(self) -> Schema:
|
|
127
|
+
"""
|
|
128
|
+
Retrieve the schema for the parameters.
|
|
129
|
+
|
|
130
|
+
This is an abstract method that should be implemented by subclasses
|
|
131
|
+
to provide the specific schema for the parameters.
|
|
132
|
+
|
|
133
|
+
Returns:
|
|
134
|
+
Schema: The schema for the parameters.
|
|
135
|
+
|
|
136
|
+
Raises:
|
|
137
|
+
NotImplementedError: If the method is not implemented by a subclass.
|
|
138
|
+
"""
|
|
107
139
|
raise NotImplementedError("Abstract method not implemented")
|
|
108
140
|
|
|
109
141
|
@abstractmethod
|
|
110
142
|
def _get_parser(self):
|
|
143
|
+
"""
|
|
144
|
+
Returns the appropriate parser based on the specified format.
|
|
145
|
+
|
|
146
|
+
This method uses a match-case statement to determine which parser to return
|
|
147
|
+
based on the value of the instance variable `self._format`.
|
|
148
|
+
|
|
149
|
+
Returns:
|
|
150
|
+
RapidJsonParser: If the format is "rapidJSON".
|
|
151
|
+
|
|
152
|
+
Raises:
|
|
153
|
+
EfaFormatNotSupported: If the format is not supported.
|
|
154
|
+
"""
|
|
111
155
|
match self._format:
|
|
112
156
|
case "rapidJSON":
|
|
113
157
|
return RapidJsonParser()
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
from voluptuous import Any, Optional, Required, Schema
|
|
4
|
+
|
|
5
|
+
from apyefa.commands.command import Command
|
|
6
|
+
|
|
7
|
+
from ..data_classes import CoordFormat
|
|
8
|
+
|
|
9
|
+
_LOGGER = logging.getLogger(__name__)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class CommandAdditionalInfo(Command):
|
|
13
|
+
def __init__(self, format: str) -> None:
|
|
14
|
+
super().__init__("XML_ADDINFO_REQUEST", format)
|
|
15
|
+
|
|
16
|
+
def parse(self, data: dict):
|
|
17
|
+
data = self._get_parser().parse(data)
|
|
18
|
+
|
|
19
|
+
result = []
|
|
20
|
+
|
|
21
|
+
return result
|
|
22
|
+
|
|
23
|
+
def _get_params_schema(self) -> Schema:
|
|
24
|
+
return Schema(
|
|
25
|
+
{
|
|
26
|
+
Required("outputFormat", default="rapidJSON"): Any("rapidJSON"),
|
|
27
|
+
Required("coordOutputFormat", default="WGS84"): Any(
|
|
28
|
+
*[x.value for x in CoordFormat]
|
|
29
|
+
),
|
|
30
|
+
Optional("filterShowLineList", default="0"): Any("0", "1", 0, 1),
|
|
31
|
+
Optional("filterShowStopList", default="0"): Any("0", "1", 0, 1),
|
|
32
|
+
Optional("filterShowPlaceList", default="0"): Any("0", "1", 0, 1),
|
|
33
|
+
Optional("filterPublished", default="0"): Any("0", "1", 0, 1),
|
|
34
|
+
Optional("filterDateValid"): str,
|
|
35
|
+
Optional("filterDateValidDay"): str,
|
|
36
|
+
Optional("filterDateValidMonth"): str,
|
|
37
|
+
Optional("filterDateValidYear"): str,
|
|
38
|
+
Optional("filterDateValidComponentsActive"): Any("0", "1", 0, 1),
|
|
39
|
+
Optional("filterPublicationStatus"): Any("current", "history"),
|
|
40
|
+
Optional("filterValidIntervalStart"): str,
|
|
41
|
+
Optional("filterValidIntervalEnd"): str,
|
|
42
|
+
Optional("filterOMC"): str,
|
|
43
|
+
Optional("filterValid"): str,
|
|
44
|
+
Optional("filterOMC_PlaceID"): str,
|
|
45
|
+
Optional("filterLineNumberIntervalStart"): str,
|
|
46
|
+
Optional("filterLineNumberIntervalEnd"): str,
|
|
47
|
+
Optional("filterMOTType"): str,
|
|
48
|
+
Optional("filterPNLineDir"): str,
|
|
49
|
+
Optional("filterPNLineSub"): str,
|
|
50
|
+
Optional("itdLPxx_selLine"): str,
|
|
51
|
+
Optional("itdLPxx_selOperator"): str,
|
|
52
|
+
Optional("itdLPxx_selStop"): str,
|
|
53
|
+
Optional("line"): str,
|
|
54
|
+
Optional("filterInfoID"): str,
|
|
55
|
+
Optional("filterInfoType"): str,
|
|
56
|
+
Optional("filterPriority"): str,
|
|
57
|
+
Optional("filterProviderCode"): str,
|
|
58
|
+
Optional("filterSourceSystemName"): str,
|
|
59
|
+
}
|
|
60
|
+
)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
from voluptuous import Any, Match, Optional, Required, Schema
|
|
4
|
+
|
|
5
|
+
from apyefa.commands.command import Command
|
|
6
|
+
from apyefa.data_classes import CoordFormat, Location
|
|
7
|
+
|
|
8
|
+
_LOGGER = logging.getLogger(__name__)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class CommandCoord(Command):
|
|
12
|
+
def __init__(self, format: str) -> None:
|
|
13
|
+
super().__init__("XML_COORD_REQUEST", format)
|
|
14
|
+
|
|
15
|
+
def parse(self, data: dict):
|
|
16
|
+
data = self._get_parser().parse(data)
|
|
17
|
+
|
|
18
|
+
locations = data.get("locations", [])
|
|
19
|
+
|
|
20
|
+
_LOGGER.info(f"{len(locations)} location(s) found")
|
|
21
|
+
|
|
22
|
+
result = []
|
|
23
|
+
|
|
24
|
+
for loc in locations:
|
|
25
|
+
result.append(Location.from_dict(loc))
|
|
26
|
+
|
|
27
|
+
return result
|
|
28
|
+
|
|
29
|
+
def _get_params_schema(self) -> Schema:
|
|
30
|
+
return Schema(
|
|
31
|
+
{
|
|
32
|
+
Required("outputFormat", default="rapidJSON"): Any("rapidJSON"),
|
|
33
|
+
Required("coordOutputFormat", default=CoordFormat.WGS84.value): Any(
|
|
34
|
+
*[x.value for x in CoordFormat]
|
|
35
|
+
),
|
|
36
|
+
Optional("boundingBox"): Any("0", "1", 0, 1),
|
|
37
|
+
Optional("boundingBoxLU"): str,
|
|
38
|
+
Optional("boundingBoxRL"): str,
|
|
39
|
+
Optional("inclFilter"): Any("0", "1", 0, 1),
|
|
40
|
+
Optional(Match(r"^type_\d{1,}$")): str,
|
|
41
|
+
Optional(Match(r"^radius_\d{1,}$")): int,
|
|
42
|
+
Optional("coord"): str,
|
|
43
|
+
Optional("max"): int,
|
|
44
|
+
},
|
|
45
|
+
)
|
|
@@ -9,10 +9,8 @@ _LOGGER = logging.getLogger(__name__)
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class CommandDepartures(Command):
|
|
12
|
-
def __init__(self,
|
|
13
|
-
super().__init__("XML_DM_REQUEST",
|
|
14
|
-
|
|
15
|
-
self.add_param("name_dm", stop)
|
|
12
|
+
def __init__(self, format: str) -> None:
|
|
13
|
+
super().__init__("XML_DM_REQUEST", format)
|
|
16
14
|
|
|
17
15
|
def parse(self, data: dict):
|
|
18
16
|
data = self._get_parser().parse(data)
|
|
@@ -32,9 +30,10 @@ class CommandDepartures(Command):
|
|
|
32
30
|
return Schema(
|
|
33
31
|
{
|
|
34
32
|
Required("outputFormat", default="rapidJSON"): Any("rapidJSON"),
|
|
35
|
-
Required("coordOutputFormat", default=
|
|
33
|
+
Required("coordOutputFormat", default=CoordFormat.WGS84.value): Any(
|
|
36
34
|
*[x.value for x in CoordFormat]
|
|
37
35
|
),
|
|
36
|
+
Required("locationServerActive", default="1"): Any("0", "1", 0, 1),
|
|
38
37
|
Required("name_dm"): str,
|
|
39
38
|
Required("type_dm", default="stop"): Any("any", "stop"),
|
|
40
39
|
Required("mode", default="direct"): Any("any", "direct"),
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
from voluptuous import Any, Optional, Required, Schema
|
|
4
|
+
|
|
5
|
+
from apyefa.commands.command import Command
|
|
6
|
+
from apyefa.data_classes import CoordFormat, Line
|
|
7
|
+
|
|
8
|
+
_LOGGER = logging.getLogger(__name__)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class CommandGeoObject(Command):
|
|
12
|
+
def __init__(self, format: str) -> None:
|
|
13
|
+
super().__init__("XML_GEOOBJECT_REQUEST", format)
|
|
14
|
+
|
|
15
|
+
def parse(self, data: dict):
|
|
16
|
+
data = self._get_parser().parse(data)
|
|
17
|
+
|
|
18
|
+
locations = data.get("transportations", [])
|
|
19
|
+
|
|
20
|
+
_LOGGER.info(f"{len(locations)} location(s) found")
|
|
21
|
+
|
|
22
|
+
result = []
|
|
23
|
+
|
|
24
|
+
for loc in locations:
|
|
25
|
+
result.append(Line.from_dict(loc))
|
|
26
|
+
|
|
27
|
+
return result
|
|
28
|
+
|
|
29
|
+
def _get_params_schema(self) -> Schema:
|
|
30
|
+
return Schema(
|
|
31
|
+
{
|
|
32
|
+
Required("outputFormat", default="rapidJSON"): Any("rapidJSON"),
|
|
33
|
+
Required("coordOutputFormat", default=CoordFormat.WGS84.value): Any(
|
|
34
|
+
*[x.value for x in CoordFormat]
|
|
35
|
+
),
|
|
36
|
+
Required("line"): str,
|
|
37
|
+
Optional("boundingBox"): Any("0", "1", 0, 1),
|
|
38
|
+
Optional("boundingBoxLU"): str,
|
|
39
|
+
Optional("boundingBoxRL"): str,
|
|
40
|
+
Optional("filterDate"): Any("0", "1", 0, 1),
|
|
41
|
+
},
|
|
42
|
+
)
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
from voluptuous import Any, Optional, Range, Required, Schema
|
|
4
|
+
|
|
5
|
+
from apyefa.commands.command import Command
|
|
6
|
+
from apyefa.data_classes import CoordFormat, Line, LineRequestType
|
|
7
|
+
|
|
8
|
+
_LOGGER = logging.getLogger(__name__)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class CommandLineList(Command):
|
|
12
|
+
def __init__(self, format: str) -> None:
|
|
13
|
+
super().__init__("XML_LINELIST_REQUEST", format)
|
|
14
|
+
|
|
15
|
+
def parse(self, data: dict):
|
|
16
|
+
data = self._get_parser().parse(data)
|
|
17
|
+
|
|
18
|
+
lines = data.get("transportations", [])
|
|
19
|
+
|
|
20
|
+
_LOGGER.info(f"{len(lines)} line(s) found")
|
|
21
|
+
|
|
22
|
+
result = []
|
|
23
|
+
|
|
24
|
+
for line in lines:
|
|
25
|
+
result.append(Line.from_dict(line))
|
|
26
|
+
|
|
27
|
+
return result
|
|
28
|
+
|
|
29
|
+
def _get_params_schema(self) -> Schema:
|
|
30
|
+
return Schema(
|
|
31
|
+
{
|
|
32
|
+
Required("outputFormat", default="rapidJSON"): Any("rapidJSON"),
|
|
33
|
+
Required("coordOutputFormat", default=CoordFormat.WGS84.value): Any(
|
|
34
|
+
*[x.value for x in CoordFormat]
|
|
35
|
+
),
|
|
36
|
+
Optional("lineListBranchCode"): str,
|
|
37
|
+
Optional("lineListNetBranchCode"): str,
|
|
38
|
+
Optional("lineListSubnetwork"): str,
|
|
39
|
+
Optional("lineListOMC"): str,
|
|
40
|
+
Optional("lineListMixedLines"): Any("0", "1", 0, 1),
|
|
41
|
+
Optional("mergeDir"): Any("0", "1", 0, 1),
|
|
42
|
+
Optional("lineReqType"): Range(
|
|
43
|
+
min=0, max=sum([x.value for x in LineRequestType])
|
|
44
|
+
),
|
|
45
|
+
}
|
|
46
|
+
)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
from voluptuous import Any, Optional, Required, Schema
|
|
4
|
+
|
|
5
|
+
from apyefa.commands.command import Command
|
|
6
|
+
from apyefa.data_classes import CoordFormat, Location
|
|
7
|
+
|
|
8
|
+
_LOGGER = logging.getLogger(__name__)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class CommandLineStop(Command):
|
|
12
|
+
def __init__(self, format: str) -> None:
|
|
13
|
+
super().__init__("XML_LINESTOP_REQUEST", format)
|
|
14
|
+
|
|
15
|
+
def parse(self, data: dict):
|
|
16
|
+
data = self._get_parser().parse(data)
|
|
17
|
+
|
|
18
|
+
stops = data.get("locationSequence", [])
|
|
19
|
+
|
|
20
|
+
_LOGGER.info(f"{len(stops)} stop(s) found")
|
|
21
|
+
|
|
22
|
+
result = []
|
|
23
|
+
|
|
24
|
+
for stop in stops:
|
|
25
|
+
result.append(Location.from_dict(stop))
|
|
26
|
+
|
|
27
|
+
return result
|
|
28
|
+
|
|
29
|
+
def _get_params_schema(self) -> Schema:
|
|
30
|
+
return Schema(
|
|
31
|
+
{
|
|
32
|
+
Required("outputFormat", default="rapidJSON"): Any("rapidJSON"),
|
|
33
|
+
Required("coordOutputFormat", default=CoordFormat.WGS84.value): Any(
|
|
34
|
+
*[x.value for x in CoordFormat]
|
|
35
|
+
),
|
|
36
|
+
Optional("line"): str,
|
|
37
|
+
Optional("allStopInfo"): Any("0", "1", 0, 1),
|
|
38
|
+
}
|
|
39
|
+
)
|
|
@@ -9,31 +9,20 @@ _LOGGER = logging.getLogger(__name__)
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class CommandServingLines(Command):
|
|
12
|
-
def __init__(self,
|
|
13
|
-
super().__init__("XML_SERVINGLINES_REQUEST",
|
|
14
|
-
|
|
15
|
-
match mode:
|
|
16
|
-
case "odv":
|
|
17
|
-
self.add_param("type_sl", "stopID")
|
|
18
|
-
self.add_param("name_sl", value)
|
|
19
|
-
case "line":
|
|
20
|
-
self.add_param("lineName", value)
|
|
21
|
-
case _:
|
|
22
|
-
raise ValueError(f"Mode {mode} not supported for serving lines")
|
|
23
|
-
|
|
24
|
-
self.add_param("mode", mode)
|
|
12
|
+
def __init__(self, format: str) -> None:
|
|
13
|
+
super().__init__("XML_SERVINGLINES_REQUEST", format)
|
|
25
14
|
|
|
26
15
|
def parse(self, data: dict) -> list[Line]:
|
|
27
16
|
data = self._get_parser().parse(data)
|
|
28
17
|
|
|
29
|
-
|
|
18
|
+
lines = data.get("lines", [])
|
|
30
19
|
|
|
31
|
-
_LOGGER.info(f"{len(
|
|
20
|
+
_LOGGER.info(f"{len(lines)} line(s) found")
|
|
32
21
|
|
|
33
22
|
result = []
|
|
34
23
|
|
|
35
|
-
for
|
|
36
|
-
result.append(Line.from_dict(
|
|
24
|
+
for line in lines:
|
|
25
|
+
result.append(Line.from_dict(line))
|
|
37
26
|
|
|
38
27
|
return result
|
|
39
28
|
|
|
@@ -41,9 +30,10 @@ class CommandServingLines(Command):
|
|
|
41
30
|
return Schema(
|
|
42
31
|
{
|
|
43
32
|
Required("outputFormat", default="rapidJSON"): Any("rapidJSON"),
|
|
44
|
-
Required("coordOutputFormat", default=
|
|
33
|
+
Required("coordOutputFormat", default=CoordFormat.WGS84.value): Any(
|
|
45
34
|
*[x.value for x in CoordFormat]
|
|
46
35
|
),
|
|
36
|
+
Required("locationServerActive", default="1"): Any("0", "1", 0, 1),
|
|
47
37
|
Required("mode", default="line"): Any("odv", "line"),
|
|
48
38
|
# mode 'odv'
|
|
49
39
|
Optional("type_sl"): Any("stopID"),
|
|
@@ -9,11 +9,8 @@ _LOGGER = logging.getLogger(__name__)
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class CommandStopFinder(Command):
|
|
12
|
-
def __init__(self,
|
|
13
|
-
super().__init__("XML_STOPFINDER_REQUEST",
|
|
14
|
-
|
|
15
|
-
self.add_param("type_sf", req_type)
|
|
16
|
-
self.add_param("name_sf", name)
|
|
12
|
+
def __init__(self, format: str) -> None:
|
|
13
|
+
super().__init__("XML_STOPFINDER_REQUEST", format)
|
|
17
14
|
|
|
18
15
|
def parse(self, data: dict) -> list[Location]:
|
|
19
16
|
data = self._get_parser().parse(data)
|
|
@@ -33,11 +30,12 @@ class CommandStopFinder(Command):
|
|
|
33
30
|
return Schema(
|
|
34
31
|
{
|
|
35
32
|
Required("outputFormat", default="rapidJSON"): Any("rapidJSON"),
|
|
36
|
-
Required("coordOutputFormat", default=
|
|
33
|
+
Required("coordOutputFormat", default=CoordFormat.WGS84.value): Any(
|
|
37
34
|
*[x.value for x in CoordFormat]
|
|
38
35
|
),
|
|
39
36
|
Required("type_sf", default="any"): Any("any", "coord"),
|
|
40
37
|
Required("name_sf"): str,
|
|
38
|
+
Required("locationServerActive", default="1"): Any("0", "1", 0, 1),
|
|
41
39
|
Optional("anyMaxSizeHitList"): int,
|
|
42
40
|
Optional("anySigWhenPerfectNoOtherMatches"): Any("0", "1", 0, 1),
|
|
43
41
|
Optional("anyResSort_sf"): str,
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
|
|
3
|
+
from voluptuous import Any, Optional, Required, Schema
|
|
4
|
+
|
|
5
|
+
from apyefa.commands.command import Command
|
|
6
|
+
from apyefa.data_classes import CoordFormat, Location
|
|
7
|
+
|
|
8
|
+
_LOGGER = logging.getLogger(__name__)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class CommandStopList(Command):
|
|
12
|
+
def __init__(self, format: str) -> None:
|
|
13
|
+
super().__init__("XML_STOPLIST_REQUEST", format)
|
|
14
|
+
|
|
15
|
+
def parse(self, data: dict):
|
|
16
|
+
data = self._get_parser().parse(data)
|
|
17
|
+
|
|
18
|
+
locations = data.get("locations", [])
|
|
19
|
+
|
|
20
|
+
_LOGGER.info(f"{len(locations)} location(s) found")
|
|
21
|
+
|
|
22
|
+
result = []
|
|
23
|
+
|
|
24
|
+
for location in locations:
|
|
25
|
+
result.append(Location.from_dict(location))
|
|
26
|
+
|
|
27
|
+
return result
|
|
28
|
+
|
|
29
|
+
def _get_params_schema(self) -> Schema:
|
|
30
|
+
return Schema(
|
|
31
|
+
{
|
|
32
|
+
Required("outputFormat", default="rapidJSON"): Any("rapidJSON"),
|
|
33
|
+
Required("coordOutputFormat", default=CoordFormat.WGS84.value): Any(
|
|
34
|
+
*[x.value for x in CoordFormat]
|
|
35
|
+
),
|
|
36
|
+
Optional("stopListOMC"): str,
|
|
37
|
+
Optional("stopListPlaceId"): str,
|
|
38
|
+
Optional("stopListOMCPlaceId"): str,
|
|
39
|
+
Optional("rTN"): str,
|
|
40
|
+
Optional("stopListSubnetwork"): str,
|
|
41
|
+
Optional("fromstop"): str,
|
|
42
|
+
Optional("tostop"): str,
|
|
43
|
+
Optional("servingLines"): Any("0", "1", 0, 1),
|
|
44
|
+
Optional("servingLinesMOTType"): Any("0", "1", 0, 1),
|
|
45
|
+
Optional("servingLinesMOTTypes"): Any("0", "1", 0, 1),
|
|
46
|
+
Optional("tariffZones"): Any("0", "1", 0, 1),
|
|
47
|
+
}
|
|
48
|
+
)
|
|
@@ -9,8 +9,8 @@ _LOGGER = logging.getLogger(__name__)
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class CommandSystemInfo(Command):
|
|
12
|
-
def __init__(self) -> None:
|
|
13
|
-
super().__init__("XML_SYSTEMINFO_REQUEST",
|
|
12
|
+
def __init__(self, format: str) -> None:
|
|
13
|
+
super().__init__("XML_SYSTEMINFO_REQUEST", format)
|
|
14
14
|
|
|
15
15
|
def parse(self, data: dict) -> SystemInfo:
|
|
16
16
|
_LOGGER.info("Parsing system info response")
|
|
@@ -23,7 +23,7 @@ class CommandSystemInfo(Command):
|
|
|
23
23
|
return Schema(
|
|
24
24
|
{
|
|
25
25
|
Required("outputFormat", default="rapidJSON"): Any("rapidJSON"),
|
|
26
|
-
Optional("coordOutputFormat", default=
|
|
26
|
+
Optional("coordOutputFormat", default=CoordFormat.WGS84.value): Any(
|
|
27
27
|
*[x.value for x in CoordFormat]
|
|
28
28
|
),
|
|
29
29
|
}
|