Skip to main content

A parser and toolkit for the opening_hours in OpenStreetMap written in Rust.

Project description

🐍 Python bindings for OSM Opening Hours

PyPI Doc PyPI - Downloads

Usage

The pre-compiled package is published for Python 3.9 and above and new releases will adapt to officially supported Python versions.

If you want to install this library with older version of Python, you will need the Rust toolchain (rustc and cargo).

Install opening-hours-py from PyPI, for example using pip:

pip install --user opening-hours-py

Then, the main object that you will interact with will be OpeningHours:

from opening_hours import OpeningHours

oh = OpeningHours("Mo-Fr 10:00-18:00; Sa-Su 10:00-12:00")
print("Current status is", oh.state())
print("This will change at", oh.next_change())

# You can also attach a timezone to your expression. If you use timezone-aware
# dates, they will be converted to local time before any computation is done.
from zoneinfo import ZoneInfo
oh = OpeningHours("Mo-Fr 10:00-18:00; Sa-Su 10:00-12:00", timezone=ZoneInfo("Europe/Paris"))

# The timezone can also be infered with coordinates
oh = OpeningHours("Mo-Fr 10:00-18:00; Sa-Su 10:00-12:00", coords=(48.8535, 2.34839))

The API is very similar to Rust API but you can find a Python specific documentation here.

Features

  • 📝 Parsing for OSM opening hours
  • 🧮 Evaluation of state and next change
  • ⏳ Lazy infinite iterator
  • 🌅 Accurate sun events
  • 📅 Embedded public holidays database for many countries (from [nagger])
  • 🌍 Timezone support
  • 🔥 Fast and memory-safe implementation using Rust

Development

To build the library by yourself you will require a recent version of Rust, rustup is usually the recommended tool to manage the installation.

Then you can use poetry to install Python dependencies and run maturin (the building tool used to create the bindings) from a virtualenv.

$ git clone https://github.com/remi-dupre/opening-hours-rs.git
$ cd opening-hours-rs

# Install Python dependancies
$ poetry install

# Enter the virtualenv
$ poetry shell

# Build developpement bindings, add `--release` for an optimized version
$ maturin develop

