Core datatypes for stele1 climbing catalogs
Project description
stele1-datatypes
Core datatypes for stele1 catalogs.
Covers Metadata, Climb, Area, Photo, Parking, and Trail.
See the stele1 spec for the data
model these implement.
Each datatype validates its input
and exposes from_data / to_data for serialization
to and from plain dicts.
Use
from uuid import uuid4
from stele1.climb import Climb
# from existing data
climb = Climb.from_data({
'uuid': '550e8400-e29b-41d4-a716-446655440000',
'name': 'Centerpede',
'rating': {'difficulty': 'V4'},
})
# or built up directly
other = Climb(uuid4())
other.name = 'Millipede'
other.rating = {'difficulty': 'V5'}
climb.name # 'Centerpede'
climb.name = 'Centerpede Low'
climb.rating = None # remove an attribute
climb.to_data() # plain dict, ready for json.dumps
Attributes are plain values: strings, numbers, tuples, dicts.
Assigning validates immediately;
invalid values raise TypeError or ValueError at the assignment,
naming the problem:
climb.length = {'lower_estimate': 3, 'upper_estimate': 2, 'unit': 'meters'}
# ValueError: climb .length lower_estimate must not exceed upper_estimate
Every record requires a uuid at construction.
uuid.UUID instances are accepted and stored
as the canonical lowercase string.
to_data returns fresh plain dicts.
json.dumps(climb.to_data()) produces spec-compliant output;
formatting is up to the caller.
Sequence attributes are returned as tuples;
to change one, assign a new value:
climb.tags = [*(climb.tags or ()), 'highball']
Attribute validators
Each datatype module also exposes its attribute validators, usable on their own:
from stele1.climb import validate_rating
validate_rating({'difficulty': 'V12'}) # returns the validated value
validate_rating({}) # raises ValueError
Compatibility behavior
Per the spec's versioning rules:
unknown top-level attributes are preserved verbatim
through from_data / to_data,
and unknown nested keys raise.
Some checks here are deliberately stricter than the spec;
they are marked beyond spec in the source.
To read records that this strictness rejects,
use DictCatalog from
stele1-filesystem.
Install
pip install stele1-datatypes
Development
Source and issues live at codeberg.org/stele-climbing/stele1.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stele1_datatypes-0.3.7.tar.gz.
File metadata
- Download URL: stele1_datatypes-0.3.7.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24b14b8639afec916a1b74de657ca38c40f604c6f9c534647fb8a38a1786f643
|
|
| MD5 |
30b5bdf0af28349bc4bc8898b23b29ea
|
|
| BLAKE2b-256 |
e3f1638d7fbb8ee9b8e29e1146e935fd686422dfed7e623fdd6f6f4aa84355e8
|
File details
Details for the file stele1_datatypes-0.3.7-py3-none-any.whl.
File metadata
- Download URL: stele1_datatypes-0.3.7-py3-none-any.whl
- Upload date:
- Size: 16.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17107cb9a1cb5d40d2e45a42c3caca78c64145dd0be6dcf016caf6ce1a8df2f1
|
|
| MD5 |
de5757f5ae928d924ea649c28c7975c8
|
|
| BLAKE2b-256 |
77597731a49051e6584b8d47ebef144dd9d569db8f6e18ffc62ac2c577ad4799
|