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.10.0.tar.gz (408.2 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.10.0-cp39-abi3-win_amd64.whl (6.8 MB view details)

Uploaded CPython 3.9+Windows x86-64

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

Uploaded CPython 3.9+Windows x86

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

Uploaded CPython 3.9+macOS 11.0+ ARM64

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

File metadata

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

File hashes

Hashes for opening_hours_py-0.10.0.tar.gz
Algorithm Hash digest
SHA256 b0fb1c6a330d6c6d386b54839e11b913a27d46d59d7a1ae25ef4fb42a767699a
MD5 d64e4679bf4a0aa918db2fd1fbf6a13c
BLAKE2b-256 af68db22585f3dabb798c99b7e0c212e137e5e2372b10a71c4c637c4b0c16b56

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.10.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1e1522039fd5fbbdf6956319454e99d4113a501c4f5b7051925d69baeb2a348a
MD5 819159e0efde474c2ba6d7640f03ac4c
BLAKE2b-256 8cc8a855609c1f8e67f415bd3e965d4637107020ce53c86a46a747c76522811d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.10.0-cp39-abi3-win32.whl
Algorithm Hash digest
SHA256 2d85992311a0f41d5b0927296b345cb748eef4553a431b0f42c02467c699de90
MD5 f5c64eb4b5bdd59afe373fc584b93cc6
BLAKE2b-256 98ae3b339c04466c4bebe032bb1a478ba3503f800123f4498c748a874dd3e0f0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.10.0-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 8909b4e40b152b4066480e752f54c8fdd5cd1ff63502632f17e5107c16566804
MD5 2c9e7bced1ba54e2dfe54dbfd7fef019
BLAKE2b-256 1e5586a4ceb62a1991ecf49c6127e7efe1dbd2946c2669588f197599a2186428

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.10.0-cp39-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 d318273105a402bcb1369992d361411a28fd967b936f8ccbb25e4214bee17736
MD5 c4729eb4294267e2942c21cacf08d7ec
BLAKE2b-256 2185ef8369950f5e07ba0aedd42351ce99454b441f149081fa65624d08bd3402

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.10.0-cp39-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 4b33dfffedf80b908f88e917c6a0b8af2d82111011eb435b8ccdafa29dfb4049
MD5 b12ff9a6b68b7930ca9ddc2094686986
BLAKE2b-256 167c0d408644e481faefed25825262dfcbd8961be264d72b46d2575087c9efee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.10.0-cp39-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 a6afbe9a30ca403d416ee30b3628e61d4108ed808a0e4f81bf784c5b8622593c
MD5 050ff02a375727d78991a652c311c3e4
BLAKE2b-256 c9f5df2921c6da97fffe3122804f78733d37fee22c7c867595d6da716f7f8cf1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.10.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7b34a092c1f9b5c42c9508536efad0c5db8583e80e96aa5bc697072e93d871a5
MD5 5f8d297fcf9a8a5960906aad82132932
BLAKE2b-256 40f76b11ee40c2bf83b7c2fe8a42bbbaeb7b1fbff9f8b7a8c1468782b12ba305

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.10.0-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 aaf09adf7b3d683e3abddb5fa292698c3e6fcf4a52b2041085e7d029a5f26276
MD5 13c8af6d6979cdad4c5c8b7a13e84358
BLAKE2b-256 da725c839e7e9ba70b026e0c9eb661cf3241b183e8b6b3a51d2443ad846b890c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.10.0-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 1a5c8ea3b95d73c8d9f3dacb7ee499ecc649b60f7870886646562c9d1e1a0847
MD5 ffc1933b59dc2c789e605bb0e9f4fc33
BLAKE2b-256 37c044ecf2755ea9223b468badd058a4784c1b077c1e45722dff54f151f63965

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.10.0-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 b0e37feff9bb3cd0aa5894ab383ead1ef0048a3b6fb85954d35ebddfed279b47
MD5 24498f54674a22bad76f220ec8cb64a7
BLAKE2b-256 8bced8a47c08b28d1c448c24bc47acc981f59d2c91cbe1a3861a626b15776c10

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.10.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 bb73d36b797fb6eb3f1804b810933c8b5c72195b77a762489593e1aa108214cb
MD5 45adb7ea3bf8f8de5234cded2f53a080
BLAKE2b-256 ffaf3166303a8822d89e9566901387dd2d3392a4b9b45a78593b69ed90915913

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.10.0-cp39-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 ffb74bda696c4dfb18681b8e1a60281cdd9407337bb064ecc31b37fefbe5eb19
MD5 653b549ab27c38aefa967db5a0a6e1b8
BLAKE2b-256 d904873ced2854914da5ebaeae532f509654322b53ae596a0d8c790e6b0a699f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.10.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 831773bf12dcfa143a1ffabdfdaed46ab620b0dd4a2786dad425ea1de3fa189f
MD5 6bdbaf2caf480a2c3c65e3c5e81a223a
BLAKE2b-256 d7e4e853122df417322b566bbf50d95e3466ef71cb6e94f6ed9c455c7677907b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.10.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 357a1325e4f71e889782369b18ad86f973b19f36bab83f9d38be3bdc065510e1
MD5 726bdb82025b96d024c68c9f2e5e684f
BLAKE2b-256 aa7c8df304b7c1639d1d0c0c0e07d2e1856c594fe5f2d2ac7f0bf8a16fc91089

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