Skip to content

Instantly share code, notes, and snippets.

@douglasmiranda
Created April 9, 2018 21:57
Show Gist options
  • Save douglasmiranda/e14c3119cc1d0931999c6f90d3948673 to your computer and use it in GitHub Desktop.
Save douglasmiranda/e14c3119cc1d0931999c6f90d3948673 to your computer and use it in GitHub Desktop.
gconfigs
$ pipenv install gconfigs # or pip install gconfigs
$ pipenv run python
>>> from gconfigs import envs, configs, secrets
>>> envs('HOME', default='/')
'/'
>>> configs.as_bool('DEBUG', default=False)
False
>>> configs('DATABASE_USER')
'user'
>>> secrets('DATABASE_PASS')
'123'
>>> # envs, configs and secrets are iterables
>>> from gconfigs import envs
>>> for env in envs:
... print(env)
... print(env.key)
... print(env.value)
...
EnvironmentVariable(key='ENV_TEST', value='env-test-1')
ENV_TEST
env-test-1
...
>>> 'ENV_TEST' in envs
True
>>> envs.json()
'{"ENV_TEST": "env-test-1", "HOME": "/root", ...}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment