Skip to main content

Jinja2 File Generator

Project description

Jingen generates files from Jinja2 based template files.

Usage:

Assuming a vars file mock_vars.py

VARS = {
    "test_var": "vars_file_test_value"
}

and a template file: mock.template:

I'M A MOCK TEMPLATE AND MY VAR IS: {{ test_var }}
from jingen.jingen import Jingen

template_file = "mock.template"
vars_source = "tests/resources/mock_vars.py"  # alternatively, can be a dict
output_file = "tests/resources/manual_test_result.file"
templates_dir = "tests/resources/"
make_file = True
verbose = True

i = Jingen(
    template_file=template_file,
    vars_source=vars_source,
    output_file=output_file,
    templates_dir=templates_dir,
    make_file=make_file,
    verbose=verbose)
output = i.generate()

print output
...
I'M A MOCK TEMPLATE AND MY VAR IS: vars_file_test_value

Output would be:

### DEBUG - generating template from tests/resources//mock.template
### DEBUG - creating file: tests/resources/manual_test_result.file with content:
I'M A MOCK TEMPLATE AND MY VAR IS: vars_file_test_value

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

jingen-0.0.3.tar.gz (4.7 kB view details)

Uploaded Source

File details

Details for the file jingen-0.0.3.tar.gz.

File metadata

  • Download URL: jingen-0.0.3.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for jingen-0.0.3.tar.gz
Algorithm Hash digest
SHA256 24fd55a952b6d9bfb80cf70165afefee463d1c9544a5f27cb3796f8b66f7a29d
MD5 b91b4a82fa7e5c2d07e6ae03a77a6653
BLAKE2b-256 fad17c687fd5af369d4405ae89b44d75cfd31cddece1914233ee604363d17028

See more details on using hashes here.

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