Skip to main content

CzPubTran

A Python package to rertrieve realtime information about public transit in CZ by calling CHAPS REST API.

Main purpose at the moment is to feed a sensor in Home-Assistant

Install

pip install czpubtran

Example usage

import asyncio
import logging
import aiohttp
from datetime import datetime, time
from czpubtran.api import czpubtran

logging.basicConfig(level=logging.ERROR)

async def test():
    session = aiohttp.ClientSession(raise_for_status=True)
    bus = czpubtran(session, '')

    timetables = await bus.async_list_combination_ids()
    print("Listing available timetables (Combination IDs)")
    print(timetables)

    print('------------------------------------------------')

    await bus.async_find_connection('Namesti Republiky', 'Chodov', 'ABCz')
    print(f'First connection from {bus.origin} to {bus.destination} using timetable {bus.combination_id}:')
    print(f'Departure: {bus.departure} line {bus.line}')
    print(f'Duration: {bus.duration}')
    print('Connections:')
    for i, description in [(0, '1st connection'), (1, '2nd connection')]:
        print(f'{description}:')
        for detail in bus.connection_detail[i]:
            print(
                f"line {detail['line']} "
                f"at {detail['depTime']} "
                f"from {detail['depStation']} "
                f"-> {detail['arrStation']} "
                f"{detail['arrTime']} "
                f"(delay: {detail['delay']} min)")

    print('------------------------------------------------')

    await bus.async_find_connection('Namesti Republiky', 'Chodov', 'ABCz', '23:20')
    print(f'Scheduled connection from {bus.origin} to {bus.destination} at {bus.start_time}:')
    print(f'Departure: {bus.departure} line {bus.line}')
    print(f'Duration: {bus.duration}')
    print('Connections:')
    for i, description in [(0, '1st connection'), (1, '2nd connection')]:
        print(f'{description}:')
        for detail in bus.connection_detail[i]:
            print(
                f"line {detail['line']} "
                f"at {detail['depTime']} "
                f"from {detail['depStation']} "
                f"-> {detail['arrStation']} "
                f"{detail['arrTime']} "
                f"(delay: {detail['delay']} min)")

    await session.close()

asyncio.run(test())

Metadata

Release files for czpubtran 0.2.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 czpubtran 0.2.1
File Size Uploaded Provenance Actions
czpubtran-0.2.1.tar.gz 5.5 kB Without provenance Details for czpubtran-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for czpubtran 0.2.1
File Interpreter ABI Platform Actions
czpubtran-0.2.1-py3-none-any.whl Python 3 none any Details for czpubtran-0.2.1-py3-none-any.whl

Total release size: 11.5 kB

Release files / czpubtran-0.2.1.tar.gz

Download URL czpubtran-0.2.1.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
47fd7c6895821b81f97f5a6e0f18467eedbb42b2f50c500a55bd91e5e5c5d9fb
BLAKE2b-256 checksum
How to use checksums
ff0a2914ff988d6293d9068892f92ddd263666f985def20fcda3e05d3d231fb0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.0

Release files / czpubtran-0.2.1-py3-none-any.whl

Download URL czpubtran-0.2.1-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6e77b65f5867467503d13af4d6901e9969ec204349bac4698d1bc61f7c431956
BLAKE2b-256 checksum
How to use checksums
790ca8d6a769edc83ddf01e9c9118e9ca5677ab77919d3a6d5b658f0bf7913e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.0.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.8.0

Security for czpubtran 0.2.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