Skip to main content

Tiny wrapper over string templates which works with files

Project description

Codacy Badge Codacy Coverage

Build Status

template-file-parser is an convenient module for parsing files with the python template syntax.

This module was inspired by the following Stack overview post.

The need of this module was for me to have an easy templating system manipulating configuration files, without learning a more complete but complicated templating system. This is especially with configuration files of solr of kubernetes where just a small list of variables needs to be interpolated and written into a file.

Installation

pip install template-file-parser

Usage

from template_file_parser import parse_file
parse_file(in_file, out_file, variables, safe=False)

These are the parameters:

  • in_file: The input file

  • out_file: The output file

  • variables : a dictionary where the keys are the variables in the template and the values are the values needed to substitute

  • safe: if True then then not all variables in the template file needs to be declared. If False, all parameters needs to be declared. For more information read here

Disclaimer

This library is only supported for python >= 3.4 as it fits my needs, and i don’t want to mees up with the encoding differences between python 2 and 3. This software is beta and breaking changes can occur between versions

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

template-file-parser-0.14.tar.gz (2.4 kB view hashes)

Uploaded Source

Built Distribution

template_file_parser-0.14-py3-none-any.whl (4.5 kB view hashes)

Uploaded Python 3

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