# 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
## Getting started
This library is pretty easy to use:
```python
from smart_env import ENV
print(ENV.HOME) # Equals print(os.environ['HOME'])
# Apply type cast wherever you need by using ENV as a context manager
with ENV:
# assuming you set env variable MYVAR to "True" in shell
my_var = ENV.MY_VAR # Equals boolean True
# And here type cast is automatically disabled
my_second_var = ENV.MY_VAR # Equals 'True' as string
# Enabling automatic type cast for all the further commands
ENV.enable_automatic_type_cast()
# assuming you set env variable MYVAR to "True" in shell
my_var = ENV.MY_VAR # Equals boolean True
ENV.NEW_VAR = 100 # Sets a new environment variable
# Disabling automatic type cast
ENV.enable_automatic_type_cast()
```
## How to use
In a few words, the logic is next:
1. You can store a lot of serialized values in Environment variables and then deserialize them on fly using ENV class.
2. Each environment variable can be accessed as an attribute of ENV class:
```python
ENV.<variable_name>
```
3. 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).
### Installing
Simply run
```
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
```
It's possible to run tests using Tox as well:
```bash
tox -e <env>
```
or just
```bash
tox
```
Tests coverage is one of the important goals of this project.
For now coverage is next:
- For Python 2.7: 99%
- For Python 3.x: 97%
Supported environments:
- py27
- py35
- py36
- py37
- py38
- py39
- py310
- py311
- py312
- coverage (using Python 3)
- coverage27 (using Python 2.7)
- pep8 (style checking)
## Restrictions
1. 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.
2. Parsing set() objects is not working in Python 2. See [this](https://bugs.python.org/issue10091) for details.
## Authors
* **Olek Sokolov** - [Albartash](https://github.com/AlBartash)
## License
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.
Raw data
{
"_id": null,
"home_page": "https://github.com/atcode-space/smart-env",
"name": "smart-env",
"maintainer": null,
"docs_url": null,
"requires_python": "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,<3.13,>=2.7.0",
"maintainer_email": null,
"keywords": "env environ smartenv",
"author": "Oleksandr Sokolov",
"author_email": "volokolek@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/71/3f/137b49bf97b269db5c44202cf6fbcd6f612f415345ac4f30b71bb27ef696/smart_env-1.0.6.tar.gz",
"platform": null,
"description": "# SmartEnv - OS Environment Wrapper Library\n\nA flexible, easy-to-use library for managing environment variables in your Python script.\n\n## Why yet another one?\n\nThis library comes with a few major points to use it:\n\n* It is easy and intuitive (see examples)\n* It's compatible with Python 2 (can be useful in old large systems)\n* Continuous support of the library\n\n## Getting started\n\nThis library is pretty easy to use:\n\n```python\nfrom smart_env import ENV\n\nprint(ENV.HOME) # Equals print(os.environ['HOME'])\n\n# Apply type cast wherever you need by using ENV as a context manager\n\nwith ENV:\n # assuming you set env variable MYVAR to \"True\" in shell\n my_var = ENV.MY_VAR # Equals boolean True\n# And here type cast is automatically disabled\nmy_second_var = ENV.MY_VAR # Equals 'True' as string\n\n# Enabling automatic type cast for all the further commands\nENV.enable_automatic_type_cast()\n\n# assuming you set env variable MYVAR to \"True\" in shell\nmy_var = ENV.MY_VAR # Equals boolean True\n\nENV.NEW_VAR = 100 # Sets a new environment variable\n\n# Disabling automatic type cast\nENV.enable_automatic_type_cast()\n```\n\n## How to use\n\nIn a few words, the logic is next:\n1. You can store a lot of serialized values in Environment variables and then deserialize them on fly using ENV class.\n2. Each environment variable can be accessed as an attribute of ENV class:\n ```python\n ENV.<variable_name>\n ```\n3. The internal decoding mechanism is based on **json** and **ast** packages. That means, \nyou can parse even some JSON-incompatible values (for example, with single quotes used for defining strings).\n\n### Installing\n\nSimply run\n\n```\npip install smart-env\n```\n\n## Running the tests\n\nThis library contains tests written using *unittest* module, so just run in the project directory\n\n```\npython -m unittest\n```\n\nIt's possible to run tests using Tox as well:\n\n```bash\ntox -e <env>\n```\n\nor just\n\n```bash\ntox\n```\n\nTests coverage is one of the important goals of this project.\nFor now coverage is next:\n- For Python 2.7: 99%\n- For Python 3.x: 97%\n\nSupported environments:\n\n- py27\n- py35\n- py36\n- py37\n- py38\n- py39\n- py310\n- py311\n- py312\n- coverage (using Python 3)\n- coverage27 (using Python 2.7)\n- pep8 (style checking)\n\n## Restrictions\n\n1. Old versions of Python in both generations (e.g. 2.6, 3.4, etc) will never be supported. \nHowever, you always can implement such support in your forks.\n\n2. Parsing set() objects is not working in Python 2. See [this](https://bugs.python.org/issue10091) for details.\n\n\n## Authors\n\n* **Olek Sokolov** - [Albartash](https://github.com/AlBartash)\n\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.\n",
"bugtrack_url": null,
"license": null,
"summary": "Smart Environment Wrapper Library",
"version": "1.0.6",
"project_urls": {
"Homepage": "https://github.com/atcode-space/smart-env",
"Source": "https://github.com/atcode-space/smart-env/"
},
"split_keywords": [
"env",
"environ",
"smartenv"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "db00e7e4a37d9b80a870669f37e603964803d0fa6472e63f3bb2b17e9f94082b",
"md5": "b76d7e9c9345b1878f8169e5060b4012",
"sha256": "3adb95ea64ba72671705bc94baa94ae4208f9b5ea2894ff5bdfa3eec3b61ca4c"
},
"downloads": -1,
"filename": "smart_env-1.0.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b76d7e9c9345b1878f8169e5060b4012",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,<3.13,>=2.7.0",
"size": 11515,
"upload_time": "2025-01-28T23:17:58",
"upload_time_iso_8601": "2025-01-28T23:17:58.522561Z",
"url": "https://files.pythonhosted.org/packages/db/00/e7e4a37d9b80a870669f37e603964803d0fa6472e63f3bb2b17e9f94082b/smart_env-1.0.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "713f137b49bf97b269db5c44202cf6fbcd6f612f415345ac4f30b71bb27ef696",
"md5": "c13c2e7ddc42ec782967132e905902de",
"sha256": "d0777d61cfefee014c9a418058fe97e9abae198641d18d074ce21e0298b0fe6f"
},
"downloads": -1,
"filename": "smart_env-1.0.6.tar.gz",
"has_sig": false,
"md5_digest": "c13c2e7ddc42ec782967132e905902de",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,<3.13,>=2.7.0",
"size": 12157,
"upload_time": "2025-01-28T23:18:00",
"upload_time_iso_8601": "2025-01-28T23:18:00.104423Z",
"url": "https://files.pythonhosted.org/packages/71/3f/137b49bf97b269db5c44202cf6fbcd6f612f415345ac4f30b71bb27ef696/smart_env-1.0.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-28 23:18:00",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "atcode-space",
"github_project": "smart-env",
"travis_ci": false,
"coveralls": true,
"github_actions": false,
"tox": true,
"lcname": "smart-env"
}