Skip to main content

.env file parser with interpolation and multi-file support

Project description

philiprehberger-env-file

Tests PyPI version License

.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.2.tar.gz (4.6 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.2-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for philiprehberger_env_file-0.1.2.tar.gz
Algorithm Hash digest
SHA256 3d1c87f4da26db672b325960268707936e62a530f6393f51801c163412edef0c
MD5 c1115474fd3aa4b66029859c9009160d
BLAKE2b-256 58c9daac5d2aac1361b4143a6419202876f64cf04919034b821758af2db95033

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for philiprehberger_env_file-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1331d32e73e07fc9c3e77ea7680675d8e02658ff6b621ae7e1aae59ba37e24c3
MD5 77c236a7515b3790993fa5fa41e097a0
BLAKE2b-256 52b839a08efa91bd0cd2eafd1fe725249134a14f4f3d2995d5a9b7f67c73cb86

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