Metadata-Version: 2.4
Name: aloeschema
Version: 0.2.0
Summary: Aloeschema is a simple schema.org accessor and validator that allows custom types and properties
Author-email: michael@aloecraft.org
Maintainer-email: michael@aloecraft.org
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/Aloecraft-org/aloeschema
Project-URL: Repository, https://github.com/Aloecraft-org/aloeschema
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Requires-Dist: coverage; extra == "test"
Dynamic: license-file

# aloeschema

<div align="center">

<svg style="height:96px; width:96px;" version="1.1" viewBox="0.0 0.0 768.0 768.0" fill="none" stroke="none" stroke-linecap="square" stroke-miterlimit="10" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg"><clipPath id="p.0"><path d="m0 0l768.0 0l0 768.0l-768.0 0l0 -768.0z" clip-rule="nonzero"/></clipPath><g clip-path="url(#p.0)"><path fill="#000000" fill-opacity="0.0" d="m0 0l768.0 0l0 768.0l-768.0 0z" fill-rule="evenodd"/><g filter="url(#shadowFilter-p.1)"><use xlink:href="#p.1" transform="matrix(1.0 0.0 0.0 1.0 0.0 2.805028083989503)"/></g><defs><filter id="shadowFilter-p.1" filterUnits="userSpaceOnUse"><feGaussianBlur in="SourceAlpha" stdDeviation="6.7076616" result="blur"/><feComponentTransfer in="blur" color-interpolation-filters="sRGB"><feFuncR type="linear" slope="0" intercept="0.0"/><feFuncG type="linear" slope="0" intercept="0.0"/><feFuncB type="linear" slope="0" intercept="0.0"/><feFuncA type="linear" slope="0.75" intercept="0"/></feComponentTransfer></filter></defs><g id="p.1"><defs><linearGradient id="p.2" gradientUnits="userSpaceOnUse" gradientTransform="matrix(26.422419929653632 0.0 0.0 26.422419929653632 0.0 0.0)" spreadMethod="pad" x1="1.245462624943264" y1="1.3215563632917704" x2="1.245366976172699" y2="27.74397629277228"><stop offset="0.0" stop-color="#d4e5f5"/><stop offset="0.53" stop-color="#6d9eeb"/><stop offset="1.0" stop-color="#1155cc"/></linearGradient></defs><path fill="url(#p.2)" d="m32.90814 383.99213c0 -192.78651 157.17273 -349.07086 351.0551 -349.07086c93.10559 0 182.39783 36.777004 248.23346 102.24048c65.83557 65.463486 102.821655 154.25104 102.821655 246.83038c0 192.7865 -157.17273 349.07086 -351.0551 349.07086c-193.88239 0 -351.0551 -156.28436 -351.0551 -349.07086z" fill-rule="evenodd"/></g><g filter="url(#shadowFilter-p.3)"><use xlink:href="#p.3" transform="matrix(1.0 0.0 0.0 1.0 0.0 3.082887664041986)"/></g><defs><filter id="shadowFilter-p.3" filterUnits="userSpaceOnUse"><feGaussianBlur in="SourceAlpha" stdDeviation="3.0828876" result="blur"/><feComponentTransfer in="blur" color-interpolation-filters="sRGB"><feFuncR type="linear" slope="0" intercept="0.0"/><feFuncG type="linear" slope="0" intercept="0.0"/><feFuncB type="linear" slope="0" intercept="0.0"/><feFuncA type="linear" slope="0.5" intercept="0"/></feComponentTransfer></filter></defs><g id="p.3"><defs><linearGradient id="p.4" gradientUnits="userSpaceOnUse" gradientTransform="matrix(19.46494314326349 -19.463239428525526 19.463239428525526 19.46494314326349 0.0 0.0)" spreadMethod="pad" x1="-9.583074212298637" y1="10.337559481948245" x2="-9.583144980723437" y2="29.802502625083093"><stop offset="0.0" stop-color="#1076d2"/><stop offset="1.0" stop-color="#093053"/></linearGradient></defs><path fill="url(#p.4)" d="m204.09448 577.18036c-104.61229 -104.6297 -108.86382 -269.99527 -9.496063 -369.35434q88.13263 -88.12491 180.11423 -172.40022q96.440186 89.143936 189.22437 181.94353c104.612305 104.6297 108.86383 269.99527 9.496033 369.3543c-99.36774 99.35907 -264.72626 95.086426 -369.33856 -9.543274z" fill-rule="evenodd"/></g><g filter="url(#shadowFilter-p.5)"><use xlink:href="#p.5" transform="matrix(1.0 0.0 0.0 1.0 0.0 2.578420209973758)"/></g><defs><filter id="shadowFilter-p.5" filterUnits="userSpaceOnUse"><feGaussianBlur in="SourceAlpha" stdDeviation="14.707419" result="blur"/><feComponentTransfer in="blur" color-interpolation-filters="sRGB"><feFuncR type="linear" slope="0" intercept="0.0"/><feFuncG type="linear" slope="0" intercept="0.0"/><feFuncB type="linear" slope="0" intercept="0.0"/><feFuncA type="linear" slope="0.85" intercept="0"/></feComponentTransfer></filter></defs><g id="p.5"><path fill="#00ff00" d="m270.38263 510.87988c-66.065445 -66.05673 -68.76584 -170.46252 -6.031494 -233.19684q85.294556 -85.294586 110.563995 -230.60641q32.82498 146.81036 122.64859 236.62216c66.06543 66.05673 68.76581 170.46252 6.031494 233.19684c-62.734314 62.734314 -167.14716 60.041016 -233.21259 -6.015747z" fill-rule="evenodd"/><path stroke="#00ff00" stroke-width="22.060367454068242" stroke-linejoin="round" stroke-linecap="butt" d="m270.38263 510.87988c-66.065445 -66.05673 -68.76584 -170.46252 -6.031494 -233.19684q85.294556 -85.294586 110.563995 -230.60641q32.82498 146.81036 122.64859 236.62216c66.06543 66.05673 68.76581 170.46252 6.031494 233.19684c-62.734314 62.734314 -167.14716 60.041016 -233.21259 -6.015747z" fill-rule="evenodd"/></g><defs><linearGradient id="p.6" gradientUnits="userSpaceOnUse" gradientTransform="matrix(16.53370895591199 -16.533708955911997 16.533708955911997 16.53370895591199 0.0 0.0)" spreadMethod="pad" x1="-5.748601497030276" y1="12.723670094197697" x2="-5.751968584823707" y2="29.257378707256184"><stop offset="0.0" stop-color="#ffffff"/><stop offset="0.19" stop-color="#b6d7a8"/><stop offset="0.37" stop-color="#93c47d"/><stop offset="0.74" stop-color="#b6d7a8"/><stop offset="1.0" stop-color="#ffffff"/></linearGradient></defs><path fill="url(#p.6)" d="m295.60068 485.6921c-51.410324 -51.41031 -53.50435 -132.66888 -4.6771545 -181.49606q85.58432 -85.58432 84.03119 -258.3061q7.352844 172.87123 97.464874 262.98325c51.41031 51.41034 53.504364 132.66888 4.6771545 181.49606c-48.82718 48.82721 -130.08575 46.733154 -181.49606 -4.6771545z" fill-rule="evenodd"/><path stroke="#ffffff" stroke-width="11.031496062992126" stroke-linejoin="round" stroke-linecap="butt" d="m295.60068 485.6921c-51.410324 -51.41031 -53.50435 -132.66888 -4.6771545 -181.49606q85.58432 -85.58432 84.03119 -258.3061q7.352844 172.87123 97.464874 262.98325c51.41031 51.41034 53.504364 132.66888 4.6771545 181.49606c-48.82718 48.82721 -130.08575 46.733154 -181.49606 -4.6771545z" fill-rule="evenodd"/><path fill="#ffffff" d="m472.6946 353.82178c28.54486 28.54486 22.756287 80.6138 -12.929138 116.299225c-35.685425 35.685425 -87.75433 41.474 -116.299194 12.929138c31.510498 0.91067505 64.9617 -13.481354 90.35434 -38.873993c25.39264 -25.39264 39.784668 -58.843872 38.873993 -90.35437z" fill-rule="evenodd"/></g></svg>

**A Schema.org Multitool**

[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Repo](https://img.shields.io/badge/github-repo-blue.svg)](https://github.com/Aloecraft-org/AloeSchema)


</div>

## Getting Started

See **quickstart.ipynb** for more detailed usage examples

**Installation**:
```sh
pip install aloeschema
```

**Initialization**: Loads schema.org and a validator

``` py
from aloeschema import load_schema_org
from aloeschema.validator import AloeSchemaValidator
schema_org = load_schema_org()
schema_validator =  AloeSchemaValidator(schema_org)
```

**Validating schema.org**
- Input case is ignored by default (`ignore_case=True`)
- Detailed errors raised by default (`quiet=False`)
    + Set `quiet=True` to return a truthy result instead

``` py
from aloeschema.validator import AloeSchemaValidator
from aloeschema import load_schema_org

schema_org = load_schema_org()
schema_validator = AloeSchemaValidator(schema_org)

schema_validator.Validate(subject_type_name="person", property_type_name="potentialaction", object_type_name="planaction")
schema_validator._getType("schedule")
```

**Extending Schema.org With Custom Types, Properties, and Enumerations**

use `registerCustomType`, `registerCustomProperty`, `registerCustomEnumeration`, and `registerCustomEnumerationValue` to extend Schema.org

``` py
from aloeschema.validator import AloeSchemaValidator
from aloeschema import load_schema_org, registerCustomProperty, registerCustomType, registerCustomEnumeration, registerCustomEnumerationValue

schema_org = load_schema_org()

schema_org = registerCustomType(schema_org, name="User", parent="Person", properties=[])
schema_org = registerCustomProperty(schema_org, name="userName", domain=["Person", "User"], range=["Text"])

schema_org = registerCustomEnumeration(schema_org, name="TaskStatus")
schema_org = registerCustomEnumerationValue(schema_org, enum_type="TaskStatus", value="TaskStatusActive")
schema_org = registerCustomProperty(schema_org, name="taskStatus", domain=["User"], range=["TaskStatus"])

schema_validator = AloeSchemaValidator(schema_org)

schema_validator.IsEnumerationType("TaskStatus")                                           # True
schema_validator.EnumerationValueIsOfType("TaskStatus", "TaskStatusActive")               # True
schema_validator.Validate(subject_type_name="User", property_type_name="taskStatus", enumeration_value_name="TaskStatusActive")  # True
```
