Metadata-Version: 2.4
Name: copperlace
Version: 0.2.1
Summary: Python wrapper for the Copperlace text renderer
Author: Copperlace contributors
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/bmahe/Copperlace
Project-URL: Repository, https://github.com/bmahe/Copperlace
Project-URL: Documentation, https://bmahe.github.io/Copperlace/
Project-URL: Issues, https://github.com/bmahe/Copperlace/issues
Keywords: text-generation,templates,procedural-generation,grammar
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Rust
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Text Processing
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# Copperlace Python

Python wrapper for the Copperlace renderer.

The wheel build runs Cargo for `../rust-core`, bundles the resulting native
library, and exposes a small Python API over the Copperlace C ABI.

```python
from copperlace import Copperlace

with Copperlace.from_string('name = ["Mia"]\norigin = "{name}"') as copperlace:
    print(copperlace.render("origin"))
    print(copperlace.render("origin"))
    print(copperlace.render("origin", {"name": "Darcy"}))

with Copperlace.from_string(
    'name = ["Mia"]\norigin = "{name | shout}"',
    {"shout": lambda value: value.upper()},
) as copperlace:
    print(copperlace.render("origin"))
```

Structured rendering returns JSON strings for object-valued rules:

```python
from copperlace import render_str_structured

config = """
name = ["Mia"]
origin {
  title = "Hello {name}"
  tags = ["structured", "{name | slug}"]
  count = 3
  active = true
  missing = null
}
"""

print(render_str_structured(config, "origin"))
# {
#     "active": true,
#     "count": 3,
#     "missing": null,
#     "tags": [
#         "structured",
#         "mia"
#     ],
#     "title": "Hello Mia"
# }
```

`RuleSet.render_structured`, `Copperlace.render_structured`,
`render_str_structured`, and `render_file_structured` return formatted JSON
strings from the native renderer.

Use inferred rendering when callers want the CLI-style behavior from one method:
text rules return text, list rules keep random text choice behavior, and
object-valued rules return a formatted JSON string.

```python
from copperlace import render_str_inferred

print(render_str_inferred(config, "origin"))
```
