Bidirectional OWL2 <-> Python over a renderable block/class system: make blocks, make classes from data, and keep an OWL ontology for everything you make.
Project description
owl22python
Bidirectional OWL2 ⇄ Python over a renderable block/class system. Make blocks, make classes from
data, and keep an OWL ontology for everything you make. Dependency-light (pydantic + jinja2), no
network, no external services.
What's in it
pydantic_stack—RenderablePiece(a block: a renderable typed pydantic model) +MetaStack(a stack of blocks that renders to one output).template_mixins—TemplateAttributeMixin/TemplateMethodMixin: class-level templating —add_attribute,add_method,execute_template_sequence— grow a class's attributes and methods from data at runtime.templated_class—TemplatedClass: aBaseModel+ the mixins, configurable from a dict, that can emit real.pysource of itself (generate_class_template/generate_code_files).owl22python(xml)/python22owl(cls)— OWL2/XML ⇄ a generatedRenderablePiececlass (one typed field per OWLDataProperty). Bidirectional: every class knows its own OWL, so you can define a thing in OWL or in Python and round-trip it.
Example
from owl22python import owl22python, python22owl, RenderablePiece, MetaStack, TemplatedClass
# OWL -> a live Python class
M = owl22python(EXAMPLE_OWL2_XML)["ModelClass"]
owl = M(species="Great Horned Owl", wingspan_cm=120.0, nocturnal=True)
print(owl.render()) # -> OWL individual (RDF/XML) + typed triples
# Python -> OWL (the inverse): the class knows its own ontology
print(python22owl(M)) # -> OWL2/XML schema for M
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 owl22python-0.1.0.tar.gz.
File metadata
- Download URL: owl22python-0.1.0.tar.gz
- Upload date:
- Size: 17.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f940370e5c9aaa1dabaaeb902382b9f23f1f6eb29c209ce34dd941681352315d
|
|
| MD5 |
b30b3ee3a72ef99deb5267704914b4ec
|
|
| BLAKE2b-256 |
3926ca97359a5423caba44f9a758c4cec4c03e387629a5366cad75ac084d950b
|
File details
Details for the file owl22python-0.1.0-py3-none-any.whl.
File metadata
- Download URL: owl22python-0.1.0-py3-none-any.whl
- Upload date:
- Size: 19.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e416e49d6c20b145f87fbcfe057c92a7c599987ac973944082a813882e94a663
|
|
| MD5 |
9d7e0ee17ab550c997135324af0dc113
|
|
| BLAKE2b-256 |
72ace5bb9ecb1e9392e3efc485090f702609c8d139bf1b32fdaaf0ae92abbc39
|