Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

python-pie

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

python-pie

Parse static files such as YAML and insert in them data from environment variables

  • 0.2.4
  • PyPI
  • Socket score

Maintainers
1

python-pie

Build Status PyPI version PyPI - Python Version

Python-pie(python insert env) parses static files such as YAML and insert in them data from environment variables

Getting Started

pip install python-pie

You can use python-pie to insert env variables to static configurations, like that:

from pie import process_file

filepath = '/docker/configuration.yaml'
process_file(filepath)

The syntax of files supported by python-pie is similar to that of python fstrings:

f"54 {from_env or 'default_value'} some text"

Depends if your environment has a from_env variable or not, python-pie will load it, or in case of absence take the default value

Syntax example

hosts:
  - f"{host}"

loglevel: 4
f"{'log_file_path'}": f"/file/path/{filename or 'tmp.log'}"
log_rotate_count: 1

after process_file(filepath)

hosts:
  - localohst

loglevel: 4
log_file_path: /file/path/tmp.log
log_rotate_count: 1

Using as module from command line

You can use python-pie in command line.

python -m pie -f /node54/config.yml

Flags: (you should provide at least one of those)

  • -f --file path to config file.
  • -s --string string to precess.

optional:

  • -tf --to-file path to output config file.
  • --keep-file if pie should keep original file without change.

Docker example

docker create -t --name pie -i python:3.9 || true;
docker start pie;
docker exec pie python -m pip install python-pie;
docker exec pie python -m pie -f /node54/config.yml;

during build:

FROM python:3.9-alpine AS builder
RUN pip install python-pie
RUN python -m pie -f /tmp/template.yml -tf /app/config.yml -e .env

Run tests

To run tests install pytest library and run the command:

pytest tests/

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc