Skip to main content

Lightweight library to parse environment variables from shell, stdin or .env file in python.

Project description

Environment-Parser

A lightweight python library to parse environment variables from current shell or .env files.

Installation

Usage

Create a new environment parser from shell context.

from environment import Environment, SHELL
env = Environment(sources=[SHELL])

You can also create a new environment parser from variables starting with a given prefix. For example, to find all variables starting with XDG_, you could use the code below...

xdgenv = env.extract_child_from_prefix('XDG_', remove_prefix=True)
print(xdgenv)

... and this will output something like the following :

CONFIG_DIRS                   /etc/xdg/xdg-budgie-desktop:/etc/xdg
SESSION_PATH                  /org/freedesktop/DisplayManager/Session0
MENU_PREFIX                   gnome-              
SESSION_DESKTOP               budgie-desktop      
SESSION_TYPE                  x11                 
GREETER_DATA_DIR              /var/lib/lightdm-data/sylvan

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

environment-parser-0.0.1.tar.gz (3.1 kB view hashes)

Uploaded Source

Built Distribution

environment_parser-0.0.1-py3-none-any.whl (3.9 kB view hashes)

Uploaded Python 3

Supported by

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