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 nager)
  • 🌍 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-1.0.2.tar.gz (415.9 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-1.0.2-cp39-abi3-win_amd64.whl (6.9 MB view details)

Uploaded CPython 3.9+Windows x86-64

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

Uploaded CPython 3.9+Windows x86

opening_hours_py-1.0.2-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-1.0.2-cp39-abi3-musllinux_1_2_i686.whl (7.3 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ i686

opening_hours_py-1.0.2-cp39-abi3-musllinux_1_2_armv7l.whl (7.4 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ ARMv7l

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

Uploaded CPython 3.9+musllinux: musl 1.2+ ARM64

opening_hours_py-1.0.2-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-1.0.2-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-1.0.2-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-1.0.2-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-1.0.2-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-1.0.2-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-1.0.2-cp39-abi3-macosx_11_0_arm64.whl (7.1 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

opening_hours_py-1.0.2-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-1.0.2.tar.gz.

File metadata

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

File hashes

Hashes for opening_hours_py-1.0.2.tar.gz
Algorithm Hash digest
SHA256 3dd6d9cf0be40a3a5c8d36e1c03255610548f71871f82c9f54b219582cc18ef5
MD5 ebf5ab1a6096a04f87e17e5759499c07
BLAKE2b-256 a802b98a0717b59d7ec17d522f5eea1c069916c6343e23deb0bef858953d8d29

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.2-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 6eb8e346c99f43ab61a34de9ad272be7b33c69a0e9a26e207e552374ed784541
MD5 21af052744c72580aee3868378dc8afd
BLAKE2b-256 655faf3ebeba038688e43af34068478ffe4f12159dfe4d1a624510a34e61c325

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.2-cp39-abi3-win32.whl
Algorithm Hash digest
SHA256 b39b2c0bea26d0bf4a4cdac51b51498b4a50f26c52d8d50f5778122ed9b1c800
MD5 9c7da1e254481411030a7f7656ef4f9b
BLAKE2b-256 377567b6a3cc78f9e91623eb43ebc822734876c589d62c98f44fd3e59ee79456

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.2-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d8b0592abccc5c0b973de8147927cac32f683390c5b8d6491050a95f4f3aaead
MD5 64b0d8aacfc65044e204d3f374eef09d
BLAKE2b-256 84c45bb45d5d78b4611b3d4457154b3094e1bb5658f010614d788225d7697094

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.2-cp39-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 69eb1cf9714df984f40fceb109b230978baa4f1b4f143876e87f42942941b999
MD5 befb0d5b888bbb148064f6972109ba39
BLAKE2b-256 991834ec1551b52c73f780fc67aa152f615c658a05fe23f6ee8391325d2e5df4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.2-cp39-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 10e6a26085b165ef611fdc6addce6e6f3f10d9434e83d89fb5cb700c917c3e15
MD5 0d82df814573170d8cca5142685888bb
BLAKE2b-256 8f23aea5f5c804e41da177da024e6e379b86aaa344e699fb3d4659e46e53385c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.2-cp39-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 f876fd5986fe5a561bdd48dc3dde0d6586da8d6af6710faf8acfb4b49912936a
MD5 a9f9d5402954e7120b87631504fe2aef
BLAKE2b-256 8997debd92388a50a11b5c3ac14ab512a864fb1545c5a5b7be5e6cf3d75deaa4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.2-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dd951ee5f5373f58b71c306835f9892eb554e77a8cf72956b950ac9a98bc73a8
MD5 58e8a0cdcda2c36ebd5b6a4bfa58f2b3
BLAKE2b-256 2f7a67674f70c21d969c9bcf400d5ffac06f507686286c90171572993ae04d3a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.2-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 746099a652df9a1ca8f7ef48c4efad9c23bfd98f222c4cd644d5fac1b4b0ea62
MD5 c99171fe9b550ccb7d961041af4b7815
BLAKE2b-256 945f5ed40c854a470126692a220937b02f51e12099fc0e1fb44effc6e7fa35b6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.2-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 e56d321dd30a9534359b20fd9aa66372dc2b0c0081744616b42f3d94e1170cb1
MD5 5f0750d7dc1f32782a58d74ba932a200
BLAKE2b-256 a43555c7d34dfb3b993eba0398ac18ac196fe646d0d0f8179c8665623836cc25

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.2-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 1b3478e652bb3e2d8bd1c726ec903fff80e8c758fdced866e48fb002b334ae4e
MD5 af7f5a190a96865499e4eb4c0a582a18
BLAKE2b-256 c3b515abc3fd253f57bc9739eb674f7d66369d4cc3a8fef9332af53207f79935

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.2-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 41ca347cf8f1a1f13f59ffeb87d3e567703ce13f4f7e21d070d5daad8e28660b
MD5 bf94c104156585d8601fe32731cdc92c
BLAKE2b-256 7f0b41d58cb5faa7879b4a9e4eae855c8b193abe7eda89078f38d4a1411779bb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.2-cp39-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 2b662de3b3de96fcdeb6f51d454a254abf797d5ed0aa5eafea50e31db39d77c6
MD5 1f92c616bc8cfec7fcaca046709be209
BLAKE2b-256 fc81e8821eedfea108cf7c7d8a65626f4d9e9d772313416d81e67d186d57a984

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.2-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0f2cf9c7b503814ead28ad71db3b5f0d6d7f8f1a667404f7756b48bcaa6f3da0
MD5 2fdc28f5182c55192148c4be4b8d11ef
BLAKE2b-256 21ed1708e47bdacf538c47d09168b9b4e8e3e5b85d33bb5118a0ccc2bb426a70

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.2-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 15adb9503ba7cf0b6385d1627615903d899c5d3fd55ef9b209f9ff00e9acee6d
MD5 0ed4bfe0b0e27a26f33eaa1d58c7830e
BLAKE2b-256 bc948197cdfc5b651e1514e09d79882c602259e694fc47bdba21641725adb3e1

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