apyefa 0.0.1__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.

@@ -0,0 +1,413 @@
1
+ Metadata-Version: 2.1
2
+ Name: apyefa
3
+ Version: 0.0.1
4
+ Summary: Python API for EFA(Elektronische Fahrplanauskunft) async requests
5
+ Author-email: Alex Jung <jungdevelop@gmail.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2024 Alex Jung
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+ Project-URL: Homepage, https://github.com/alex-jung/apyefa
28
+ Project-URL: Documentation, https://github.com/alex-jung/apyefa
29
+ Project-URL: Repository, https://github.com/alex-jung/apyefa
30
+ Project-URL: Issues, https://github.com/alex-jung/apyefa/issues
31
+ Keywords: efa,vgn,gtfs,public transport,traffic
32
+ Requires-Python: >=3.11
33
+ Description-Content-Type: text/markdown
34
+ License-File: LICENSE
35
+ Requires-Dist: aiohttp==3.11.7
36
+ Requires-Dist: voluptuous==0.15.2
37
+ Requires-Dist: tzdata==2024.2
38
+ Provides-Extra: tests
39
+ Requires-Dist: coverage>=5.0.3; extra == "tests"
40
+ Requires-Dist: pytest-cov; extra == "tests"
41
+ Requires-Dist: pytest; extra == "tests"
42
+ Requires-Dist: pytest-asyncio==0.24.0; extra == "tests"
43
+ Requires-Dist: pytest-benchmark[histogram]>=3.2.1; extra == "tests"
44
+ Requires-Dist: requests==2.32.3; extra == "tests"
45
+
46
+ # apyefa
47
+ [![Python package](https://github.com/alex-jung/apyefa/actions/workflows/python-package.yml/badge.svg)](https://github.com/alex-jung/apyefa/actions/workflows/python-package.yml)
48
+ [![License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
49
+ # Intro
50
+ **apyefa** is a python package used to asynchronously fetch public transit routing data via EFA interfaces like [efa.vgn](https://efa.vgn.de/vgnExt_oeffi/"). It can request itineraries for Bus/Trams/Subways etc. connections and return data in a human and machine readable format.
51
+ # Installation
52
+ You only need to install the **apyefa** package, for example using pip:
53
+ ``` bash
54
+ pip install apyefa
55
+ ```
56
+
57
+ # Restrictions
58
+ Currently the package supports only endpoints using [RapidJSON](https://rapidjson.org/) format. To check whether the endpoint supports this format, please call:
59
+ ``` bash
60
+ To describe(!)
61
+ ```
62
+
63
+ # Development setup
64
+ Create and activate virtual environment. Then install dependencies required by `apefa` package.
65
+ ``` bash
66
+ python3 -m venv .venv
67
+ source .venv/bin/activate
68
+ pip install .
69
+ ```
70
+
71
+ # EfaClient functions
72
+ |Function name |Implementation |Documentation |
73
+ |----------------------------------------------------|------------------|------------------|
74
+ |[info()](#info) |:white_check_mark:|:white_check_mark:|
75
+ |[locations_by_name()](#locations_by_name) |:white_check_mark:|:white_check_mark:|
76
+ |[location_by_coord()](#locations_by_coord) |:white_check_mark:|:white_check_mark:|
77
+ |[trip()](#trip) |:x: |:x: |
78
+ |[departures_by_location()](#departures_by_location) |:white_check_mark:|:white_check_mark:|
79
+ |[lines_by_name()](#lines_by_name) |:white_check_mark:|:white_check_mark:|
80
+ |[lines_by_location()](#lines_by_location) |:white_check_mark:|:white_check_mark:|
81
+ |[locations_by_line()](#locations_by_line) |:x: |:x: |
82
+ |[coords()](#coords) |:x: |:x: |
83
+ |[geo_object()](#geo_object) |:x: |:x: |
84
+ |[trip_stop_time()](#trip_stop_time) |:x: |:x: |
85
+ |[stop_seq_coord()](#stop_seq_coord) |:x: |:x: |
86
+ |[map_route()](#map_route) |:x: |:x: |
87
+ |[add_info()](#add_info) |:x: |:x: |
88
+ |[stop_list()](#stop_list) |:x: |:x: |
89
+ |[line_list()](#line_list) |:x: |:x: |
90
+
91
+ ## info()
92
+ Provides end API system information.
93
+
94
+ ### Arguments
95
+ None
96
+
97
+ ### Return value
98
+ |Type|Description|
99
+ |----|-----------|
100
+ |[SystemInfo](#systeminfo)|System information object|
101
+
102
+ ### Example request
103
+ ``` python
104
+ from apyefa import EfaClient, SystemInfo
105
+ from pprint import pprint
106
+
107
+ async with EfaClient("https://efa.vgn.de/vgnExt_oeffi/") as client:
108
+ info: SystemInfo = await client.info()
109
+
110
+ pprint(info)
111
+
112
+ # OUTPUT:
113
+ # SystemInfo(version='10.6.14.22',
114
+ # app_version='10.4.30.6 build 16.09.2024 01:30:57',
115
+ # data_format='EFA10_04_00',
116
+ # data_build='2024-12-02T16:53:02Z',
117
+ # valid_from=datetime.date(2024, 11, 1),
118
+ # valid_to=datetime.date(2025, 12, 13))
119
+ ```
120
+
121
+ ## locations_by_name()
122
+ Find localities by name or unique id.
123
+
124
+ ### Arguments
125
+ |Name |Type |Required|Description|
126
+ |---------|--------------------|--------|-----------|
127
+ |name |str |required|Name or id ID of locality to search for|
128
+ |filters |list[[LocationFilter](#locationfilter)]|optional|The localition search may be limited by certain types of objects using this parameter. Default value is `[]`|
129
+ |limit |int |optional|Max size of returned list. Default value is `30`|
130
+
131
+ ### Return value
132
+ |Type|Description|
133
+ |----|-----------|
134
+ |list[[Location](#location)]|List of locations found py provided name sorted by match quality|
135
+
136
+
137
+ ### Examples
138
+ 1. Search for all localities contain name `Plärrer`
139
+ ``` python
140
+ from apyefa import EfaClient, Location, LocationFilter
141
+
142
+ async with EfaClient("https://efa.vgn.de/vgnExt_oeffi/") as client:
143
+ locations: list[Location] = await client.locations_by_name("Plärrer")
144
+
145
+ print(f"Found {len(locations)} location(s)")
146
+ print(location[0].id)
147
+ print(location[0].name)
148
+ print(location[0].loc_type)
149
+ # OUTPUT:
150
+ # Found 20 location(s)
151
+ # de:09574:7132
152
+ # Hersbruck, Plärrer
153
+ # <LocationType.STOP: 'stop'>
154
+ ```
155
+ 2. Search for POIs and Addresses with name `Plärrer`
156
+ ``` python
157
+ async with EfaClient("https://efa.vgn.de/vgnExt_oeffi/") as client:
158
+ locations: list[Location] = await client.locations_by_name("Plärrer", filters=[LocationFilter.ADDRESSES, LocationFilter.POIS])
159
+
160
+ print(f"Found {len(locations)} location(s)")
161
+ print(location[0].id)
162
+ print(location[0].name)
163
+ print(location[0].loc_type)
164
+
165
+ # OUTPUT:
166
+ # Found 4 location(s)
167
+ # poiID:1000029001:9564000:-1:N-PLärrer:Nürnberg:N-PLärrer:ANY:POI:4431934:680416:NAV4:vgn
168
+ # Nürnberg, N-PLärrer
169
+ # <LocationType.POI: 'poi'>
170
+ ```
171
+ 3. Search by `stop id`
172
+ ``` python
173
+ async with EfaClient("https://efa.vgn.de/vgnExt_oeffi/") as client:
174
+ locations: list[Location] = await client.locations_by_name("de:09564:704")
175
+
176
+ print(f"Found {len(locations)} location(s)")
177
+ print(location[0].id)
178
+ print(location[0].name)
179
+ print(location[0].loc_type)
180
+ # OUTPUT:
181
+ # Found 1 location(s)
182
+ # de:09564:704
183
+ # Nürnberg, N-PLärrer
184
+ # <LocationType.STOP: 'stop'>
185
+ ```
186
+
187
+ ## locations_by_coord()
188
+ Find localities by coordinates.
189
+
190
+ > :x: Currently test endpoint does not sent any answers for this request
191
+
192
+ ### Arguments
193
+ |Arguments|Type |Required|Description|
194
+ |---------|--------------------|--------|-----------|
195
+ |coord_x |float |required|X-coordinate|
196
+ |coord_y |float |required|Y-coordinate|
197
+ |format |[CoordFormat](#coordformat)|optional|Coordinates format used for request|
198
+ |limit |int |optional|Max size of returned list. Default value is `10`|
199
+
200
+ ### Return value
201
+ |Type|Description|
202
+ |----|-----------|
203
+ |list[[Location](#location)]|List of locations found py provided name sorted by match quality|
204
+
205
+ ## trip()
206
+
207
+ ## departures_by_location()
208
+ Find all departures for a specific location
209
+
210
+ ### Arguments
211
+ |Arguments|Type |Required|Description|
212
+ |---------|--------------------|--------|-----------|
213
+ |stop |[Location](#location) \| str |required|Location for which the departures are being sought|
214
+ |limit |int |optional|Max size of returned list. Default value is `40`|
215
+ |date |str |optional|Date/time for which the departures are sought in format "YYYYMMDD hh:mm", "YYYYMMDD" or "mm:hh". Default value is `empty`|
216
+
217
+ ### Return value
218
+ |Type|Description|
219
+ |----|-----------|
220
+ |list[[Departure](#departure)]|List of departures sorted by departure time|
221
+
222
+ ### Examples
223
+ ``` python
224
+ from apyefa import EfaClient, Departure
225
+
226
+ async with EfaClient("https://efa.vgn.de/vgnExt_oeffi/") as client:
227
+ departures: list[Departure] = await client.departures_by_location("de:09564:704", limit=3, date="22:13")
228
+
229
+ print(f"Found {len(departures)} departure(s)")
230
+ print(location[0].line_name)
231
+ print(location[0].route)
232
+ print(location[0].transport)
233
+ print(location[0].planned_time)
234
+ # OUTPUT:
235
+ # Found 3 departure(s)
236
+ # U3
237
+ # Nordwestring - Hauptbahnhof - Plärrer - Großreuth bei Schweinau
238
+ # <TransportType.SUBWAY: 2>
239
+ # datetime.datetime(2024, 12, 7, 22, 16, tzinfo=zoneinfo.ZoneInfo(key='Europe/Berlin'))
240
+ ```
241
+
242
+ ## lines_by_name()
243
+ Find lines by name.
244
+
245
+ ### Arguments
246
+ |Arguments|Type |Required|Description|
247
+ |---------|--------------------|--------|-----------|
248
+ |name |str |required|Name of the line to search. e.g. `U1` or `67`|
249
+
250
+ ### Return value
251
+ |Type|Description|
252
+ |----|-----------|
253
+ |list[[Line](#line)]|List of lines found for provided name|
254
+
255
+ > NOTE: The attribute `origin` of returned `line` objects is None
256
+
257
+ ### Examples
258
+ ``` python
259
+ async with EfaClient("https://efa.vgn.de/vgnExt_oeffi/") as client:
260
+ lines: list[Line] = await client.lines_by_name("U1")
261
+
262
+ print(f"Found {len(lines)} line(s)")
263
+ print(f"id : {lines[0].id}")
264
+ print(f"name : {lines[0].name}")
265
+ print(f"description: {lines[0].description}")
266
+ print(f"product : {lines[0].product}")
267
+
268
+ # OUTPUT:
269
+ # Found 4 line(s)
270
+ # id : vgn:11001: :H:j24
271
+ # name : U1
272
+ # description: Fürth Hardhöhe - Nürnberg Plärrer - Hauptbahnhof - Langwasser Süd
273
+ # product : <TransportType.SUBWAY: 2>
274
+ ```
275
+
276
+ ## lines_by_location()
277
+ Find lines pass provided location.
278
+
279
+ ### Arguments
280
+ |Arguments|Type |Required|Description|
281
+ |---------|--------------------|--------|-----------|
282
+ |location |str \| [Location](#location) |required|The location passed by searched line(s)|
283
+
284
+ ### Return value
285
+ |Type|Description|
286
+ |----|-----------|
287
+ |list[[Line](#line)]|List of lines found for provided location|
288
+
289
+ > The attribute `origin` of returned `line` objects is None
290
+
291
+ ### Examples
292
+ ``` python
293
+ async with EfaClient("https://efa.vgn.de/vgnExt_oeffi/") as client:
294
+ lines: list[Line] = await client.lines_by_location("de:09564:704")
295
+
296
+ print(f"Found {len(lines)} line(s)")
297
+ print(f"id : {lines[0].id}")
298
+ print(f"name : {lines[0].name}")
299
+ print(f"description: {lines[0].description}")
300
+ print(f"product : {lines[0].product}")
301
+
302
+ # OUTPUT:
303
+ # Found 10 line(s)
304
+ # id : vgn:33283: :H:j24
305
+ # name : 283
306
+ # description: Hugenottenplatz - St. Johann - Dechsendorfer Weiher
307
+ # product : <TransportType.BUS: 5>
308
+ ```
309
+
310
+ ## coords()
311
+ ## geo_object()
312
+ ## trip_stop_time()
313
+ ## stop_seq_coord()
314
+ ## map_route()
315
+ ## add_info()
316
+ ## stop_list()
317
+ ## line_list()
318
+
319
+ # Data Classes
320
+ ## SystemInfo
321
+ |Attribute |Type|Description |
322
+ |------------|----|------------------------ |
323
+ |version |str |API internal information|
324
+ |app_version |str |API internal information |
325
+ |data_format |str |API internal information |
326
+ |data_build |str |API internal information |
327
+ |valid_from |date|Start validity date |
328
+ |valid_to |date|End validity date |
329
+
330
+ ## Location
331
+ |Attribute |Type |Description |
332
+ |-----------------|-------------------|-------------|
333
+ |name |str |Name of location e.g. `Nürnberg, Nordostbahnhof`|
334
+ |loc_type |[LocationType](#locationtype)|Type of location e.g. `STOP` or `POI`|
335
+ |id |str |Location unique id|
336
+ |coord |list[int] |Location coordinates|
337
+ |transports |list[[TransportType](#transporttype)]|Transport type(s) this location pass|
338
+ |parent |[Location](#location) \| None|Parent location|
339
+ |stops |list[[Location](#location)]|Location with type `STOP` assigned to this location|
340
+ |properties |dict |API internal information|
341
+
342
+ ## Departure
343
+ |Attribute |Type|Description |
344
+ |---------------|----|------------------------|
345
+ |location |[Location](#location) |Location of departure|
346
+ |line_name |str |Line name e.g. `U3`|
347
+ |route |str |The complete route name from origin to destination stops e.g. `Nordwestring - Hauptbahnhof - Plärrer - Großreuth bei Schweinau`|
348
+ |origin |[Location](#location)|Origin location|
349
+ |destination |[Location](#location)|Destination location|
350
+ |transport |[TransportType](#transporttype)|Transport type e.g. `Bus` or `Subway`|
351
+ |planned_time |datetime|Planned departure time|
352
+ |estimated_time |datetime \| None|Estimated departure time(will be provided by endpoits supporting real time mode)|
353
+ |infos |list[dict] \| None|List of ICS messages|
354
+
355
+ ## Line
356
+ |Attribute |Type|Description |
357
+ |------------|----|------------------------ |
358
+ |id |str |Line id |
359
+ |name |str |Line name |
360
+ |description |str |Route name |
361
+ |product |[TransportType](#transporttype) |Type of transportation. Bus, Subway etc.|
362
+ |destination |[Location](#location)|Line destination location|
363
+ |origin |[Location](#location) \| None|Line start location|
364
+ |properties |dict|Additional properties |
365
+
366
+ # Enums
367
+ ## TransportType
368
+ ```python
369
+ class TransportType(IntEnum):
370
+ RAIL = 0
371
+ SUBURBAN = 1
372
+ SUBWAY = 2
373
+ CITY_RAIL = 3
374
+ TRAM = 4
375
+ BUS = 5
376
+ RBUS = 6
377
+ EXPRESS_BUS = 7
378
+ CABLE_TRAM = 8
379
+ FERRY = 9
380
+ AST = 10 # Anruf-Sammel-Taxi
381
+ ```
382
+
383
+ ## CoordFormat
384
+ ```python
385
+ class CoordFormat(StrEnum):
386
+ WGS84 = "WGS84 [dd.ddddd]"
387
+ ```
388
+
389
+ ## LocationFilter
390
+ ```python
391
+ class LocationFilter(IntEnum):
392
+ NO_FILTER = 0
393
+ LOCATIONS = 1
394
+ STOPS = 2
395
+ STREETS = 4
396
+ ADDRESSES = 8
397
+ INTERSACTIONS = 16
398
+ POIS = 32
399
+ POST_CODES = 64
400
+ ```
401
+
402
+ ## LocationType
403
+ ```python
404
+ class LocationType(StrEnum):
405
+ STOP = "stop"
406
+ POI = "poi"
407
+ ADDRESS = "address"
408
+ STREET = "street"
409
+ LOCALITY = "locality"
410
+ SUBURB = "suburb"
411
+ PLATFORM = "platform"
412
+ UNKNOWN = "unknown"
413
+ ```
@@ -0,0 +1,21 @@
1
+ apyefa/__init__.py,sha256=kohSwa1VlugPyxKa0QZqQFwRi4hIGrKFd74W7NDgunA,342
2
+ apyefa/client.py,sha256=mxlxxBMEBRkklWhhbujvN5HpL8QWllSRFwIhkICcmQI,6591
3
+ apyefa/data_classes.py,sha256=ZZfP3CAATiSYCt2AJy3Hw6vPr4Rc9TmH8UU0r0-bzwI,10195
4
+ apyefa/exceptions.py,sha256=Vhc8FEtI1xSxbVRLFXd3BlNTekY2w3byEvd3Jhhg8h4,240
5
+ apyefa/helpers.py,sha256=EJyj-Pw3xDrn8WKGbpfqbnaUZjHtVrE2A2LYpTkACps,1695
6
+ apyefa/commands/__init__.py,sha256=kC7Zr8IcahAN8xEOytDUS6WCADQ5oe_nqDIPAjlzxy4,425
7
+ apyefa/commands/command.py,sha256=wq3rEaYd3NUpkNqo2sX3Yw9-lcRerp8scAy2SVpx1hs,3577
8
+ apyefa/commands/command_departures.py,sha256=kHOyxxSHn7F7ClAV1fQdl1O4cOVRs6a60pkqc8-r_9o,1736
9
+ apyefa/commands/command_serving_lines.py,sha256=C8PrMVWCp71fyPzvsTYMmSaYORs60yUNdEShXEawrK0,2021
10
+ apyefa/commands/command_stop_finder.py,sha256=oDCbjVoQVK_ARDEdmHXuaUJ-IJA0P6f99cVDRS2hqT8,1688
11
+ apyefa/commands/command_system_info.py,sha256=0bQ0oYbp7FFqPA1b5RgaxANm9-BYlN5KiwRILCCuDVY,783
12
+ apyefa/commands/command_trip.py,sha256=kOlchWyBRlvWBqwjqpx130VXEh5kly6KMSv_pgCBljs,1095
13
+ apyefa/commands/parsers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
+ apyefa/commands/parsers/parser.py,sha256=1PSlLpfYrNeKRTpvCcYsCzAKlNrs0oHvSN7zpF4Xcs8,140
15
+ apyefa/commands/parsers/rapid_json_parser.py,sha256=UMexRiMKkJLcK5EEj80B6RYkWBuR8ZWD3YpeGa0J3lQ,212
16
+ apyefa/commands/parsers/xml_parser.py,sha256=ru52QtBP68KoTZ8OgjFWrLy-PD4_j1miY8Zv5umNSE8,151
17
+ apyefa-0.0.1.dist-info/LICENSE,sha256=C2Gdvb1B39BeEP-RGqVd7w6j94GnJo4gnYyiC_l3SFQ,1066
18
+ apyefa-0.0.1.dist-info/METADATA,sha256=Dnau_LJIBxJKkVcZoMSx-0R3iuXtDKOXemmYDQQT72Y,15624
19
+ apyefa-0.0.1.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
20
+ apyefa-0.0.1.dist-info/top_level.txt,sha256=b9VSv2S7lxdaypCumxO92IEQFpJdFuB8vQs03j5gZxY,7
21
+ apyefa-0.0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (75.6.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ apyefa