Metadata-Version: 2.4
Name: owl22python
Version: 0.1.0
Summary: Bidirectional OWL2 <-> Python over a renderable block/class system: make blocks, make classes from data, and keep an OWL ontology for everything you make.
License: MIT
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pydantic>=2
Requires-Dist: jinja2
Dynamic: license-file

# 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`: a `BaseModel` + the mixins, configurable from a dict, that
  can emit real `.py` source of itself (`generate_class_template` / `generate_code_files`).
- **`owl22python(xml)` / `python22owl(cls)`** — OWL2/XML ⇄ a generated `RenderablePiece` class
  (one typed field per OWL `DataProperty`). Bidirectional: **every class knows its own OWL**, so you can
  define a thing in OWL *or* in Python and round-trip it.

## Example

```python
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.
