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

Uploaded CPython 3.9+Windows x86-64

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

Uploaded CPython 3.9+Windows x86

opening_hours_py-0.11.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.11.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.11.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.11.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.11.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.11.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.11.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.11.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.11.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.11.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.11.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.11.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.11.0.tar.gz.

File metadata

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

File hashes

Hashes for opening_hours_py-0.11.0.tar.gz
Algorithm Hash digest
SHA256 1b150470ed6c39f9fe27fe05a0497cc6ce8b8bfbd11de1a7606b4d8fc5586fb4
MD5 b06610e607b5ac2a951be29b89f48355
BLAKE2b-256 ffcab6054b4d3beb87c7352f29ba81cc6cd3ebec6a42ae03916cb730ba89a25d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.11.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 3f04ddf33ab4c3c3fe49fe3ba65a69689bc6218d62da8b77cf0fbb57c75d018d
MD5 d3ebdc38ae2c2c5fe86335562a6353ac
BLAKE2b-256 ba2710a5635c26b8364ae958f941ef6c87accca45b12e6a49c15aa685cd9d05b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.11.0-cp39-abi3-win32.whl
Algorithm Hash digest
SHA256 cf26466cb72105a63f8e19fefa6b6667b1c6eb50c3528ed237aa226464dabac3
MD5 997e0d796322796d083980c0341f58f2
BLAKE2b-256 f8445cabba0c06f0e59d93181da598eb68ae49a36e5e4075a0a63a95371ac938

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.11.0-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 ffdab53c379b234a15c71b4fd7cc76d55290ee333f6fe2dca25fe2568579459c
MD5 311d49c936421e70c3fc4da27a221206
BLAKE2b-256 6f505f5d893acf38675cb2a88ae3d30abba61e15571bcbc0f26409a85d4d8918

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.11.0-cp39-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 172dd8d4aa55017e99b1f344bd886c7c84c9419bf0b305c8d88a529a6cfdad66
MD5 86ef2bd99dbd4cc083607b982a6604d3
BLAKE2b-256 d2abd40ab6f9256fb383076c5a65cddc0fd417b8448906aa539fa5ee56890bf7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.11.0-cp39-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 e7499c1cd43d8ffc11d303765e879c52d6e4b5fd8910c53084150b480d0bc5ad
MD5 94b4d4efdf31ed94374b510d1d537067
BLAKE2b-256 050a05352d49be3160090b77a3b01a2a543649b86c3249ebe9543d597837f521

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.11.0-cp39-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 a848f4cadde80a64eeeebf2a5d37c8dc401d68b301d5ba5d3e0561769be893d0
MD5 3f17b942a61902389a6b93d4703ef708
BLAKE2b-256 5d7537213019b24f08bf749908305831cae88b4be0d7870c1d663d66d6d0f209

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.11.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a2cfc0d92b1a1a9dfce5af2d7271af6a0f38c6e4d5259e78f0e310c85a489761
MD5 9822af719cacb3b92aaf1aac182aa46a
BLAKE2b-256 803367a5898e8bd63bc1d40a1d16dc03d079b0755e279e8e83aa77f5fa91727a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.11.0-cp39-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 4866fe1d8704bf5711880d1602a4857f1c1c85a3ea034c88ef04478809a7dac6
MD5 2e2e3a984eda3ca6ae90c1450e2191fe
BLAKE2b-256 03b9fd67ec920b65c9381309b8479d50dcd2465a5287f4532ee1a20bf2abcf01

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.11.0-cp39-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 0f8fded16606245d511f0a1eeb188e138dbbc1764270f8c30b1a05bff73cc2b8
MD5 f042175d0ba50e1ece515223bef16420
BLAKE2b-256 39821d1c99f5338b44a4b3ffab49ff8fd6267b865961f5b3666ad0f1fd3b5813

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.11.0-cp39-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 77cee44d3ac72fe7cf2e07be4763e89c17c5c7592aca58eec1cd453f5435cac9
MD5 9fce81a7ce3cda2e05601789f7746af0
BLAKE2b-256 dc5f4e3bf195d6e0850fe38de845658563928c06cba60cb91b62fc5b02c22abe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.11.0-cp39-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5858cdb90fe5ae6fd249e5a99f3cebba82f294e5bbe21b79d0e82403f252b12f
MD5 bb6e964169a35c24f01dccc996df45ad
BLAKE2b-256 90afdf37a7cd395684e0734676eef6547d41c8c5a8d9f789bca118949def8dee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.11.0-cp39-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 b5b5b16df2ed984d99092ca4412088305eac26850d837b581bd786fa813cc9ba
MD5 fcce7374dc1a02726942e9cb95b80c45
BLAKE2b-256 ad5dcad3e7bf2426f9734473eff8b63ae8b6242dcf737cb039c6b36aa2a77514

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.11.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 44dcc9a163a30e050f2fa43ca6651393e9604c9ba6700e2c27af809e4856d580
MD5 d1b029a3805e7958f4d3f70d37c31378
BLAKE2b-256 d9cc974bb46dac4aea4c10fd280f9e79100d96eca85be7ac436d17655936fbfd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opening_hours_py-0.11.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a191550d2ba915232d7b2935c84fbe4558901355a3463b5ae90e68278e5d10bf
MD5 7dd2228509ab824987fa88db50e2ae20
BLAKE2b-256 cb2cd6abf09729a4c969de38beb4c19a2b5fecea9e8721e76134cca97b5a23d3

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