Skip to main content

dict-like grouping of environment variables

Project description

# dict-envy

dict-like grouping of environment variables :sparkles:


Imagine you have this:

COUNTRIES_GB_NAME="United Kingdom"

and with a simple call you can have all of this:

>>> import os
>>> import dictenvy
>>> import pprint
>>> env = dictenvy.dictate(os.environ, depth=2)
>>> pprint.pprint(env)
{'countries': {'gb': {'name': 'United Kingdom', 'tld': '.uk'},
'hk': {'name': 'China', 'tld': '.cn'}}}

`depth` is how you regulate the depth of the returned dictionary.

<details><summary>Couple gotchas</summary>

### #1

Sometimes you may encounter the following situation:


In which case, the return value would still be a dict, but `TERM` value would have an empty key like so:

>>> import dictenvy
>>> import pprint
>>> env = dictenvy.dictate({'TERM': 'xterm-256color', 'TERM_PROGRAM': 'Apple_Terminal'}, depth=1))
>>> pprint.pprint(env)
{'term': {'': 'xterm-256color', 'program': 'Apple_Terminal'}}

### #2

Variables that start with an underscore will be left alone.

## Installation

Use pip:

$ pip install dict-envy

## License


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

dict-envy-0.2.0.tar.gz (2.5 kB view hashes)

Uploaded Source

Built Distribution

dict_envy-0.2.0-py3-none-any.whl (2.8 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