Metadata-Version: 2.1
Name: wysdom
Version: 0.0.1
Summary: A Python library for building custom document object models (DOMs) with built-in JSON schema checking
Home-page: https://github.com/jetavator/wysdom
Author: Joe Taylor
Author-email: joetaylorconsulting@gmail.com
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.7.0
Description-Content-Type: text/markdown
Requires-Dist: jsonschema (<4,>=3.2.0)


# wysdom
![Python application](https://github.com/jetavator/wysdom/workflows/Python%20application/badge.svg) [![codecov](https://codecov.io/gh/jetavator/wysdom/branch/master/graph/badge.svg)](https://codecov.io/gh/jetavator/wysdom)

A Python library for building custom document object models (DOMs) with built-in JSON schema checking

## Example Usage

### User class definition

```
from wysdom import UserObject, UserProperty, SchemaArray

class Address(UserObject):
    first_line = UserProperty(str)
    second_line = UserProperty(str)
    city = UserProperty(str)
    postal_code = UserProperty(int)

class Person(UserObject):
    first_name = UserProperty(str)
    last_name = UserProperty(str)
    current_address = UserProperty(Address)
    previous_addresses = UserProperty(SchemaArray(Address))
```

### Loading from dict
```
person_instance = Person({
  "first_name": "Marge",
  "last_name": "Simpson",
  "current_address": {
    "first_line": "123 Fake Street",
    "second_line": "",
    "city": "Springfield",
    "postal_code": 58008
  },
  "previous_addresses": [{
    "first_line": "742 Evergreen Terrace",
    "second_line": "",
    "city": "Springfield",
    "postal_code": 58008
  }]
})
```

### Reading attributes
```
>>> person_instance.last_name
'Simpson'

>>> person_instance.current_address.first_line
'123 Fake Street'

>>> person_instance.previous_addresses[0].first_line
'742 Evergreen Terrace'
```

### Reading attributes
```
>>> person_instance.last_name
'Simpson'

>>> person_instance.current_address.first_line
'123 Fake Street'

>>> person_instance.previous_addresses[0].first_line
'742 Evergreen Terrace'
```


