Skip to main content

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_stackRenderablePiece (a block: a renderable typed pydantic model) + MetaStack (a stack of blocks that renders to one output).
  • template_mixinsTemplateAttributeMixin / TemplateMethodMixin: class-level templating — add_attribute, add_method, execute_template_sequence — grow a class's attributes and methods from data at runtime.
  • templated_classTemplatedClass: 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

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

owl22python-0.1.0.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

owl22python-0.1.0-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

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

Hashes for owl22python-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f940370e5c9aaa1dabaaeb902382b9f23f1f6eb29c209ce34dd941681352315d
MD5 b30b3ee3a72ef99deb5267704914b4ec
BLAKE2b-256 3926ca97359a5423caba44f9a758c4cec4c03e387629a5366cad75ac084d950b

See more details on using hashes here.

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

Hashes for owl22python-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e416e49d6c20b145f87fbcfe057c92a7c599987ac973944082a813882e94a663
MD5 9d7e0ee17ab550c997135324af0dc113
BLAKE2b-256 72ace5bb9ecb1e9392e3efc485090f702609c8d139bf1b32fdaaf0ae92abbc39

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