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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

Details for the file template-file-parser-0.14.tar.gz.

File metadata

File hashes

Hashes for template-file-parser-0.14.tar.gz
Algorithm Hash digest
SHA256 0ccf9c48506ebcb1c764edff12030bb849476c2b500a478dd528fd82db7e6624
MD5 2b497d2bea18b796ee4bbaa376bcfa9e
BLAKE2b-256 72278e643cbea0b1250d4d9cb8e95bd466f1b029e9ad58282a97346e29bf6759

See more details on using hashes here.

File details

Details for the file template_file_parser-0.14-py3-none-any.whl.

File metadata

File hashes

Hashes for template_file_parser-0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 43a7aa3d00b9cc098bb87d856bcac5dfaa7f3faf483183f42cf106cc5b731ef3
MD5 0835681112f02f418c986ed4821883b7
BLAKE2b-256 b27b5759531bb7c22f282562b0835c7da8631e658cef27663166432d88543cc7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page