Skip to main content

Yet Another Adapter Base

https://img.shields.io/pypi/v/yaab.svg https://img.shields.io/travis/panagiks/yaab.svg Documentation Status

YAAB aims to provide a flexible base for Adapter Design Pattern implementations based on dataclasses.

Example Usage

Let’s assume that you are interfacing an API that returns a JSON object with the following structure:

{
    "weird_name": "My name",
    "oid": "3"
}

And you would like to transform it into a schema that fits the rest of your API, let’s assume:

{
    "name": "My name",
    "id": 3
}

Then you would define and use your model in the following way:

>>> from dataclasses import asdict, dataclass, field
>>>
>>> from yaab.adapter import BaseAdapter
>>>
>>> @dataclass
... class MyModel(BaseAdapter):
...     id: int = field(metadata={"transformations": ("oid", int)})
...     name: str = field(metadata={"transformations": ("weird_name", )})
...
>>> m = MyModel.from_dict({"weird_name": "My name", "oid": "3"})
>>> print(m)
MyModel(id=3, name='My name')
>>> asdict(m)
{'id': 3, 'name': 'My name'}

Features

  • TODO

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

History

0.2.2 (2020-05-03)

  • Introduce type conversion & convenience Mixins

0.2.1 (2020-02-18)

  • Bugfix: from_env now utilizes default values.

0.2.0 (2020-02-18)

  • Add dataclass nesting support.

0.1.0 (2020-01-21)

  • First release on PyPI.

Metadata

Release files for yaab 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for yaab 0.2.2
File Size Uploaded Provenance
yaab-0.2.2.tar.gz 10.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for yaab 0.2.2
File Interpreter ABI Platform
yaab-0.2.2-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 16.1 kB

Release files / yaab-0.2.2.tar.gz

Download URL yaab-0.2.2.tar.gz
Size 10.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7876bff852eaf99af93b6a08b979b686c16f62b16e1fe9abf6d03f6450d057d4
BLAKE2b-256 checksum
How to use checksums
824a06dae6e18f2f01710759f9b27105618036261dab5ab98741540aae16f08d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.7

Release files / yaab-0.2.2-py2.py3-none-any.whl

Download URL yaab-0.2.2-py2.py3-none-any.whl
Size 5.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
98317df95e55c4da5fa43238ba43529d192244d451e9aa8aa28ca1178ed0b1c2
BLAKE2b-256 checksum
How to use checksums
6709d609cfd0825b0d8b4b81236da0a9ce3be0cea8546c4c1e156dc543b46956
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.7

Security for yaab 0.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page