Skip to main content

A type aware structor/destructor for python value objects.

Project description

# data_structor

[![Documentation Status](https://readthedocs.org/projects/dataclass-structor/badge/?version=latest)](https://dataclass-structor.readthedocs.io/en/latest/?badge=latest)

![PyPI - License](https://img.shields.io/pypi/v/dataclass_structor.svg)

![PyPI - Python Version](https://img.shields.io/pypi/pyversions/dataclass_structor.svg)

![PyPI - License](https://img.shields.io/pypi/l/dataclass_structor.svg)

[![Build Status](https://travis-ci.com/hockeybuggy/dataclass_structor.svg?branch=master)](https://travis-ci.com/hockeybuggy/dataclass_structor)


A type aware structor/destructor for python value objects.


## Install

```shell
pip install data_structor
```


## Documentation

The [docs for this project can be found here](dataclass-structor.readthedocs.io).


## Example

```python
import dataclasses

from data_structor import structure, unstructure


@dataclasses.dataclass
class Invite:
email: str
guests: typing.List["Guest"]


@dataclasses.dataclass
class Guest:
first_name: typing.Optional[str] = None


value_type = Invite(
email="testing",
guests=[
Guest(first_name="John"),
Guest(),
],
)

x = unstructure(value_type)
assert x == {"email": "", "guests": [{"first_name": "John"}, {"first_name": None}]}

assert structure(x, Invite) == value_type
```

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

dataclass_structor-0.0.2.tar.gz (1.6 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page