Library for automatically mapping one object to another
Project description
py-automapper
Python object auto mapper
TODO:
- use custom exception type
- use https://docs.readthedocs.io/en/stable/index.html
- configure poetry for building a package: https://python-poetry.org/docs/pyproject/
- using TortoiseORM as an example of package building: https://github.com/tortoise/tortoise-orm/blob/develop
Requirements:
from automapper import mapper
mapper.register_cls_extractor(ParentClassA, fields_name_extractor_function)
mapper.add(ClassA, ClassB)
# output type is known from registered before
mapper.map(obj)
# output type specified
mapper.to(TargetClass).map(obj)
# TODO: extra mappings, they override default mapping from `obj`
mapper.map(obj, field1=value1, field2=value2)
# TODO: same extra mappings with specific type, field1 and field2 coming from SpecificType
mapper.map(obj, SpecificType, field1=value1, field2=value2)
# TODO: don't map None values, by default skip_none_values == False
mapper.map(obj, skip_none_values = True)
# TODO: Mapping should be recursive
# TODO: Add optional dependencies for
# TODO: Advanced: multiple from classes
mapper.add(FromClassA, FromClassB, ToClassC)
# TODO: Advanced: add custom mappings for fields
mapper.add(ClassA, ClassB, {"ClassA.field1", "ClassB.field2", "ClassA.field2", "ClassB.field1"})
# TODO: Advanced: map multiple objects to output type
mapper.multimap(obj1, obj2)
mapper.to(TargetType).multimap(obj1, obj2)
# TODO: Advanced: Verify correctness of all mappings and if it's possible to construct object
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
py-automapper-0.0.1.tar.gz
(4.1 kB
view hashes)
Built Distribution
Close
Hashes for py_automapper-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e36aeb2e4294eefc2089d865a530183b082c01bef0ca5c64ce8d86433a8d665 |
|
MD5 | 2ec70fdf13e57bf1c75c4597f1c79b4d |
|
BLAKE2b-256 | a11bc98ac659dff119d851926c466d43e69270b489085e5e303811c1af1e37df |