Skip to main content

.env file parser with interpolation and multi-file support

Project description

philiprehberger-env-file

.env file parser with interpolation and multi-file support.

Installation

pip install philiprehberger-env-file

Usage

Load into Environment

from philiprehberger_env_file import load_env

# Load .env (default)
load_env()

# Load multiple files (later files override earlier)
load_env(".env", ".env.local")

# Don't override existing env vars
load_env(override=False)

Parse Without Modifying Environment

from philiprehberger_env_file import parse_env_file

config = parse_env_file(".env")
print(config["DATABASE_URL"])

Supported Syntax

# Comments
KEY=value
export KEY=value

# Quoted values
SINGLE='no interpolation here'
DOUBLE="supports\nnewlines"

# Variable interpolation
BASE_URL=https://api.example.com
API_URL=${BASE_URL}/v1

# Empty values
EMPTY_VAR=

# Inline comments (unquoted values only)
HOST=localhost # this is a comment

API

  • load_env(*paths, override=True) — Load .env files into os.environ, returns dict of loaded vars
  • parse_env_file(path) — Parse a .env file, returns dict without modifying environment

License

MIT

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

philiprehberger_env_file-0.1.1.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

philiprehberger_env_file-0.1.1-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file philiprehberger_env_file-0.1.1.tar.gz.

File metadata

  • Download URL: philiprehberger_env_file-0.1.1.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for philiprehberger_env_file-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f607ce26a2a049bba44e45f1c89bdca9341d82c95735532460d3b6dea28a8bbf
MD5 f0a8cd13dd58b99866653491afb4c36d
BLAKE2b-256 cb8523042a369d5dd03aec1e9dacc5621539373d4ae2574f6c7bdce760077c04

See more details on using hashes here.

File details

Details for the file philiprehberger_env_file-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for philiprehberger_env_file-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 62d7aafc70d85af2de8c64719c6573b173d17fdaeb5ab5e27b720bddd2f2aea2
MD5 95cbe6476003e862e08aaf9a055da96d
BLAKE2b-256 c6e2db6cf845ce37b554f3a3883e82bb961912a823954095fe814f011a2ed2b0

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