apyefa 1.1.6__tar.gz
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.
- apyefa-1.1.6/.devcontainer/Dockerfile +16 -0
- apyefa-1.1.6/.devcontainer/devcontainer.json +20 -0
- apyefa-1.1.6/.github/FUNDING.yml +1 -0
- apyefa-1.1.6/.github/dependabot.yml +14 -0
- apyefa-1.1.6/.github/release-drafter.yml +29 -0
- apyefa-1.1.6/.github/workflows/ci.yml +42 -0
- apyefa-1.1.6/.github/workflows/publish.yml +57 -0
- apyefa-1.1.6/.github/workflows/release_drafter.yml +19 -0
- apyefa-1.1.6/.gitignore +55 -0
- apyefa-1.1.6/.vscode/settings.json +20 -0
- apyefa-1.1.6/LICENSE +21 -0
- apyefa-1.1.6/PKG-INFO +100 -0
- apyefa-1.1.6/README.md +80 -0
- apyefa-1.1.6/apyefa/__init__.py +23 -0
- apyefa-1.1.6/apyefa/client.py +718 -0
- apyefa-1.1.6/apyefa/commands/__init__.py +27 -0
- apyefa-1.1.6/apyefa/commands/command.py +165 -0
- apyefa-1.1.6/apyefa/commands/command_add_info.py +55 -0
- apyefa-1.1.6/apyefa/commands/command_coord.py +45 -0
- apyefa-1.1.6/apyefa/commands/command_departures.py +50 -0
- apyefa-1.1.6/apyefa/commands/command_geoobject.py +42 -0
- apyefa-1.1.6/apyefa/commands/command_line_list.py +46 -0
- apyefa-1.1.6/apyefa/commands/command_line_stop.py +39 -0
- apyefa-1.1.6/apyefa/commands/command_serving_lines.py +57 -0
- apyefa-1.1.6/apyefa/commands/command_stop_finder.py +52 -0
- apyefa-1.1.6/apyefa/commands/command_stop_list.py +48 -0
- apyefa-1.1.6/apyefa/commands/command_system_info.py +30 -0
- apyefa-1.1.6/apyefa/commands/command_trip.py +56 -0
- apyefa-1.1.6/apyefa/commands/parsers/__init__.py +0 -0
- apyefa-1.1.6/apyefa/commands/parsers/parser.py +7 -0
- apyefa-1.1.6/apyefa/commands/parsers/rapid_json_parser.py +11 -0
- apyefa-1.1.6/apyefa/commands/parsers/xml_parser.py +6 -0
- apyefa-1.1.6/apyefa/data_classes.py +565 -0
- apyefa-1.1.6/apyefa/exceptions.py +18 -0
- apyefa-1.1.6/apyefa/helpers.py +135 -0
- apyefa-1.1.6/apyefa.egg-info/PKG-INFO +100 -0
- apyefa-1.1.6/apyefa.egg-info/SOURCES.txt +63 -0
- apyefa-1.1.6/apyefa.egg-info/dependency_links.txt +1 -0
- apyefa-1.1.6/apyefa.egg-info/requires.txt +5 -0
- apyefa-1.1.6/apyefa.egg-info/top_level.txt +1 -0
- apyefa-1.1.6/examples.py +32 -0
- apyefa-1.1.6/pyproject.toml +96 -0
- apyefa-1.1.6/setup.cfg +4 -0
- apyefa-1.1.6/tests/conftest.py +7 -0
- apyefa-1.1.6/tests/integration/test_endpoints.py +73 -0
- apyefa-1.1.6/tests/unit/commands/__init__.py +0 -0
- apyefa-1.1.6/tests/unit/commands/parsers/__init__.py +0 -0
- apyefa-1.1.6/tests/unit/commands/parsers/test_json_parser.py +19 -0
- apyefa-1.1.6/tests/unit/commands/parsers/test_xml_parser.py +13 -0
- apyefa-1.1.6/tests/unit/commands/test_cmd.py +161 -0
- apyefa-1.1.6/tests/unit/commands/test_cmd_departures.py +119 -0
- apyefa-1.1.6/tests/unit/commands/test_cmd_line_list.py +94 -0
- apyefa-1.1.6/tests/unit/commands/test_cmd_line_stop.py +83 -0
- apyefa-1.1.6/tests/unit/commands/test_cmd_serving_lines.py +95 -0
- apyefa-1.1.6/tests/unit/commands/test_cmd_stop_finder.py +91 -0
- apyefa-1.1.6/tests/unit/commands/test_cmd_stop_list.py +255 -0
- apyefa-1.1.6/tests/unit/commands/test_cmd_system_info.py +67 -0
- apyefa-1.1.6/tests/unit/data_classes/__init__.py +0 -0
- apyefa-1.1.6/tests/unit/data_classes/test_departure.py +0 -0
- apyefa-1.1.6/tests/unit/data_classes/test_location.py +0 -0
- apyefa-1.1.6/tests/unit/data_classes/test_system_info.py +49 -0
- apyefa-1.1.6/tests/unit/data_classes/test_transportation.py +0 -0
- apyefa-1.1.6/tests/unit/test_client.py +600 -0
- apyefa-1.1.6/tests/unit/test_helpers.py +52 -0
- apyefa-1.1.6/uv.lock +1567 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
ARG PYTHON_VERSION=3.12
|
|
2
|
+
|
|
3
|
+
FROM python:${PYTHON_VERSION}-slim
|
|
4
|
+
|
|
5
|
+
WORKDIR /app
|
|
6
|
+
|
|
7
|
+
COPY . .
|
|
8
|
+
|
|
9
|
+
RUN apt-get update && apt-get install -y git \
|
|
10
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
11
|
+
|
|
12
|
+
RUN pip install --no-cache-dir uv
|
|
13
|
+
|
|
14
|
+
RUN uv sync --frozen --all-groups
|
|
15
|
+
|
|
16
|
+
CMD ["uv", "run", "pytest"]
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Python + uv",
|
|
3
|
+
"build": {
|
|
4
|
+
"dockerfile": "Dockerfile",
|
|
5
|
+
"context": ".."
|
|
6
|
+
},
|
|
7
|
+
|
|
8
|
+
"customizations": {
|
|
9
|
+
"vscode": {
|
|
10
|
+
"extensions": ["ms-python.python", "ms-python.vscode-pylance", "charliermarsh.ruff", "ms-azuretools.vscode-docker"],
|
|
11
|
+
"settings": {
|
|
12
|
+
"python.defaultInterpreterPath": "/usr/local/bin/python",
|
|
13
|
+
"python.analysis.typeCheckingMode": "basic"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
"postCreateCommand": "uv sync --all-groups",
|
|
19
|
+
"remoteUser": "root"
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ko_fi: alexjungnbg
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
- package-ecosystem: github-actions
|
|
4
|
+
directory: "/"
|
|
5
|
+
schedule:
|
|
6
|
+
interval: daily
|
|
7
|
+
- package-ecosystem: pip
|
|
8
|
+
directory: "/.github/workflows"
|
|
9
|
+
schedule:
|
|
10
|
+
interval: daily
|
|
11
|
+
- package-ecosystem: pip
|
|
12
|
+
directory: "/"
|
|
13
|
+
schedule:
|
|
14
|
+
interval: daily
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
categories:
|
|
2
|
+
- title: ":boom: Breaking Changes"
|
|
3
|
+
label: "breaking"
|
|
4
|
+
- title: ":rocket: Features"
|
|
5
|
+
label: "enhancement"
|
|
6
|
+
- title: ":fire: Removals and Deprecations"
|
|
7
|
+
label: "removal"
|
|
8
|
+
- title: ":beetle: Fixes"
|
|
9
|
+
label: "bug"
|
|
10
|
+
- title: ":racehorse: Performance"
|
|
11
|
+
label: "performance"
|
|
12
|
+
- title: ":rotating_light: Testing"
|
|
13
|
+
label: "testing"
|
|
14
|
+
- title: ":construction_worker: Continuous Integration"
|
|
15
|
+
label: "ci"
|
|
16
|
+
- title: ":books: Documentation"
|
|
17
|
+
label: "documentation"
|
|
18
|
+
- title: ":hammer: Refactoring"
|
|
19
|
+
label: "refactoring"
|
|
20
|
+
- title: ":lipstick: Style"
|
|
21
|
+
label: "style"
|
|
22
|
+
- title: ":package: Dependencies"
|
|
23
|
+
labels:
|
|
24
|
+
- "dependencies"
|
|
25
|
+
- "build"
|
|
26
|
+
template: |
|
|
27
|
+
## Changes
|
|
28
|
+
|
|
29
|
+
$CHANGES
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
name: Lint, check format and tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: ["**"]
|
|
6
|
+
tags-ignore: ["v*"]
|
|
7
|
+
pull_request:
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
strategy:
|
|
14
|
+
fail-fast: false
|
|
15
|
+
matrix:
|
|
16
|
+
python-version: ["3.11", "3.12", "3.13"]
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v6
|
|
20
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
21
|
+
uses: actions/setup-python@v6
|
|
22
|
+
with:
|
|
23
|
+
python-version: ${{ matrix.python-version }}
|
|
24
|
+
|
|
25
|
+
- name: Display Python version
|
|
26
|
+
run: python -c "import sys; print(sys.version)"
|
|
27
|
+
|
|
28
|
+
- name: Build Docker image
|
|
29
|
+
run: |
|
|
30
|
+
docker build \
|
|
31
|
+
--build-arg PYTHON_VERSION=${{ matrix.python-version }} \
|
|
32
|
+
-t apyefa:${{ matrix.python-version }} -f .devcontainer/Dockerfile .
|
|
33
|
+
|
|
34
|
+
- name: Lint code
|
|
35
|
+
run: docker run --rm apyefa:${{ matrix.python-version }} uv run ruff check .
|
|
36
|
+
|
|
37
|
+
- name: Check code formatting
|
|
38
|
+
run: docker run --rm apyefa:${{ matrix.python-version }} uv run black --check .
|
|
39
|
+
|
|
40
|
+
- name: Run tests
|
|
41
|
+
run: |
|
|
42
|
+
docker run --rm apyefa:${{ matrix.python-version }} uv run pytest .
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
name: Build and publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
publish:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v6
|
|
14
|
+
with:
|
|
15
|
+
fetch-depth: 0
|
|
16
|
+
|
|
17
|
+
- name: Build Docker image
|
|
18
|
+
run: |
|
|
19
|
+
docker build \
|
|
20
|
+
-t apyefa:release -f .devcontainer/Dockerfile .
|
|
21
|
+
|
|
22
|
+
- name: Build package
|
|
23
|
+
run: |
|
|
24
|
+
docker run --rm \
|
|
25
|
+
-v $PWD/dist:/app/dist \
|
|
26
|
+
apyefa:release \
|
|
27
|
+
uv run python -m build
|
|
28
|
+
|
|
29
|
+
- name: Set up Python
|
|
30
|
+
uses: actions/setup-python@v6
|
|
31
|
+
with:
|
|
32
|
+
python-version: "3.12"
|
|
33
|
+
|
|
34
|
+
- name: Install twine tool
|
|
35
|
+
run: |
|
|
36
|
+
python -m pip install --upgrade pip
|
|
37
|
+
pip install twine
|
|
38
|
+
|
|
39
|
+
- name: Decide publish target
|
|
40
|
+
id: target
|
|
41
|
+
run: |
|
|
42
|
+
if [[ "${GITHUB_REF_NAME}" == *dev* ]]; then
|
|
43
|
+
echo "url=https://test.pypi.org/legacy/" >> $GITHUB_OUTPUT
|
|
44
|
+
echo "token=TEST_PYPI_API_TOKEN" >> $GITHUB_OUTPUT
|
|
45
|
+
else
|
|
46
|
+
echo "url=https://upload.pypi.org/legacy/" >> $GITHUB_OUTPUT
|
|
47
|
+
echo "token=PYPI_API_TOKEN" >> $GITHUB_OUTPUT
|
|
48
|
+
fi
|
|
49
|
+
|
|
50
|
+
- name: Publish to (Test) PyPI
|
|
51
|
+
env:
|
|
52
|
+
TWINE_USERNAME: __token__
|
|
53
|
+
TWINE_PASSWORD: ${{ secrets[steps.target.outputs.token] }}
|
|
54
|
+
run: |
|
|
55
|
+
twine upload \
|
|
56
|
+
--repository-url ${{ steps.target.outputs.url }} \
|
|
57
|
+
dist/*
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
name: Draft a release note
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- main
|
|
6
|
+
- master
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
draft_release:
|
|
13
|
+
name: Release Drafter
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- name: Run release-drafter
|
|
17
|
+
uses: release-drafter/release-drafter@v6
|
|
18
|
+
env:
|
|
19
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
apyefa-1.1.6/.gitignore
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# developing script
|
|
2
|
+
script.py
|
|
3
|
+
|
|
4
|
+
# Byte-compiled / optimized / DLL files
|
|
5
|
+
__pycache__/
|
|
6
|
+
*.py[cod]
|
|
7
|
+
*$py.class
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# Installer logs
|
|
31
|
+
pip-log.txt
|
|
32
|
+
pip-delete-this-directory.txt
|
|
33
|
+
|
|
34
|
+
# Unit test / coverage reports
|
|
35
|
+
htmlcov/
|
|
36
|
+
.tox/
|
|
37
|
+
.nox/
|
|
38
|
+
.coverage
|
|
39
|
+
.coverage.*
|
|
40
|
+
.cache
|
|
41
|
+
nosetests.xml
|
|
42
|
+
coverage.xml
|
|
43
|
+
*.cover
|
|
44
|
+
*.py,cover
|
|
45
|
+
.hypothesis/
|
|
46
|
+
.pytest_cache/
|
|
47
|
+
cover/
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
51
|
+
__pypackages__/
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
# Environments
|
|
55
|
+
.venv
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"python.testing.pytestArgs": [
|
|
3
|
+
"tests"
|
|
4
|
+
],
|
|
5
|
+
"python.testing.unittestEnabled": false,
|
|
6
|
+
"python.testing.pytestEnabled": true,
|
|
7
|
+
"editor.codeActionsOnSave":
|
|
8
|
+
{
|
|
9
|
+
"source.organizeImports": "always",
|
|
10
|
+
},
|
|
11
|
+
"editor.formatOnSave": true,
|
|
12
|
+
"[json]": {
|
|
13
|
+
"editor.defaultFormatter": "vscode.json-language-features"
|
|
14
|
+
},
|
|
15
|
+
"editor.defaultFormatter": "charliermarsh.ruff",
|
|
16
|
+
"notebook.defaultFormatter": "charliermarsh.ruff",
|
|
17
|
+
"[python]": {
|
|
18
|
+
"editor.defaultFormatter": "charliermarsh.ruff"
|
|
19
|
+
}
|
|
20
|
+
}
|
apyefa-1.1.6/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Alex Jung
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
apyefa-1.1.6/PKG-INFO
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: apyefa
|
|
3
|
+
Version: 1.1.6
|
|
4
|
+
Summary: Python API for EFA(Elektronische Fahrplanauskunft) async requests
|
|
5
|
+
Author-email: Alex Jung <jungdevelop@gmail.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/alex-jung/apyefa
|
|
7
|
+
Project-URL: Documentation, https://github.com/alex-jung/apyefa
|
|
8
|
+
Project-URL: Repository, https://github.com/alex-jung/apyefa
|
|
9
|
+
Project-URL: Issues, https://github.com/alex-jung/apyefa/issues
|
|
10
|
+
Keywords: efa,public transport,traffic
|
|
11
|
+
Requires-Python: >=3.11
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: aiohttp>=3.11.2
|
|
15
|
+
Requires-Dist: voluptuous>=0.15.2
|
|
16
|
+
Requires-Dist: tzdata>=2024.2
|
|
17
|
+
Requires-Dist: black>=25.12.0
|
|
18
|
+
Requires-Dist: twine>=6.2.0
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# apyefa
|
|
22
|
+
[](https://github.com/alex-jung/apyefa/actions/workflows/ci.yml)
|
|
23
|
+
[](https://opensource.org/licenses/MIT)
|
|
24
|
+
|
|
25
|
+
# Intro
|
|
26
|
+
**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.
|
|
27
|
+
|
|
28
|
+
# Installation
|
|
29
|
+
You only need to install the **apyefa** package, for example using pip:
|
|
30
|
+
``` bash
|
|
31
|
+
pip install apyefa
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
# Restrictions
|
|
35
|
+
Currently the package supports only endpoints using [RapidJSON](https://rapidjson.org/) format. To check whether the endpoint supports this format, please call:
|
|
36
|
+
``` bash
|
|
37
|
+
curl <EFA API URL>/XML_SYSTEMINFO_REQUEST?outputFormat=rapidJSON
|
|
38
|
+
e.g. curl https://bahnland-bayern.de/efa/XML_SYSTEMINFO_REQUEST?outputFormat=rapidJSON
|
|
39
|
+
```
|
|
40
|
+
If API's answer looks like this, endpoint supports rapidJSON:
|
|
41
|
+
```
|
|
42
|
+
{"version":"10.6.21.17","ptKernel":{"appVersion":"10.6.22.28 build 16.12.2024 11:14:57","dataFormat":"EFA10_06_01","dataBuild":"2024-12-31T00:54:55Z"},"validity":{"from":"2024-12-15","to":"2025-06-14"}}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
# Development setup
|
|
46
|
+
Create and activate virtual environment. Then install dependencies required by `apefa` package.
|
|
47
|
+
``` bash
|
|
48
|
+
python3 -m venv .venv
|
|
49
|
+
source .venv/bin/activate
|
|
50
|
+
pip install .
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
# apyefa functions
|
|
54
|
+
|Function Name |Description|
|
|
55
|
+
|----------------------------------------------------|-----------|
|
|
56
|
+
|[info()](https://github.com/alex-jung/apyefa/wiki/info)|Provides EFA endpoint system information|
|
|
57
|
+
|[locations_by_name()](https://github.com/alex-jung/apyefa/wiki/locations_by_name)|Search for locations by name with optional filters|
|
|
58
|
+
|[locations_by_coord()](https://github.com/alex-jung/apyefa/wiki/locations_by_coord)|Search for locations by coordinates|
|
|
59
|
+
|[list_lines()](https://github.com/alex-jung/apyefa/wiki/list_lines)|Retrieves a list of lines|
|
|
60
|
+
|[list_stops()](https://github.com/alex-jung/apyefa/wiki/list_stops)|Retrieves a list of stops|
|
|
61
|
+
|[trip()](https://github.com/alex-jung/apyefa/wiki/trip)|Calculates a trip between an origin and a destination locations|
|
|
62
|
+
|[departures_by_location()](https://github.com/alex-jung/apyefa/wiki/departures_by_location)|Fetches departures for a given location|
|
|
63
|
+
|[lines_by_name()](https://github.com/alex-jung/apyefa/wiki/lines_by_name)|Fetches lines by name|
|
|
64
|
+
|[lines_by_location()](https://github.com/alex-jung/apyefa/wiki/lines_by_location)|Fetches lines for a specific location|
|
|
65
|
+
|[line_stops()](https://github.com/alex-jung/apyefa/wiki/line_stops)|Retrieves the stops for a given line|
|
|
66
|
+
|[coord_bounding_box()](https://github.com/alex-jung/apyefa/wiki/coord_bounding_box)|Requests locations within a bounding box|
|
|
67
|
+
|[coord_radial()](https://github.com/alex-jung/apyefa/wiki/coord_radial)|Requests locations within a radius|
|
|
68
|
+
|[geo_object()](https://github.com/alex-jung/apyefa/wiki/geo_object)|Generates a sequence of coordinates and all passed stops of a provided line|
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
# Example
|
|
72
|
+
``` python
|
|
73
|
+
import asyncio
|
|
74
|
+
from apyefa import EfaClient
|
|
75
|
+
from apyefa.data_classes import (
|
|
76
|
+
Location,
|
|
77
|
+
LocationFilter,
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
async def async_info(client: EfaClient):
|
|
81
|
+
info = await client.info()
|
|
82
|
+
print(info)
|
|
83
|
+
|
|
84
|
+
async def async_location_by_name(client: EfaClient):
|
|
85
|
+
stops: list[Location] = await client.locations_by_name(
|
|
86
|
+
"Plärrer", filters=[LocationFilter.STOPS], limit=20
|
|
87
|
+
)
|
|
88
|
+
for s in stops:
|
|
89
|
+
print(s)
|
|
90
|
+
|
|
91
|
+
async def main():
|
|
92
|
+
async with EfaClient("https://bahnland-bayern.de/efa/") as client:
|
|
93
|
+
await asyncio.gather(
|
|
94
|
+
async_info(client),
|
|
95
|
+
async_location_by_name(client),
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
if __name__ == "__main__":
|
|
99
|
+
asyncio.run(main())
|
|
100
|
+
```
|
apyefa-1.1.6/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# apyefa
|
|
2
|
+
[](https://github.com/alex-jung/apyefa/actions/workflows/ci.yml)
|
|
3
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
|
+
|
|
5
|
+
# Intro
|
|
6
|
+
**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.
|
|
7
|
+
|
|
8
|
+
# Installation
|
|
9
|
+
You only need to install the **apyefa** package, for example using pip:
|
|
10
|
+
``` bash
|
|
11
|
+
pip install apyefa
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
# Restrictions
|
|
15
|
+
Currently the package supports only endpoints using [RapidJSON](https://rapidjson.org/) format. To check whether the endpoint supports this format, please call:
|
|
16
|
+
``` bash
|
|
17
|
+
curl <EFA API URL>/XML_SYSTEMINFO_REQUEST?outputFormat=rapidJSON
|
|
18
|
+
e.g. curl https://bahnland-bayern.de/efa/XML_SYSTEMINFO_REQUEST?outputFormat=rapidJSON
|
|
19
|
+
```
|
|
20
|
+
If API's answer looks like this, endpoint supports rapidJSON:
|
|
21
|
+
```
|
|
22
|
+
{"version":"10.6.21.17","ptKernel":{"appVersion":"10.6.22.28 build 16.12.2024 11:14:57","dataFormat":"EFA10_06_01","dataBuild":"2024-12-31T00:54:55Z"},"validity":{"from":"2024-12-15","to":"2025-06-14"}}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
# Development setup
|
|
26
|
+
Create and activate virtual environment. Then install dependencies required by `apefa` package.
|
|
27
|
+
``` bash
|
|
28
|
+
python3 -m venv .venv
|
|
29
|
+
source .venv/bin/activate
|
|
30
|
+
pip install .
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
# apyefa functions
|
|
34
|
+
|Function Name |Description|
|
|
35
|
+
|----------------------------------------------------|-----------|
|
|
36
|
+
|[info()](https://github.com/alex-jung/apyefa/wiki/info)|Provides EFA endpoint system information|
|
|
37
|
+
|[locations_by_name()](https://github.com/alex-jung/apyefa/wiki/locations_by_name)|Search for locations by name with optional filters|
|
|
38
|
+
|[locations_by_coord()](https://github.com/alex-jung/apyefa/wiki/locations_by_coord)|Search for locations by coordinates|
|
|
39
|
+
|[list_lines()](https://github.com/alex-jung/apyefa/wiki/list_lines)|Retrieves a list of lines|
|
|
40
|
+
|[list_stops()](https://github.com/alex-jung/apyefa/wiki/list_stops)|Retrieves a list of stops|
|
|
41
|
+
|[trip()](https://github.com/alex-jung/apyefa/wiki/trip)|Calculates a trip between an origin and a destination locations|
|
|
42
|
+
|[departures_by_location()](https://github.com/alex-jung/apyefa/wiki/departures_by_location)|Fetches departures for a given location|
|
|
43
|
+
|[lines_by_name()](https://github.com/alex-jung/apyefa/wiki/lines_by_name)|Fetches lines by name|
|
|
44
|
+
|[lines_by_location()](https://github.com/alex-jung/apyefa/wiki/lines_by_location)|Fetches lines for a specific location|
|
|
45
|
+
|[line_stops()](https://github.com/alex-jung/apyefa/wiki/line_stops)|Retrieves the stops for a given line|
|
|
46
|
+
|[coord_bounding_box()](https://github.com/alex-jung/apyefa/wiki/coord_bounding_box)|Requests locations within a bounding box|
|
|
47
|
+
|[coord_radial()](https://github.com/alex-jung/apyefa/wiki/coord_radial)|Requests locations within a radius|
|
|
48
|
+
|[geo_object()](https://github.com/alex-jung/apyefa/wiki/geo_object)|Generates a sequence of coordinates and all passed stops of a provided line|
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
# Example
|
|
52
|
+
``` python
|
|
53
|
+
import asyncio
|
|
54
|
+
from apyefa import EfaClient
|
|
55
|
+
from apyefa.data_classes import (
|
|
56
|
+
Location,
|
|
57
|
+
LocationFilter,
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
async def async_info(client: EfaClient):
|
|
61
|
+
info = await client.info()
|
|
62
|
+
print(info)
|
|
63
|
+
|
|
64
|
+
async def async_location_by_name(client: EfaClient):
|
|
65
|
+
stops: list[Location] = await client.locations_by_name(
|
|
66
|
+
"Plärrer", filters=[LocationFilter.STOPS], limit=20
|
|
67
|
+
)
|
|
68
|
+
for s in stops:
|
|
69
|
+
print(s)
|
|
70
|
+
|
|
71
|
+
async def main():
|
|
72
|
+
async with EfaClient("https://bahnland-bayern.de/efa/") as client:
|
|
73
|
+
await asyncio.gather(
|
|
74
|
+
async_info(client),
|
|
75
|
+
async_location_by_name(client),
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
if __name__ == "__main__":
|
|
79
|
+
asyncio.run(main())
|
|
80
|
+
```
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from apyefa.client import EfaClient
|
|
2
|
+
from apyefa.data_classes import (
|
|
3
|
+
Departure,
|
|
4
|
+
Line,
|
|
5
|
+
LineRequestType,
|
|
6
|
+
Location,
|
|
7
|
+
LocationFilter,
|
|
8
|
+
LocationType,
|
|
9
|
+
SystemInfo,
|
|
10
|
+
TransportType,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
"LocationFilter",
|
|
15
|
+
"Location",
|
|
16
|
+
"LineRequestType",
|
|
17
|
+
"LocationType",
|
|
18
|
+
"Departure",
|
|
19
|
+
"SystemInfo",
|
|
20
|
+
"Line",
|
|
21
|
+
"TransportType",
|
|
22
|
+
"EfaClient",
|
|
23
|
+
]
|