smart-env


Namesmart-env JSON
Version 1.0.5 PyPI version JSON
download
home_pagehttps://github.com/atcode-space/smart-env
SummarySmart Environment Wrapper Library
upload_time2022-12-28 20:21:32
maintainer
docs_urlNone
authorOleksandr Sokolov
requires_python>=2.7.*, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <3.12
license
keywords env environ smartenv
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # 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
- 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** - *Author* - [Albartash](https://github.com/AlBartash)

## Contacts

* Telegram channel with updates: [@bart_tools](http://t.me/bart_tools)

## 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": "",
    "docs_url": null,
    "requires_python": ">=2.7.*, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <3.12",
    "maintainer_email": "",
    "keywords": "env environ smartenv",
    "author": "Oleksandr Sokolov",
    "author_email": "volokolek@gmail.com",
    "download_url": "",
    "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- 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** - *Author* - [Albartash](https://github.com/AlBartash)\n\n## Contacts\n\n* Telegram channel with updates: [@bart_tools](http://t.me/bart_tools)\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Smart Environment Wrapper Library",
    "version": "1.0.5",
    "split_keywords": [
        "env",
        "environ",
        "smartenv"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "ddca6422d3697686605baaebda80e79a",
                "sha256": "e44bb784e7e1fe9edd1a668f1d7c1ea9ab46ccb5255bbee5838913bfcb481901"
            },
            "downloads": -1,
            "filename": "smart_env-1.0.5-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ddca6422d3697686605baaebda80e79a",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=2.7.*, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <3.12",
            "size": 11516,
            "upload_time": "2022-12-28T20:21:32",
            "upload_time_iso_8601": "2022-12-28T20:21:32.263193Z",
            "url": "https://files.pythonhosted.org/packages/21/4d/9446c115183a64c542b0dfaa302eaf3cba91c4a1281df76ee6c6c672d9a0/smart_env-1.0.5-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-28 20:21:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "atcode-space",
    "github_project": "smart-env",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": false,
    "tox": true,
    "lcname": "smart-env"
}
        
Elapsed time: 0.02237s