# Now the library is available as long as you don't leave the virtualenv
$ python
>>> from opening_hours import OpeningHours
>>> oh = OpeningHours("24/7")
>>> oh.state()
"open"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opening_hours_py-0.11.1.tar.gz (410.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

opening_hours_py-0.11.1-cp39-abi3-win_amd64.whl (6.9 MB view details)

Uploaded CPython 3.9+Windows x86-64

opening_hours_py-0.11.1-cp39-abi3-win32.whl (6.8 MB view details)

Uploaded CPython 3.9+Windows x86

opening_hours_py-0.11.1-cp39-abi3-musllinux_1_2_x86_64.whl (7.3 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ x86-64

opening_hours_py-0.11.1-cp39-abi3-musllinux_1_2_i686.whl (7.3 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ i686

opening_hours_py-0.11.1-cp39-abi3-musllinux_1_2_armv7l.whl (7.3 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ ARMv7l

opening_hours_py-0.11.1-cp39-abi3-musllinux_1_2_aarch64.whl (7.3 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ ARM64

opening_hours_py-0.11.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.1 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

opening_hours_py-0.11.1-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (7.2 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ s390x

opening_hours_py-0.11.1-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (7.2 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ppc64le

opening_hours_py-0.11.1-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (7.1 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARMv7l

opening_hours_py-0.11.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (7.1 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ ARM64

opening_hours_py-0.11.1-cp39-abi3-manylinux_2_5_i686.manylinux1_i686.whl (7.1 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.5+ i686

opening_hours_py-0.11.1-cp39-abi3-macosx_11_0_arm64.whl (7.1 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

opening_hours_py-0.11.1-cp39-abi3-macosx_10_12_x86_64.whl (7.0 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file opening_hours_py-0.11.1.tar.gz.

File metadata

  • Download URL: opening_hours_py-0.11.1.tar.gz
  • Upload date:
  • Size: 410.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.8.1

File hashes

Hashes for opening_hours_py-0.11.1.tar.gz
Algorithm Hash digest
SHA256 0e1a297e802421ef4b58222fd64ecf4c9d34e86f3813b7ad29a14d1bf7b83e17
MD5 3e7ed60606fe6f5d3d718be7838640e3
BLAKE2b-256 9f94c9ab0a8d50f0aa5cd2af6ba01411a5ca1603fa82b020621334f599b62df1

See more details on using hashes here.

File details

Details for the file opening_hours_py-0.11.1-cp39-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for opening_hours_py-0.11.1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 668f187179625d7fbe04a675a43701c841ccf376da15c8d4807890d5dc21549e
MD5 857e0ff7229883aa69b14e5311c22a50
BLAKE2b-256 d06eb938f9a41900cec1f0b82f8a7f017100f7a810912d0fa14d224e2ace072b

See more details on using hashes here.

File details

Details for the file opening_hours_py-0.11.1-cp39-abi3-win32.whl.

File metadata

File hashes

Hashes for opening_hours_py-0.11.1-cp39-abi3-win32.whl
Algorithm Hash digest
SHA256 a19e482072913822449de422495fdc3d0351fbdf691391a135f7b3bbcee6101f
MD5 3f8d1f046003d2ae67d0d9ee7b855221
BLAKE2b-256 3273ac60b329d6f3c0bfde18415e32935abae0e0320c588de1d828f2c6b90d7d

See more details on using hashes here.

File details

Details for the file opening_hours_py-0.11.1-cp39-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for opening_hours_py-0.11.1-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 ec13e82babfef5c86ef8a6e6534b259bcc9e4eae1408574f0daccd2103418896
MD5 727d38fd7900a1088649fd1d9f9ec11b
BLAKE2b-256 b1f414be60538d64b596bab7456450d14123dc558a158f2440c39ef2f9020a5b

See more details on using hashes here.

File details

Details for the file opening_hours_py-0.11.1-cp39-abi3-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for opening_hours_py-0.11.1-cp39-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 489345b29ba1a94b29b4eada75b485212ae5f9dd003af70c52c41ba2922531e6
MD5 8395df77470f76e2c84d1f5b426c7c88
BLAKE2b-256 462515490c67c2efd4dfc0e2444dbd1174cfcea64e1b717e15bf3762b2094604

See more details on using hashes here.

File details

Details for the file opening_hours_py-0.11.1-cp39-abi3-musllinux_1_2_armv7l.whl.

File metadata

File hashes

Hashes for opening_hours_py-0.11.1-cp39-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 4cd8d2186f15ce072c542b629d5f3b87e86e72f34f320f915c2b50679172102e
MD5 7bffe47f2011966f3a1bb74d025af060
BLAKE2b-256 6cf86ffca5a7342b7b0141ac2cd503751544f84a293f55a5e4b7bc9205051835

See more details on using hashes here.

File details

Details for the file opening_hours_py-0.11.1-cp39-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for opening_hours_py-0.11.1-cp39-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 8dbc6f4c8956fa84db390410a167d06d7707a51f078356c9a8b579c1207da282
MD5 526f2ff1a40e5abda1c215b088eb7d47
BLAKE2b-256 d4afac3db5c3ef011f0978226937f231a2d97a91345344d1ddd9d12724a0c594

See more details on using hashes here.

File details

Details for the file opening_hours_py-0.11.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for opening_hours_py-0.11.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1c9db7f1e7e3d91f03d7c9f67eb3b4a808a395035f4e8512fdc5d42ac1ab8051
MD5 2cec5d1bbba813830d9eb9746a68d7fc
BLAKE2b-256 42ef301446d1914731cc66c9e6b6ead92c12752a78a5ca39a253c8cd7b5d9a2d

See more details on using hashes here.

File details

Details for the file opening_hours_py-0.11.1-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for opening_hours_py-0.11.1-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 1fa536f4feb2d8e756f52a6ffff59f190e1d3bacc0f706c1b85927a172e0b778
MD5 8bf1eba3038f2c1d4d59be54d7aa9d78
BLAKE2b-256 5b97da542eab4da8286d39aa2edc640130e0007d4311fe53ce1be997254165ba

See more details on using hashes here.

File details

Details for the file opening_hours_py-0.11.1-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for opening_hours_py-0.11.1-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 6076c797329ceb94c7ecf8217ed521d93d6ba127b9475e26b4f44c41334055c5
MD5 c9aee2c9e218e3a26b41053ad3f9446c
BLAKE2b-256 294c5f914bb546f4791ca1119dc1f2553a52174d4857088a889708048149d34f

See more details on using hashes here.

File details

Details for the file opening_hours_py-0.11.1-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for opening_hours_py-0.11.1-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 8b221210235e4e81594148367a764cfa5a75564a3fa91f70cc02b1222014c607
MD5 a5917dcbb3515c79ae11d2b33f464b54
BLAKE2b-256 a439f2f76f4481aa3df8890d74ef1a60cac65665029a026abb6af3a97eb44337

See more details on using hashes here.

File details

Details for the file opening_hours_py-0.11.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for opening_hours_py-0.11.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9fc7faa4a86fa647f8271dd4bcdb532e237c4fbbaac03da3caa4a017072279a4
MD5 a9cabc5317f77f98e43b8e22f33b48b2
BLAKE2b-256 7cbec4d7f08c72989665db9f4e43c952d4cc01f1a6d958d750fed595a14e5656

See more details on using hashes here.

File details

Details for the file opening_hours_py-0.11.1-cp39-abi3-manylinux_2_5_i686.manylinux1_i686.whl.

File metadata

File hashes

Hashes for opening_hours_py-0.11.1-cp39-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 15bb4f31de1104cd1253e8cacfd27ea707b44ac0bca82875709b9e663e6b573f
MD5 fcb7004593464751a9395e124d17fa99
BLAKE2b-256 b1cad700b26b0647a4aec21cd8b969124350bc963845703c7a76c83119f66ca3

See more details on using hashes here.

File details

Details for the file opening_hours_py-0.11.1-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for opening_hours_py-0.11.1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4091fca57a43bea129fd3dde4ec6a81dc8415993d66df0cb06aa0f410175e401
MD5 da3f9b1bc7bfff7d7c1e44c7038a0f08
BLAKE2b-256 f2089d8df5a0a101be27e84fc94abf9cb06298460b29c38fced14556e26029af

See more details on using hashes here.

File details

Details for the file opening_hours_py-0.11.1-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for opening_hours_py-0.11.1-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 8fe3d5d5077e8288515885c8f9b88c26d5c3a5debf1be16ece65b90119ba35bb
MD5 1a78b2cc8458606d0e55d3d299f20e89
BLAKE2b-256 2a283a0a48287fc8d86c983b521421e41fc23f2956da49ffa97d0e48ea96dcbd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page