Metadata-Version: 2.4
Name: datamapperx
Version: 0.1.0
Summary: A reusable Python library that maps dictionary data to Python objects.
Home-page: https://github.com/example/datamapperx
Author: datamapperx contributors
Author-email: example@example.com
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-python
Dynamic: summary

# datamapperx

A complete, production-ready Python package for mapping dictionary data to Python objects (classes), inspired by AutoMapper in .NET.

## Features
- **Basic Mapping**: Map dictionaries to standard Python objects or dataclasses.
- **Custom Mapping**: Rename source fields to match target attributes based on custom dictionary mappings.
- **Ignore Fields**: Exclude specific fields from mapping during object creation.
- **Nested Mapping**: Supports mapping nested dictionaries to nested Python class structures automatically using type hints.
- **Type Conversion**: Converts data types automatically based on type hints (e.g. `str` to `int` or `float`).
- **Error Handling**: Custom `MappingError` exception with informative messages for missing fields or failed conversions. 
- **Logging**: Configured via the `logging` module to trace mapping execution procedures.

## Installation

You can install `datamapperx` locally:

```bash
pip install -e .
```

Or build and publish it:

```bash
python -m build
twine upload dist/*
```

## Usage Example

```python
from datamapperx import map_to

class UserProfile:
    def __init__(self, username: str, age: int, is_active: bool = True):
        self.username = username
        self.age = age
        self.is_active = is_active

# 1. Basic Mapping
data = {"username": "john_doe", "age": 30}
user = map_to(UserProfile, data)
print(user.username, user.age)

# 2. Custom Mapping
data = {"user_name": "jane", "user_age": 25}
custom_map = {"user_name": "username", "user_age": "age"}
user = map_to(UserProfile, data, custom_map=custom_map)

# 3. Ignoring Fields
data = {"username": "admin", "age": 40, "is_active": False}
# is_active gets the default (True) instead of False because it's ignored
user = map_to(UserProfile, data, ignore=["is_active"])

# 4. Nested Mapping
class Address:
    def __init__(self, city: str):
        self.city = city
        
class UserWithAddress:
    def __init__(self, profile: UserProfile, address: Address):
        self.profile = profile
        self.address = address

data = {
    "profile": {"username": "bob", "age": 35},
    "address": {"city": "New York"}
}
user_nest = map_to(UserWithAddress, data)
print(user_nest.address.city)  # "New York"
```

## MLOps & CI/CD
`datamapperx` follows software engineering and MLOps best practices:
- **CI/CD Pipeline**: GitHub Actions are configured in `.github/workflows/ci.yml`. It runs `pytest` automatically on PRs and commits to the `main` branch.
- **Testing**: Using `pytest` for all modules (`tests/test_mapper.py`). To run locally, simply run `pytest`.
- **Packaging**: Standardized layout with `pyproject.toml`, `setup.py`, and `src/datamapperx` for safe package resolution and module exporting. 
- **Logging Control**: Uses standard Python `logging`. This allows granular verbosity control dynamically in your production systems.
