Skip to main content
# dict-envy

dict-like grouping of environment variables :sparkles:

---

Imagine you have this:

```
COUNTRIES_GB_NAME="United Kingdom"
COUNTRIES_GB_TLD=.uk
COUNTRIES_HK_NAME=China
COUNTRIES_HK_TLD=.cn
```

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

```python
>>> 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:

```
TERM_PROGRAM=Apple_Terminal
TERM=xterm-256color
```

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

```python
>>> 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.
</details>

## Installation

Use pip:

```shell
$ pip install dict-envy
```

## License

MIT


Release files for dict-envy 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dict-envy 0.2.0
File Size Uploaded
dict-envy-0.2.0.tar.gz 2.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dict-envy 0.2.0
File Interpreter ABI Platform
dict_envy-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 5.3 kB

Release files / dict-envy-0.2.0.tar.gz

Download URL dict-envy-0.2.0.tar.gz
Size 2.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2e7ad15f380a8cb6ffa36384cd4cdfab70b50fd3a515aeb0bef32bdde0b25193
BLAKE2b-256 checksum
How to use checksums
9f8b3a42fc2e7302e1512b16a29b649d0adbbdcb13f281517c7249de49cc6bc5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / dict_envy-0.2.0-py3-none-any.whl

Download URL dict_envy-0.2.0-py3-none-any.whl
Size 2.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7fceff87679a806f13952d56fdbc1bb197c850af4591c19b3643f8c85eb34344
BLAKE2b-256 checksum
How to use checksums
37198fd01c3cfadb46a2c3ab308143a3e77d47199d96e5858295d88f71afdd02
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page