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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file environment-parser-0.0.1.tar.gz.

File metadata

  • Download URL: environment-parser-0.0.1.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2

File hashes

Hashes for environment-parser-0.0.1.tar.gz
Algorithm Hash digest
SHA256 812e569fea323a6ca724b2d89bf16c15748fa455063d730d12a039cb0bdd7bf3
MD5 1b607d77898f4f9a43b0628e95fce7f1
BLAKE2b-256 d873141780d907a9b2993c2197e73d3ded8d7243bf11fe0e3dbfba4143cb791a

See more details on using hashes here.

File details

Details for the file environment_parser-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: environment_parser-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2

File hashes

Hashes for environment_parser-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c838134d3369a2fadd6b8a2d58c72338f27614c6e7c857a099d46857575ee916
MD5 989c482f101f7b18a9cf66ebe288c0d6
BLAKE2b-256 49d10d8b8b14c527a45d0f8a1f537268cc727f99c35c4fcd6de727aa6f618d02

See more details on using hashes here.

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