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-1.0.0.tar.gz (411.0 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.0-cp39-abi3-win_amd64.whl (6.9 MB view details)

Uploaded CPython 3.9+Windows x86-64

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

Uploaded CPython 3.9+Windows x86

opening_hours_py-1.0.0-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.0-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.0-cp39-abi3-musllinux_1_2_armv7l.whl (7.3 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ ARMv7l

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

File metadata

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

File hashes

Hashes for opening_hours_py-1.0.0.tar.gz
Algorithm Hash digest
SHA256 dcb6e90ec343a09ccc74e9c2a83e5c45798bd2e4bc610c8182da9ffbe0fea84e
MD5 5e3e6083b653fcb0be08b2dff83e9146
BLAKE2b-256 a6cd7b9197f32a54095d57519cabbf72ff89576a9d80d2d2f828cef7268cc9f4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 9f63a3660be9d9e9aacab7d6588e0ae7fe63f311da183de3d29c6f30e9d58e45
MD5 8e5b3f65674f19cbf81001a098a74caf
BLAKE2b-256 0b0437000cc4379f942b1f9a98e7320e2f4b5ecff8503877159accfac06c0bed

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.0-cp39-abi3-win32.whl
Algorithm Hash digest
SHA256 109d4381b1e940867d5d75f70f9f60bb8d6400fa9a7cd5792ce17e9a42805166
MD5 dc4e85e4259daf90e2b545345b9fdfcd
BLAKE2b-256 d3aa4ee357e3b691ceb7a75a1265303407c830804f67e4959d8f7e800ca6be6d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.0-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 b79ee9312aba64effbcf9f689e4d0b0f742be07a66e79615307e024ae964eaef
MD5 940e2bcf692f100c9b78eeac165bf96d
BLAKE2b-256 5de09071f5628d7c05dfdb622874c3c45e1d4abd39aa1c66565e35c25c2c7c32

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.0-cp39-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 aed0013ab87d21c804b4b40beaf52d1bc3e22cf2e97c2a0b0f6c8b695d505d0f
MD5 b31bf9dfecc7c2ad3ca55cf3f6a8d488
BLAKE2b-256 882e02bc171c424a527d52d1dcd66e9eeb493fc0c4f2cbd82a05bdb34555dce2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.0-cp39-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 55a768090c94f0d325af434aba7b42a1ea11126e9f50fee55c74a4cd425c6eb4
MD5 800733702fd19521401169683ee68296
BLAKE2b-256 8245efdb9f47c5dee35c8052323b1f08f3be83a2118a35d7e3d34f9099109341

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.0-cp39-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 888c81e37a83afb3ecf9e0a4763a2082e673d2ed1bb8266e5a53a9238c295dcf
MD5 52ff061c38d114321d409b403e080196
BLAKE2b-256 8229ccc0ef6b1aa66e54367b2647b7edae2fe1e879e7f2092067ce796316a823

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e3fa8cb82a170e5570afabc5dbac884ecf952d302fba77268dc4108d4835b888
MD5 1c8f9fcd37ce95fc96cbcc869084549c
BLAKE2b-256 ade7cb597bff30b5bc0125334ec86fdf602ab2abbefe35401cc6de3f845f9c67

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.0-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 e74fa245dc9c45db879377cc15738361ee2cdf4200545b4183f244c24f9e5809
MD5 8522f06951867ba8b5c6b9d75d8569a4
BLAKE2b-256 517c64363f402ac2cc42b19494f8f4508540c372e15746375a68668bdad627ef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.0-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 331b5bc690e6413c9a98516f6387d5992273968ac27f6b5e7963c0e2ae8c58e9
MD5 6dc0ec6d25972e7d9c003fea8623aa92
BLAKE2b-256 485f73571dd5175c0705094fc1b1e27d9c70df34d0f48ed0f9dbc1251ef69c99

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.0-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 477a938963a5e666d9820e000828cf6e4a42a0fafb78631bc5df126dd8087a46
MD5 7e195021b430229fd2f1c8de26cf1a3e
BLAKE2b-256 de758a6ad4a410bc16e9c680348088b8e81ace9b838f56a6d8b7fd622761bef3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4bfbe8def5fc99e15c325bbf461297297d0c56751cce10b42048d6615aef7395
MD5 0b96699123dee52c93de675fbf3fdc96
BLAKE2b-256 562b82c582dc3567e33cdaa975899f98769c94c37e912a62c022245a79c3c3da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.0-cp39-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 6feeff703fccb9d81d0f624c68d5902d2d7fef4aeff21cbddae712769721b180
MD5 747db31aaed008ef44acf15a60fd7b31
BLAKE2b-256 68659db6b3b8d9e09101b297e65c75a7f1e7d93662ef22c3129dfd3c15c9a247

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 da80e012b2d57ad0dc7b842379daaf4a72a345ad327477961a1d4dd52f82eb53
MD5 369236292ab97c39f4259074f56afe09
BLAKE2b-256 c16ee87084c17d62088ec545254603394a08e6595a97cdb9fa91d9170559362d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f7561e3cfd805ff318d8234aeaec02b527a88890d0c999709f7b5a11cef1f8ea
MD5 09d1248de0880f941a944b54eb0706fb
BLAKE2b-256 073a23e676ea49d99c3febd05638e33d651f2800a346e8ab9f42da8ea70acd7c

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