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

Uploaded CPython 3.9+Windows x86-64

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

Uploaded CPython 3.9+Windows x86

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

File metadata

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

File hashes

Hashes for opening_hours_py-0.10.1.tar.gz
Algorithm Hash digest
SHA256 10330b50205a551931156be7d77bbadf3cb0c5a16c68365582da7eef4f4fa1df
MD5 99b66e6488901b784ea80d08d213e17a
BLAKE2b-256 ace75de7c56e3b4e4ca5345032ddab053f0a05e8ee14e9948bdbddda1b3bb444

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.10.1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 25ee98726f3168d59812a82b79986040143a70de878176437ee70399f8a988df
MD5 564e5ad4b82f7948f4ec4da863faaaac
BLAKE2b-256 1b050efb569c624d6f5373085afd5b9e56f3b81a498e781e1668e65e57a29d37

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.10.1-cp39-abi3-win32.whl
Algorithm Hash digest
SHA256 e2e95e70b7ce8ee94fb287760c2ea257352418f70c923ac1c93642162fda5c26
MD5 c8a1056f152dc6253dcebeb7ba856372
BLAKE2b-256 625eb13eb7c0d8c9fdd4728eb64327b6f47331bd0d4e186bc515fe8abce833f6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.10.1-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 cf14635dcb04255fd0170ec3699c3a73fb74e37b0100959329340aa59e15a5de
MD5 afb16075941b8c0a686f78af66684d7a
BLAKE2b-256 fa121f6bf4398edb35285606f8a86a0f8aff6619bf95f0b53ffaab8f35442803

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.10.1-cp39-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 a51cd3c2551a7370995a9d6ca516324a9497cd67274936ce35b88c6874ead57f
MD5 9a86eff5af2933461ee95c39514d85e0
BLAKE2b-256 7623a69b91d3be5f5cec84db04a33a3b3391d7ce0d99167652036a84cacf1c65

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.10.1-cp39-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 bb6e8418d7036028e013f619e7d1496091821401f6c3bae469a88412daef4e5a
MD5 141295245aa6a4355dc4fc3ea8c9ddc2
BLAKE2b-256 e669f329dd72da19ee81e8d8d14f8a6cf86124990c172ad05486c5864f771b5a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.10.1-cp39-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 4501611225235113ecf4300c25b2b497f5192b101d27f8997dbbe4ff196a8cc8
MD5 1865b3ba2e489eaf85a16b8c5c9f4b93
BLAKE2b-256 1122ec2cbb8cca50d31f3416c9e0e8d2a8bac6ea59e8089485298680cd75ffad

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.10.1-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cba299c8bc96b340168b108fe82383b8732b8ecd398b67a39f24ffc876dd9cc9
MD5 58af6a5228c2be51242f1930c04b9521
BLAKE2b-256 335c6f7cceea194116df8a8bff3d9e43dd71ef82fb4f39f12e2622c3042bbb2a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.10.1-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 355adcff3d1a07610003db5f95b07fd9e5d91a2fa1283d3cdcbc0ce102034d8b
MD5 dd2e20a44003956f8f919fd3ea2b44f4
BLAKE2b-256 940d858912f9ec4e8c5351fff82792f4d3780327b3d6120eafdbfbb29399fcd4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.10.1-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 5a0dd7936557a8eb9466a87ed553b949170d067a52295d0e38121d930aec72a5
MD5 d82084b373234ff8647a248206c46eea
BLAKE2b-256 b9d95b989eb0d6242a610b7fea3b6e3430443239a6ca2a4e6312b75cb029ca3b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.10.1-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 75bf7e509339de7ce8b9b447620d11f25eb9ac9547308a70dfe7701eddde5637
MD5 77a7c649ff6b9abcf8654a45976bfde6
BLAKE2b-256 be02fde393014da175b85aa69784472389db915d1af1c5f672c81a2268446f0b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.10.1-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ad921498c33b1cbfa2b8a682f6832b4941902dd70f4355e6934d373326b65d19
MD5 f4fa25f5d9d0b3a6db2aa69b8890b82b
BLAKE2b-256 96caa1f03498cde1cf23b6c752f4da9c8bc957357a86e1002420558d73bdf02a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.10.1-cp39-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 970b05b4f8c4a10656cfbc4002721e5066253a1d3ff4008b957ab14166095769
MD5 74a228e741877b3012b977da0a793fdc
BLAKE2b-256 948a4178be774a83a68d50bc13173da6bc0629dd96094bc1184ab36cba7e5bb1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.10.1-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4a95ddf4a44abe2a7baa43d3ae56291f69570e59ab57a7cc69da47039df72d29
MD5 b006439dbe5dda95aa8f3dde20025f51
BLAKE2b-256 796744ad14d9073e5d05b1fb2a365590a7e4c6238b3e2b888126a6919a903a2c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.10.1-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 8d0f4da474c5c9be966b1df572d7ac98f62cb0d97e9f0b0fa21f85c5f28e6616
MD5 5e56a88f0f564f97225551daef86e3ef
BLAKE2b-256 674e45badcbaa58d833009264c01fef7c82d857d58be74aed76ffd04a994ebd1

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