Git Product home page Git Product logo

python-json-via-jinja2-render's Introduction

About

Very simple script to get json input, pass it via Jinja2 template to get the output.

Why? Sometimes I got some simple json file and I want to process it into something easier to read, for example text file or html.

Other tools usually do too much already, like extra connecting to internet idk why...

Known limitations

  • not providing pip package, I'm too lazy and this is too simple to package it anyway.... or docker, yeaaaaaaahhh ;)
  • template used is TOTALLY dependent on json file used as input, see examples

Requirements

  • pretty sure it requires python
  • may require Jinja2

Usage

render.py --help

Examples

AWS ECR security scan output

Plain text short

python render.py \
  -i examples/aws_ecr_scan_result.json \
  -t templates/aws_ecr_scan_result_plaintext_short.j2 \
  -o examples/aws_ecr_scan_result_plaintext_short.txt

Plain text long

python render.py \
  -i examples/aws_ecr_scan_result.json \
  -t templates/aws_ecr_scan_result_plaintext_long.j2 \
  -o examples/aws_ecr_scan_result_plaintext_long.txt

HTML

This is a bit more useful :)

python render.py \
  -i examples/aws_ecr_scan_result.json \
  -t templates/aws_ecr_scan_result_html.j2 \
  -o examples/aws_ecr_scan_result_html.html

Fully rendered output here.

Docker

cat examples/aws_ecr_scan_result.json \
| docker run -v $(pwd)/templates/:/app/templates:ro -i quay.io/kaszpir/python-json-via-jinja2-render -t templates/aws_ecr_scan_result_html.j2 \
> output.html

or:

docker run \
    -v "$(pwd)/templates/:/app/templates:ro" \
    -i quay.io/kaszpir/python-json-via-jinja2-render \
        -t templates/aws_ecr_scan_result_html.j2 \
        <examples/aws_ecr_scan_result.json \
        >output.html

Running in container with custom templates

  • Create my_template dir with desired template
  • write my_template/custom.j2 file which is tailored to your json input files
  • Run command to get output to stdout:
cat examples/aws_ecr_scan_result.json \
| docker run -v $(pwd)/my_template/:/app/templates:ro -i quay.io/kaszpir/python-json-via-jinja2-render -t templates/custom.j2 \
> output.html

python-json-via-jinja2-render's People

Contributors

nvtkaszpir avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.