Skip to main content

hcl2-eval

Evaluate HCL2 configurations like a programming language. Based on hcl2-ast.

Usage

The evaluation of the HCL2 AST uses three components: A context, an evaluator an interpreter. The context is responsible for performing attribute reads and writes, looking up functions as well as opening and closing stanzas. The evaluator's responsibility is to evaluate expressions in the AST to Python values, while the interpreter executes statement nodes.

from hcl2_ast import parse_file
from hcl2_eval import Context, Evaluator, Interpreter, Stanza

class HelloStanza(Stanza):
    ...

module = parse_file(open("hello.hcl"), close=True)
context = Context.of(hello=HelloStanza)
Interpreter(Evaluator()).execute(module, context)

Check out the full example at examples/hello.py.

Compatibility

hcl2-eval requires Python 3.6 or higher.

Metadata

Release files for hcl2-eval 0.1.3

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

Source distribution (sdist)

Source distribution for hcl2-eval 0.1.3
File Size Uploaded
hcl2-eval-0.1.3.tar.gz 5.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hcl2-eval 0.1.3
File Interpreter ABI Platform
hcl2_eval-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 11.9 kB

Release files / hcl2-eval-0.1.3.tar.gz

Download URL hcl2-eval-0.1.3.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f4875c27786fc26fb1d89df5e182f4c334feaab6a9b7f071e593ed6bf568cfd5
BLAKE2b-256 checksum
How to use checksums
294cbf5e4e5d7bdf1c3f9b16947132d83f37243ac5a4fa144e8630bc428218d5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

Release files / hcl2_eval-0.1.3-py3-none-any.whl

Download URL hcl2_eval-0.1.3-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
982f5b1a4069d0f95f42350a7646805143869bf960df687a3d4845ca0941d16c
BLAKE2b-256 checksum
How to use checksums
4000356831039e68bc53a708120045be670b035f97a6dda4ab4045890125c60f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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