Skip to main content

Object Mapper

Version 1.1.0

Author marazt

Copyright marazt

License The MIT License (MIT)

Last updated 13 July 2019

Package Download https://pypi.python.org/pypi/object-mapper —

Versions

1.2.0 - 2025/06/02

1.1.0 - 2019/07/13

1.0.7 - 2019/06/19

1.0.6 - 2018/10/28

1.0.5 - 2018/02/21

1.0.4 - 2017/11/03

  • Migration to new Pypi.org deployment

1.0.3 - 2015/05/15

1.0.2 - 2015/05/06

1.0.1 - 2015/02/19

  • Fix of the package information

1.0.0 - 2015/02/19

  • Initial version

About

ObjectMapper is a class for automatic object mapping inspired by .NET AutoMapper. It helps you to create objects between project layers (data layer, service layer, view) in a simple, transparent way.

Example

  1. Mapping of the properties without mapping definition

In this case are mapped only these properties of the target class which are in target and source classes. Other properties are not mapped. Suppose we have class A with attributes name and last_name and class B with attribute name. Initialization of the ObjectMapper will be:

python mapper = ObjectMapper() mapper.create_map(A, B) instance_b = mapper.map(A(), B)

In this case, value of A.name will be copied into B.name.

  1. Mapping with defined mapping functions

Suppose we have class A with attributes first_name and last_name , class B with attribute full_name and class C with attribute reverse_name. And want to map it in a way B.full_name = A.first_name + A.last_name and C.reverse_name = A.last_name + A.first_name Initialization of the ObjectMapper will be:

```python mapper = ObjectMapper() mapper.create_map(A, B, {‘name’: lambda a : a.first_name + “ “ + a.last_name}) mapper.create_map(A, C, {‘name’: lambda a : a.last_name + “ “ + a.first_name})

instance_b = mapper.map(A(), B) instance_c = mapper.map(A(), C) ```

In this case, to the B.name will be mapped A.first_name + " " + A.last_name In this case, to the C.name will be mapped A.last_name + " " + A.first_name

  1. Mapping suppression

For some purposes, it can be needed to suppress some mapping. Suppose we have class A with attributes name and last_name and class B with attributes name and last_name. And we want to map only the A.name into B.name, but not A.last_name to B.last_name Initialization of the ObjectMapper will be:

```python mapper = ObjectMapper() mapper.create_map(A, B, {‘last_name’: None})

instance_b = mapper.map(A(), B) ```

In this case, value of A.name will be copied into B.name automatically by the attribute name name. Attribute A.last_name will be not mapped thanks the suppression (lambda function is None).

  1. Case insensitive mapping

Suppose we have class A with attributes Name and Age and class B with attributes name and age and we want to map A to B in a way B.name = A.Name and B.age = A.Age Initialization of the ObjectMapper will be:

python mapper = ObjectMapper() mapper.create_map(A, B) instance_b = mapper.map(A(), B, ignore_case=True)

In this case, the value of A.Name will be copied into B.name and the value of A.Age will be copied into B.age.

Note: You can find more examples in tests package

Installation

ENJOY IT!

Metadata

Release files for object-mapper-312 1.2.0

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

Source distribution (sdist)

Source distribution for object-mapper-312 1.2.0
File Size Uploaded Provenance Actions
object_mapper_312-1.2.0.tar.gz 11.3 kB With provenance Details for object_mapper_312-1.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for object-mapper-312 1.2.0
File Interpreter ABI Platform Actions
object_mapper_312-1.2.0-py2.py3-none-any.whl Python 2, Python 3 none any Details for object_mapper_312-1.2.0-py2.py3-none-any.whl

Total release size: 23.2 kB

Release files / object_mapper_312-1.2.0.tar.gz

Download URL object_mapper_312-1.2.0.tar.gz
Size 11.3 kB
Tags Source
SHA-256 checksum
How to use checksums
6942d02e3dd71297d45e988ccb9014ee54f05290e3862fdab6dea798a6b5fb96
BLAKE2b-256 checksum
How to use checksums
9c66d90be1bddcb7fde7d11c1c6fbdef7aa5820bd2fbc361802692dd26e1334c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 2, 2025.

Transparency log

Release files / object_mapper_312-1.2.0-py2.py3-none-any.whl

Download URL object_mapper_312-1.2.0-py2.py3-none-any.whl
Size 12.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
4c2a96e5d164632ba7acdce6828e3b65349105ad742bf991736a935dba3614de
BLAKE2b-256 checksum
How to use checksums
140123fc16fa9110e628e052b3ab14b206820a62b0b451d0f79549e31bd96019
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 2, 2025.

Transparency log

Security for object-mapper-312 1.2.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for object_mapper_312-1.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 2, 2025.

Transparency log

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.2.0 This release

2 release files Full 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