Skip to main content

License: GPL v3 Python 3.7 Release Build

Straeto

Straeto is a Python 3 (>= 3.7) package encapsulating data about buses and bus routes of Strætó bs, an Icelandic municipal bus service.

The data is fetched from an open data file released by Strætó bs called GTFS.zip. This file is large and doesn't change often. Please do not fetch it frequently or frivolously. An interval of at least 24 hours should be more than enough.

Note that the process that fetches the GTFS.zip file must have file create and file write rights on the resources/ subdirectory within the Straeto source package.

Installation

Straeto is a pure-Python package. It is available on PyPi, and can thus be installed by simply typing:

pip install straeto

Usage

Example:

import straeto
# Your location here, as a (lat, lon) tuple
location = straeto._MIDEIND_LOCATION  # Fiskislóð 31, Reykjavík
s = straeto.BusStop.closest_to(location)
print("The bus stop closest to {0} is {1}".format(location, s.name))
# Load the bus schedule for today
schedule = straeto.BusSchedule()
# Your route identifier here
route_id = "14"
# Print the next two arrivals of that route at the closest bus stop
arrivals, arrives = schedule.arrivals(route_id, s, n=2)
if not arrives:
    # This stop is not in the schedule for this route
    print("The bus does not stop at {0}".format(s.name))
else:
    for direction, times in arrivals.items():
        print(
            "Direction {0}: {1}"
            .format(
                direction,
                ", ".join(
                    "{0:02}:{1:02}".format(hms[0], hms[1]) for hms in times
                )
            )
        )

Documentation

This is a beta release and proper documentation has not yet been produced. But the code is fairly self-explanatory; look at the file src/straeto/straeto.py to see the source code for the main classes and some usage examples.

Real-time Data

Optionally, and in addition to static schedule data, this package supports reading real-time data about bus locations from a URL provided by Strætó bs. However, these URLs are not public and you need to sign an agreement with Strætó to get access to the data and obtain your own URL. Once you have your URL, put it in the file config/status_url.txt to enable the Straeto package to fetch real-time data.

Release history

  • Release 1.4.0

    Full type annotations. Python requirement bumped to 3.7.

  • Release 1.3.0

    Added type annotations; fixed Python 3.6 compatibility regression.

  • Release 1.2.0

    Updated and hardened the code that reads Strætó.bs' XML configuration file. Added type annotations.

  • Release 1.1.0

    Added type annotations; modified the BusStop.closest_to() function; updated the default resources files that accompany the Straeto package.

  • Release 1.0.2

    Updated the default resources files that accompany the Straeto package.

  • Release 1.0.1

    Updated the code to reflect a change in the format of the stop_times.txt file, going from 6 fields to 7.

  • Release 1.0.0

    Beta release. Supports downloading and extraction of the GTFS.zip schedule file from the Strætó bs open data URL. Fixes a bug where sequential bus halts with identical time points were not being included in the schedule.

  • Release 0.0.10

    Better support for Windows with explicit specification of UTF-8 encoding for files

This program is copyright © 2023 Miðeind ehf.

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

The full text of the GNU General Public License is available at http://www.gnu.org/licenses/.

No Affiliation

This program and its authors are in no way affiliated with or endorsed by Strætó bs.


If you would like to use this software in ways that are incompatible with the standard GNU GPLv3 license, please contact Miðeind ehf. at mideind@mideind.is to negotiate alternative arrangements.

Metadata

Release files for straeto 1.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for straeto 1.4.1
File Size Uploaded Provenance Actions
straeto-1.4.1.tar.gz 1.2 MB Without provenance Details for straeto-1.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for straeto 1.4.1
File Interpreter ABI Platform Actions
straeto-1.4.1-py2.py3-none-any.whl Python 3, Python 2 none any Details for straeto-1.4.1-py2.py3-none-any.whl

Total release size: 2.5 MB

Release files / straeto-1.4.1.tar.gz

Download URL straeto-1.4.1.tar.gz
Size 1.2 MB
Tags Source
SHA-256 checksum
How to use checksums
b3c382e9edfc1b74ec99bdf4b0d646c115352378fdab5b33ad5aedb8237580b7
BLAKE2b-256 checksum
How to use checksums
cc102cf9bb50aee635c590a255afe703417295bbd66e82a891a6e9926c2d84b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2

Release files / straeto-1.4.1-py2.py3-none-any.whl

Download URL straeto-1.4.1-py2.py3-none-any.whl
Size 1.2 MB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
ba69a29f63d3b656327f47a03fdb28aa1bc4a8639b8d704f27febb9303d0456c
BLAKE2b-256 checksum
How to use checksums
1597d2c0b100c98ca2dfc722e43d45e16b9548782e3134fad5ae36b5cc612254
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.2

Security for straeto 1.4.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page