Skip to main content

A Python package for environment management.

Project description

Liexa-env

Liexa-env is a Python package to manage environment variables easily. It supports loading, parsing, and exporting variables from files, including .env, JSON, and YAML formats.

Features

  • Load environment variables from .env, JSON, or YAML files.
  • Supports environment-based auto-loading.
  • Retrieve variables with specific data types (e.g., int, bool, list).
  • Export variables to a file or print them with masking options for sensitive information.

Installation

Install with pip:

pip install liexa-env

Usage

Initialization in a Project

Initialize Liexa-env by importing and creating an instance:

from liexa_env import env

Loading Environment Variables

Auto-loading (Recommended)

Liexa-env automatically loads environment variables based on the ENV system variable. If ENV is set to production, the package looks for .env.production files in the project root.

  • File Priority: .env.<ENV> (e.g., .env.production) > .env
  • Supported Formats: .env, .json, .yaml

Manual Loading

To manually load files, specify file paths and control load order. Later files override earlier ones if they have the same variable names.

env.load(["config.yaml", "settings.env"], overwrite_system=True)
  • Order Matters: Variables in files loaded later override earlier ones.
  • Overwrite System: Set overwrite_system to True to let loaded files override system environment variables.

Accessing Environment Variables

Reading Variables

Access environment variables using attribute syntax:

db_host = env.DB_HOST

Or use specific data types:

db_port = env.as_int("DB_PORT")
debug_mode = env.as_bool("DEBUG")
allowed_ips = env.as_list("ALLOWED_IPS")

Setting Variables

Set a variable directly:

env.NEW_SETTING = "some_value"

Printing Environment Variables

Print variables with options to hide sensitive values and include system variables:

# Print with sensitive values masked
env.print(show_sensitive=False, include_system=True)

Exporting to a File

Export all variables to a file:

env.export_to_file("output.env", include_system=True)
  • File Path: Specify the path for the output file.
  • Include System: Include both system and loaded variables by setting include_system=True.

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

liexa_env-0.0.10.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

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

liexa_env-0.0.10-py3-none-any.whl (20.8 kB view details)

Uploaded Python 3

File details

Details for the file liexa_env-0.0.10.tar.gz.

File metadata

  • Download URL: liexa_env-0.0.10.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for liexa_env-0.0.10.tar.gz
Algorithm Hash digest
SHA256 1d98f28314f5eb0c7dd954d7767327feb95a5d0d2d5d806173b93e235e5030b6
MD5 11df723f70e8e9f42f7e02969dbe5437
BLAKE2b-256 677506578ad72e0fa17703fddb60cddaee8140a0806806ee1956b012f6be46e6

See more details on using hashes here.

File details

Details for the file liexa_env-0.0.10-py3-none-any.whl.

File metadata

  • Download URL: liexa_env-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 20.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for liexa_env-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 401876b28564f5e1d0a9c2069091e8252b74ed393e27b7a1fe9f8962c99ccb3a
MD5 d31d87d7920516615da190300194a145
BLAKE2b-256 731fb280b15c90571a50d0821fa127e94204f90d29a0eb33b9c5962f9aa9b44f

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