Skip to main content

DuckMapper

A tiny library to help you to convert classes to DTO and vice versa.

Usage

Using the default function

class testClass():
    def __init__(self):
        self.id = None
        self.gender =None
        self.github = None
        self.name = None
        self.password = None
        self.phone_number = None
class testDTO:
    def __init__(self):
        self.name = None
        self.github = None
        self.telephone = None
x = testClass()
x.name = "Lucas"
x.phone_number = 99999999
x.github = "https://github.com/lucascz37"
result = convertTo(source=x, target=testDTO, default=10)

obs: fields not mapped will receive the value passed on the default param

using decorator

With the same two classes created before with decorator you can specify fields that dont have the same name. My suggestion it's that you can create a class that have functions with the decorator that convert all your project's DTO to classes and the other way around.

@mapBy(fields={"telephone": "phone_number"})
def convertTestClasstoTestDTO():
    pass


teste = convertTestClasstoTestDTO(source=x, target=testDTO, default=100)

obs: the fields dict should be like this: {"target_field1": "source_field1", "target_field2": "source_field2"...}

Metadata

Release files for DuckMapper 1.0.1

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

Source distribution (sdist)

Source distribution for DuckMapper 1.0.1
File Size Uploaded Provenance Actions
DuckMapper-1.0.1.tar.gz 3.1 kB Without provenance Details for DuckMapper-1.0.1.tar.gz

Release files / DuckMapper-1.0.1.tar.gz

Download URL DuckMapper-1.0.1.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
62fc4d07fb1c8f1b32c988be7527c9f96ca725ddddda8d744701cd7630c19d39
BLAKE2b-256 checksum
How to use checksums
cf5c9b462588f8ced07deab904b9f9d7fada51db125ecc2a3a60617f15b59710
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.5

Security for DuckMapper 1.0.1

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.

Release history Release notifications | RSS feed

This release

1.0.1 This release

1 release file No provenance

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