Skip to main content

data interpolation templating engine

Project description

PyPI Version Build Status


dinterpol is a python library and a command line utility for data interpolation that supports both scalar and structured types generation.

Motivation

When dealing with structured data types like dictionaries, or data formats like JSON and YAML it can be useful to generate scalar or structured types resulting from the interpolation of multiple input elements. Python3 provides several standard string interpolation mechanisms: string.Template(), f-strings and str.format(), but because they all return strings, they are not suitable for structured and non string data interpolation.

Usage example:

from dinterpol import Template

data = {
    "product": "pie",
    "quantity": 33,
    "price": 14,
}

# simple key interpolation for string generation
Template("We have $quantity$ $product$(s)").render(data)
'We have 33 pie(s)'

# python expression for string generation, expression result concatnated with string
Template("Total price is $quantity * price$").render(data)
'Total price is 426'

# python expression for dict generation, type inferred directly from expression's eval()
Template({ "total": "$quantity * price$"}).render(data)
{'total': 426}

Code of Conduct

Everyone interacting in the dinterpol project’s codebase, issue trackers, chat rooms, and mailing lists is expected to follow the PyPA Code of Conduct.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dinterpol-0.1.1.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

dinterpol-0.1.1-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file dinterpol-0.1.1.tar.gz.

File metadata

  • Download URL: dinterpol-0.1.1.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.6

File hashes

Hashes for dinterpol-0.1.1.tar.gz
Algorithm Hash digest
SHA256 644bb4f39b3ab38b8584ff0a6c3914108607e143d211c9f414e33c3133952527
MD5 e4a92d55c758d1614baecd3804e58e52
BLAKE2b-256 cd8a451aa281329da611f31405a658ff536e350c0c9b1188b3efb0aaee5a463a

See more details on using hashes here.

Provenance

File details

Details for the file dinterpol-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: dinterpol-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.6

File hashes

Hashes for dinterpol-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 663c16806413cc22dcc91145af371d02a6fab44fda3668d047496bbb75e335b3
MD5 c6d62f1111d9b2a795f2978b5a5f59a1
BLAKE2b-256 a7222a3a751d399a316083ab6ed0172a8a5973166af33abc6964377fb0938b39

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page