Skip to main content

jinjarecurse CLI tool


PyPI GitHub Workflow Status GitHub PyPI - Downloads


Jinja Recursive Templating for the CLI. Recursively template one file or many folders of many files like a config management languages allow, without the whole config management language. Useful if you're switching from managing an application from config management to just docker and need some simple templating logic.

Installation

pip install jinjarecurse

Example Usage

$ jinjarecurse --help
 jinjarecurse (CLI)

Usage:
    jinjarecurse --vars=VARS_FILE --input=INPUT_PATH --output=OUTPUT_PATH

Options:
    -v <file>, --vars   <file>
    -i <file>, --input  <file>
    -o <file>, --output <file>

Single file

Given a config file containing your variables e.g. vars.yaml:

#comment: not available
root: /
number: 1
dictionary:
    street: 123 North Ave
    city: New York
    state: New York
list:
    - ABC
    - DEF
    - HJK
layer_1:
    layer_2:
        layer_3: last

And an input file jinja2 template e.g. i_file:

# Top level
{{root}}
{{number}}
{{dictionary}}
{{list}}
{{layer_1}}

# Nested data

{{dictionary.street}}
{{dictionary.city}}
{{dictionary.state}}
{{layer_1.layer_2.layer_3}}

You can populate it and specify an output filepath e.g. o_file:

$ jinjarecurse -v example/vars.yaml -i example/i_file -o example/o_file
WARNING: example/o_file (output) exists and any conflicting files will be overwritten
Writing from example/i_file to example/o_file

Contents of the output file e.g. o_file:

# Top level
/
1
{'street': '123 North Ave', 'city': 'New York', 'state': 'New York'}
['ABC', 'DEF', 'HJK']
{'layer_2': {'layer_3': 'last'}}

# Nested data

123 North Ave
New York
New York
last

Directory

You can also template an entire directory e.g. i_dir at once. Note the output files in the output directory will maintain the filenames from the input directory:

$ jinjarecurse -v example/vars.yaml -i example/i_dir -o example/o_dir
Writing from example/i_dir/i_file to example/o_dir/i_file
Writing from example/i_dir/i_file_1 to example/o_dir/i_file_1
Writing from example/i_dir/i_file_2 to example/o_dir/i_file_2

Tests

To run the unit tests, first install the dependencies:

$ pipenv install --dev .

Then invoke pytest:

$ pipenv run py.test -vvvs

Changelog

Please see the Releases and CHANGELOG.md.

Metadata

Release files for jinjarecurse 0.0.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 jinjarecurse 0.0.3
File Size Uploaded
jinjarecurse-0.0.3.tar.gz 3.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for jinjarecurse 0.0.3
File Interpreter ABI Platform
jinjarecurse-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 8.0 kB

Release files / jinjarecurse-0.0.3.tar.gz

Download URL jinjarecurse-0.0.3.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
231786f104f2d9ab7fcaa6a07f73cf6d13fdd6ebd033ad2073e24a521db1e68d
BLAKE2b-256 checksum
How to use checksums
fe310184376acb2a2b74bf3c6d7121bf78672174599437ebe39b60fc9a7df521
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.9

Release files / jinjarecurse-0.0.3-py3-none-any.whl

Download URL jinjarecurse-0.0.3-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ddac487f8db514b6605a69bf89796b230e61891e84bcca3163768ed701354ace
BLAKE2b-256 checksum
How to use checksums
7c257569ecdd8353be30a178a67e180a74af0c794d42712ce094cbcb956ffa65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.9

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

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