No project description provided
Project description
Python environment toolchain
Home-page: https://github.com/pedroburon/python-envtools
Author: Pedro Burón
Author-email: hi@pedroburon.info
License: MIT
Description-Content-Type: UNKNOWN
Description: =======================================
Useful environment toolchain for python
=======================================
.. image:: https://travis-ci.org/pedroburon/python-envtools.svg?branch=master
:target: https://travis-ci.org/pedroburon/python-envtools
.. image:: https://coveralls.io/repos/github/pedroburon/python-envtools/badge.svg?branch=master
:target: https://coveralls.io/github/pedroburon/python-envtools?branch=master
********************
override_environment
********************
Context Processor that overrides environment vars.
::
>>> @override_environment(DEBUG=False, FOO="Bar")
>>> def foo():
>>> print(os.getenv("FOO"))
>>> return os.getenv("DEBUG")
>>> foo()
FOO
"DEBUG"
::
>>> with override_environment(DEBUG="False", FOO="Bar"):
>>> print(os.getenv("FOO"))
>>> os.getenv("DEBUG")
FOO
"DEBUG"
*****************
configure_logging
*****************
Wrap a `configDict` inside configure_logging, then logging level could be controlled by environment variables
::
LOGGING = configure_logging({
"loggers": {
"module": {
"handlers": ["console"],
"level": "INFO",
},
}
})
For this example, environment variable must be set as `LOGGING_LEVEL_module=DEBUG`.
*******
get_env
*******
Similar to `os.getenv()` but evaluates string content (default) into simple python types.
::
>>> os.environ['FOO'] = "1"
>>> os.getenv('FOO')
"1"
>>> get_env('FOO')
1
>>> os.environ['FOO'] = "bar"
>>> get_env('FOO')
"bar"
>>> os.environ['FOO'] = "True"
>>> os.getenv('FOO')
"True"
>>> get_env('FOO')
True
>>> os.environ['FOO'] = "[1,2,3]"
>>> os.getenv('FOO')
"[1,2,3]"
>>> get_env('FOO')
[1, 2, 3]
it works for list, tuples, dictionaries, numbers, booleans and strings. And is safe!
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Home-page: https://github.com/pedroburon/python-envtools
Author: Pedro Burón
Author-email: hi@pedroburon.info
License: MIT
Description-Content-Type: UNKNOWN
Description: =======================================
Useful environment toolchain for python
=======================================
.. image:: https://travis-ci.org/pedroburon/python-envtools.svg?branch=master
:target: https://travis-ci.org/pedroburon/python-envtools
.. image:: https://coveralls.io/repos/github/pedroburon/python-envtools/badge.svg?branch=master
:target: https://coveralls.io/github/pedroburon/python-envtools?branch=master
********************
override_environment
********************
Context Processor that overrides environment vars.
::
>>> @override_environment(DEBUG=False, FOO="Bar")
>>> def foo():
>>> print(os.getenv("FOO"))
>>> return os.getenv("DEBUG")
>>> foo()
FOO
"DEBUG"
::
>>> with override_environment(DEBUG="False", FOO="Bar"):
>>> print(os.getenv("FOO"))
>>> os.getenv("DEBUG")
FOO
"DEBUG"
*****************
configure_logging
*****************
Wrap a `configDict` inside configure_logging, then logging level could be controlled by environment variables
::
LOGGING = configure_logging({
"loggers": {
"module": {
"handlers": ["console"],
"level": "INFO",
},
}
})
For this example, environment variable must be set as `LOGGING_LEVEL_module=DEBUG`.
*******
get_env
*******
Similar to `os.getenv()` but evaluates string content (default) into simple python types.
::
>>> os.environ['FOO'] = "1"
>>> os.getenv('FOO')
"1"
>>> get_env('FOO')
1
>>> os.environ['FOO'] = "bar"
>>> get_env('FOO')
"bar"
>>> os.environ['FOO'] = "True"
>>> os.getenv('FOO')
"True"
>>> get_env('FOO')
True
>>> os.environ['FOO'] = "[1,2,3]"
>>> os.getenv('FOO')
"[1,2,3]"
>>> get_env('FOO')
[1, 2, 3]
it works for list, tuples, dictionaries, numbers, booleans and strings. And is safe!
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for python_envtools-0.0.1.dev1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6f1dc922d4b489ba74c0d10353df632c18fdec9673f1b1facebc668889afe48 |
|
MD5 | eccba903774ac1e124a558b9322a983a |
|
BLAKE2b-256 | 11b9a1c454b9b67b2513385d663ca47392d7a55f7db0ed50ff637f0ed9f1b4d5 |