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

Uploaded CPython 3.9+Windows x86-64

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

Uploaded CPython 3.9+Windows x86

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

File metadata

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

File hashes

Hashes for opening_hours_py-1.0.3.tar.gz
Algorithm Hash digest
SHA256 3ffcb21ee97a92d80d73524b0629f0f3ef7f51d2f785e4b4831dbabc8f414389
MD5 efcf54512afe9334ac4caa39241f381c
BLAKE2b-256 af0ee6f8b1822c2c43e488ac032302a8daf4ec955cfc139aedebf0a0830eaf51

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.3-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 14b8b2985f48f7da076b264e3ef6611cda38766dd651f134d2260b747a9ff264
MD5 8a90109e6f79db993fb2d361c1a361a2
BLAKE2b-256 c9990be73c81d87ae009d4de8ffcba48b760a1d025f9a023c627f8396aeb2119

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.3-cp39-abi3-win32.whl
Algorithm Hash digest
SHA256 efef6a600065c89c89f9f8f88b46151b05d0895899ce6f220f8e93f96c9ccb23
MD5 653e227ccda30104572bab0aa6836887
BLAKE2b-256 227be9d5b8a5095d0401c53247c504835951366d46e93656bc947f15ec6fb149

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.3-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 8546cf81efb60f5de2652eb3f0fc5753b9513868caf27ff370f339affb2c436b
MD5 a74427e7777be02eaecc87c39d24d4b8
BLAKE2b-256 2488509f956d391edd17c657b6e4188596955c0177f8787256933f594c7aef5f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.3-cp39-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 61c4bc0b7fc78501bc4ebacaef7bb7a4e35fb18582d1e068577d433ee3adb5e1
MD5 9e603aef98d7788809fbc9cf0c077c6c
BLAKE2b-256 2afcbca52a4ba83641b6c5dfb3c33ef8509049b685d980e00f52da198eaa1c7d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.3-cp39-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 3b49e57ab5a8c30cb5f9cb91d686739765a119a682a5f60ef759ed1f60523c94
MD5 8e85c0733387dddbc13047c89f00b744
BLAKE2b-256 bd82ec9c28bcafe1a570f66b68d35cfb9bc0769c7a8bb730598b253cadf7d170

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.3-cp39-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 709d8e493d8be7bff3f7192bbb97f71481be715468fa5c056ef2526ba0fc72e1
MD5 20ddbe12ee3088fe2fa16ea0014eb5be
BLAKE2b-256 7462c624ad3cd8b70069b278cd6903c721e43570c7457dcaa7206e33d03fe834

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.3-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 89acb1fa51567cdf7351d3152b79bfedc8ea4b2bf464007141c58263fdece11f
MD5 1597aa796790e783b3d8777af403ce50
BLAKE2b-256 3544c113a0fa81402a255bfae38f1c876495449a80ede9facdfadc5904fc5811

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.3-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 862dda208a0a0205a0f325f960f73524850f4e4d36965558fb1bbac6383712a8
MD5 a91335abc8f9b18cf7ad74fb0bfe63ac
BLAKE2b-256 d7a6f69803b4f1e5deb42ede830ae3f1b332d92f7930f87a8b64545f5970deb9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.3-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 170cd0d82a54bd64b91ef82882fb5d2aa4f6a94ea3377542312316a12e9b86c2
MD5 abaf6559fc9ab0f8ac4f130d07ad2278
BLAKE2b-256 90a1f6782a35e7ff2948b96b6d90ffaff261f5a66017dc38cd1bcde0fee6d540

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.3-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 edc3586c93c3ddfebb1fcf7aef8bb82dfe62ae3b9413c3cf6ef67a156250a52d
MD5 e7afc45c1a3f5e11fbdc4d69e7f854de
BLAKE2b-256 d9d1c180ba708a464c50885263ec73a0215aa4c501aa5458b143dbae39278225

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.3-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6248455ce82ab0dc12d8b18c938d672da0e3c9e56fc7cd4712c8fd609daa4287
MD5 8140f862968882328ecbf9ba1a9ae020
BLAKE2b-256 d3f3a190ca6e43f5dfe9003d805c2110339442bdd5906f9d60d18db5b0da8f92

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.3-cp39-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 6a15a44256183f8badb637051b39d697e7c59b6e01a07b80a63075b89df98bd3
MD5 8eff785318d62635dc6c6187091a40a2
BLAKE2b-256 3dbdcbbeb603a30f5a0c8a6ffd03a7ed8d5793911c090896db7e8e98ca8945c4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.3-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5049925c89862143e6e6872e6a20c5e36cadf3bc298e75b8f9b72002eec90bbb
MD5 0c1a1e029c8c037967eb102aafacf29a
BLAKE2b-256 f1cc85fe89e25a712b03a7e06bdb0f1eee4bc1d1b69bee5ea79a6131c020dec5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-1.0.3-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a4c4b954d9a7ae449917b4018eeed7077db21fee98005123fb8e7344b9848849
MD5 f71a4cc0998132c5bbbdb104192c287c
BLAKE2b-256 39b4c5e9266afe853b531ee6455216c5fc9395256a9f03c6ad41fbd23ed3d281

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