Smart Environment Wrapper Library
SmartEnv - OS Environment Wrapper Library
A flexible, easy-to-use library for managing environment variables in your Python script.
Why yet another one?
This library comes with a few major points to use it:
- It is easy and intuitive (see examples)
- It's compatible with Python 2 (can be useful in old large systems)
- Continuous support of the library
This library is pretty easy to use:
from smart_env import ENV print(ENV.HOME) # Equals print(os.environ['HOME']) # assuming you set env variable MYVAR to "True" ENV.enable_automatic_type_cast() my_var = ENV.MY_VAR # Equals boolean True ENV.NEW_VAR = 100 # Sets a new environment variable
How to use
In a few words, the logic is next:
- You can store a lot of serialized values in Environment variables and then deserialize them on fly using ENV class.
- Each environment variable can be accessed as an attribute of ENV class:
- The internal decoding mechanism is based on json and ast packages. That means, you can parse even some JSON-incompatible values (for example, with single quotes used for defining strings).
pip install smart-env
Running the tests
This library contains tests written using unittest module, so just run in the project directory
python -m unittest
Also it's possible to run tests using Tox:
tox -e <env>
Tests coverage is one of the important goals of this project. For now coverage is next:
- For Python 2.7: 98%
- For Python 3.x: 97%
- coverage (using Python 3)
- coverage (using Python 2.7)
- pep8 (style checking)
Old versions of Python in both generations (e.g. 2.6, 3.4, etc) will never be supported. However, you always can implement such support in your forks.
Parsing set() objects is not working in Python 2. See this for details.
- Alex Sokolov - Author - Albartash
- Telegram channel with updates: @bart_tools
This project is licensed under the MIT License - see the LICENSE.md file for details.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size smart_env-1.0.2-py2.py3-none-any.whl (10.9 kB)||File type Wheel||Python version py2.py3||Upload date||Hashes View|
Hashes for smart_env-1.0.2-py2.py3-none-any.whl