Giter Site home page Giter Site logo

zaanposni / vvspy Goto Github PK

View Code? Open in Web Editor NEW
32.0 1.0 2.0 590 KB

simple python module for the VVS and SSB API (Verkehrsverbund Stuttgart)

Home Page: https://vvspy.readthedocs.io/en/latest/

License: MIT License

Python 99.88% Batchfile 0.05% Shell 0.06%
vvs vvs-api stuttgart wrapper python-library efa json rest python vvspy

vvspy's People

Contributors

arpiix avatar mhorst00 avatar monkmitrad avatar zaanposni avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

vvspy's Issues

[Feature] Add more tests

Summarize the feature
Currently, this project's test coverage is only 60%. Especially get_depatures(), get_trips, and get_arrivals() needs to be tested. Additionally, all the data classes should be tested as well.

Example of the feature
None

Additional context
None

release library

after #5, #6, #7 do:

  • bump version to 1.0.0
  • set status to Development Status :: 5 - Production/Stable

[Feature] Add logging package

Summarize the feature
To easier determine errors, it would be handy if a logging package would be used. For that, I recommend Loguru.

Example of the feature
Loguru enables the developer to just import from loguru import logger and then use logging levels like debug, info, and error. In comparison to the default logger, Loguru logs are already nicely formatted.

Additional context
As an alternative, the built-in logging package could be used.

missing delay data

Describe the bug
A clear and concise description of what the bug is.

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Code fragment
Let us see the important code sample that fails.

Additional context
Add any other context about the problem here.

[Feature] Add Codecov Reports

Summarize the feature
To ensure the functionality, the test coverage should be at least 80%. I recommend using Codecov.

Additional context
Using pytest, pytest-cov, and GitHub Actions, this can be easily achieved. An example configuration can be found here.

[Feature] Add a package manager and `pyproject.toml`

Summarize the feature
The current setup with setup.py and all the other settings files is not quite convenient. Additionally, the packages within the requierements.txt are not correctly checked for compatibility. For that, I recommend using Poetry or Pipenv.

Further, I recommend switching most of the configurations to the pyproject.toml (docs).

Example of the feature
Using Poetry, it is possible to easily manage packages using poetry add and poetry install. It is also possible to define different groups like dev or docs so that you can exclude not necessary packages.

Additional context
None

Filter canceled trains

Hi,
I'm using VVSPY since 1 year as HomaAssistant integration and I'm very happy. I'm requesting all departures for station 'Universität' every 2 mins.
On Thursday, 16.11.2023 the S-Bahn did not operate at all in the morning due to union strike. My request with vvspy received still all S-Bahn trains - with zero delay :-), which was obviousely wrong.
The VVS website did not show the S-Bahn trains.
Is there an additional filter, i can apply for canceled trains?

Kind Regards & Thanks for your great work!
Ralf

[BUG] get_trips triggers an exception when connections do not have a duration set

Describe the bug
The method get_trips triggers an exception upon retrieving a trip that contains a connection that does not have the connection.duration attribute set.

Apparently, the VVS API does not set the duration property in case a connection takes less than a minute, i.e. the duration would be 0. This is at least what I assume to be reason for not adding the duration.

Expected behavior
The request should not fail. If no duration is given, it probably is 0 and thus does not need to be part of the final sum.

Proof of Concept
The following request is one that triggers the exception. One part of the trip contains a connection with only one stop, taking less than a minute.

from vvspy import get_trips
from datetime import datetime

trip = get_trips("de:08111:341", "de:08111:6118", trip_date=datetime(2022, 8, 1, 10, 15, 0, 0))
print(trip)

Code fragment

The problematic code can be found in https://github.com/zaanposni/vvspy/blob/master/vvspy/obj/trip.py#L33:

    def __init__(self, **kwargs):
        self.connections = []
        for connection in kwargs.get("legs", []):
            self.connections.append(Connection(**connection))

        self.duration = sum([x.duration for x in self.connections])

Suggestion
It has to be checked whether the duration attribute exists. If it does not exist, (I assume that) it is equal to 0 and therefore can be left out.

        self.duration = sum([x.duration for x in self.connections if x.duration])

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.