turfslot-utils
Core business logic helpers for booking badminton, table tennis, and tennis turf slots.
The package provides reusable dataclasses and services to validate slots, detect clashes, and compute prices so that any Python application (web, CLI, or automation) can reuse the same rules.
Installation
Once released to PyPI:
pip install turfslot-utils
For local development from this repository:
pip install .
Quick start
from datetime import datetime, timezone
from turfslot_utils import (
Court,
SlotPriceCalculator,
SlotRangeValidator,
SportAvailabilityChecker,
CourtNotAvailableError,
)
court = Court(
court_id="C1",
sport_type="BADMINTON",
name="Smash Arena",
hourly_rate=400,
)
validator = SlotRangeValidator()
slot = validator.validate(
sport_type="BADMINTON",
court_id="C1",
start_time=datetime(2025, 1, 10, 9, 0, tzinfo=timezone.utc),
end_time=datetime(2025, 1, 10, 11, 0, tzinfo=timezone.utc),
)
checker = SportAvailabilityChecker()
existing_bookings = [] # Populate from your storage layer
try:
checker.check_availability(slot, existing_bookings)
except CourtNotAvailableError:
print("Court already booked!")
else:
total = SlotPriceCalculator().calculate_price(slot, court)
print(f"Booking confirmed. Price: INR {total}")
Testing
python -m pytest
Building and publishing
python -m pip install --upgrade build twine
python -m build
# TestPyPI upload
python -m twine upload --repository testpypi dist/*
# PyPI upload (set TWINE_PASSWORD or use keyring)
python -m twine upload dist/*
Keep credentials outside source control and pass them via environment variables or a secure keyring.
Metadata
Release files for turfslot-utils 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| turfslot_utils-0.1.0.tar.gz | 5.2 kB | Without provenance | Details for turfslot_utils-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| turfslot_utils-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for turfslot_utils-0.1.0-py3-none-any.whl |
Total release size: 10.4 kB
Release files / turfslot_utils-0.1.0.tar.gz
| Download URL | turfslot_utils-0.1.0.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
08f94942ea3021fc1e3205aebb4dbfc4c72013e19fa2ae3a431c9471d4c2f47b
|
|
BLAKE2b-256 checksum How to use checksums |
aecccc67c821acc2612e0bdcaa08011f81257e8d6f348c27b16c8ce363a709e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Release files / turfslot_utils-0.1.0-py3-none-any.whl
| Download URL | turfslot_utils-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
138f7e4d5d4a605af44484f4c45b8c699427c22996806916a1909500ced856a9
|
|
BLAKE2b-256 checksum How to use checksums |
757de29d861dcb9cfb3cc39b24bc7f483ce304af1ea25e300b5981b88659fc02
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Security for turfslot-utils 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.