Metadata-Version: 2.4
Name: datamorph-python
Version: 1.22.1
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Rust
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Text Processing :: Markup :: XML
Summary: Python bindings for the DataMorph transformation engine
Keywords: datamorph,transformation,xml,json,csv,yaml
Home-Page: https://data-morph.com
Author: Armin Majerie
License: MIT OR Apache-2.0
Requires-Python: >=3.8
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Documentation, https://data-morph.com
Project-URL: Homepage, https://data-morph.com
Project-URL: Repository, https://github.com/arminmajerie/data-morph

# datamorph-python

`datamorph-python` exposes the DataMorph transformation engine as a normal Python package.

Install it with:

```bash
pip install datamorph-python
```

Then import it with:

```python
from datamorph import evaluate, read, write
```

## Quick Start

```python
from datamorph import evaluate

script = """
output application/json
---
{
  id: payload.id,
  requestId: headers.requestId,
  stage: attributes.stage,
  env: vars.env
}
"""

result = evaluate(
    script,
    payload={"id": 42},
    headers={"requestId": "req-001"},
    attributes={"stage": "test"},
    variables={"env": "dev"},
)

assert result == {
    "id": 42,
    "requestId": "req-001",
    "stage": "test",
    "env": "dev",
}
```

## API

- `evaluate(script, payload=None, headers=None, attributes=None, variables=None, payload_mime=None)`
- `transform(...)` as an alias for `evaluate(...)`
- `eval_expression(expression)`
- `read(input_text, mime_type)`
- `write(data, mime_type)`
- `validate(script)`
- `version()`

## Notes

- Package name on PyPI: `datamorph-python`
- Import name in Python: `datamorph`
- Wheels built from this folder contain the Rust engine, so users do not need a separate DataMorph installation.

