pydotenvs


Namepydotenvs JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://github.com/ableinc/pyenv
SummaryImport environment variables from your .env file or run as command line tool; PyDotEnv Cli.
upload_time2022-07-12 19:15:35
maintainer
docs_urlNone
authorJaylen Douglas
requires_python
license
keywords environment variables deployments settings env pydotenvs configurations python pydotenvs python3 dependencies
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PY.Env

Import environment variables from your .env file or run as command line tool; PyDotEnv Cli.

* Python 3
* Command line tool

## Version

Stable: v0.2.0

## How to use

```bash
pip install pydotenvs

or 

git clone https://github.com/ableinc/pyenv.git
cd pyenv
pip install --editable .
```

Now import into any python project you have <br />

``` python
from pydotenvs import load_env
load_env()
```

or <br />

```python
load_env('.myEnvFile')
```

or <br />

```python
envObj = load_env_object()
envObj['myEnv']

# New
envObj = load_env_object(values_as_datatype=True)
envObj['myEnv']

# The example above will return the values in the dictionary as their respective data types.
```

That's it!

## Demo

Run this to see a working example

```python
python example/demo.py
```

## StringIO

You can load your local .env file as a StringIO object.
By default you are responsible for closing the StringIO
object. Though, there is an option to auto close upon program
termination.

```python
from pydotenvs import load_env
stringObj = load_env(stringIO = True, auto_close = True)
contents = stringObj.getvalue()
```

## Transfer

You can now transfer an existing .env file variables to a new .env file,
with the option of preserving or overriding the existing values in the new
.env file. You can use this feature via the CLI tool or by importing the
function from the pydotenvs library. Preserve is True by default. Example:

```python
from pydotenvs import transfer_new_env, load_env
transfer_new_env(old_env_path = '.env', new_env_path = '.env-new', preserve = True)
# load_env('.env-new')
```

or

```bash
pyenv -f .env -n .newenv -t True
```

## Clear

You can clear environment variables during runtime with the ```clear_env```
function. You can provide the .env file path or use the default file path.
If you've ran a transfer during the current runtime, it will only remove the
variables set in the new environment variable file. By default it will only
clear the environment variables set in the .env file path provided. Example:

```python
from pydotenvs import clear_env
clear_env(env_path = '.env', module_init_only=True)
```

## Command Line Tool - CLI

You can use PyEnv as a command line tool. All the same features apply.
It would be common to use the client tool for the Dictionary & StringIO
features of PyEnv.

You can run a command that requires your local environment variables
with PyEnv command line tool. Your variables will only exist in
that one instance.

```bash
 pyenv --command 'echo $MY_VARIABLE'
 ```

```bash
Usage: pyenv [OPTIONS]

Options:
  -f, --envpath PATH      Location of .env file, defaults to .env in current
                          working directory  [required]
  -n, --newpath PATH      Location of new .env file that you would like to
                          transfer old env file variables to
  -t, --transfer BOOLEAN  This must be true if you would like to transfer.
                          --newpath is required as well.
  -p, --preserve BOOLEAN  True or False whether or not to preserve existing
                          envs during transfer
  -c, --command TEXT      Run a command that requires local enviornment
                          variables for one instance
  -l, --loadobj BOOLEAN   Load .env file as object instead of environment
                          variable
  -s, --stringio BOOLEAN  Load .env file as StringIO object instead of
                          environment variable
  --clear BOOLEAN         Clear the environment variables set by pydotenvs or
                          all variables during runtime.
  -v, --verbose BOOLEAN   Verbose
  --version               Show the version and exit.
  --help                  Show this message and exit.
  ```

## Changelog

* July 2022 - Minor version update
  * When using ***load_env_object()*** you can now return the values as their respective data type. i.e ***load_env_object('.env', values_as_datatype=True)*** (Note: default is False. Data types supported are integer, float, dictionary, string, and list.)
  * Squashed some bugs :)
* March 2022 - Minor version udpate
  * Bug fix where 'PWD' key was not found on linux systems.
* January 2022 - Minfor version update
  * You can now transfer an old .env file document to a new .env file document. Described above.
  * Before, the .env file was required at root of the project directory. This is no longer the case, you
    can now give any file path on the system.
  * Option to clear all environment variables or only the ones imported by pydotenvs - Default: module_init_only=True
* October 2020 - Minor version update
  * Any message that should/shall be printed (unrelated to an error) will be controlled by the boolean value of verbose.
  * Cleaned the CLI code, slightly

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ableinc/pyenv",
    "name": "pydotenvs",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "environment variables,deployments,settings,env,pydotenvs,configurations,python,pydotenvs,python3,dependencies",
    "author": "Jaylen Douglas",
    "author_email": "douglas.jaylen@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/cd/51/353bb71db59b5533cc3006c689a6567fd9b44ead9295659d4877c3661a9f/pydotenvs-0.2.0.tar.gz",
    "platform": null,
    "description": "# PY.Env\n\nImport environment variables from your .env file or run as command line tool; PyDotEnv Cli.\n\n* Python 3\n* Command line tool\n\n## Version\n\nStable: v0.2.0\n\n## How to use\n\n```bash\npip install pydotenvs\n\nor \n\ngit clone https://github.com/ableinc/pyenv.git\ncd pyenv\npip install --editable .\n```\n\nNow import into any python project you have <br />\n\n``` python\nfrom pydotenvs import load_env\nload_env()\n```\n\nor <br />\n\n```python\nload_env('.myEnvFile')\n```\n\nor <br />\n\n```python\nenvObj = load_env_object()\nenvObj['myEnv']\n\n# New\nenvObj = load_env_object(values_as_datatype=True)\nenvObj['myEnv']\n\n# The example above will return the values in the dictionary as their respective data types.\n```\n\nThat's it!\n\n## Demo\n\nRun this to see a working example\n\n```python\npython example/demo.py\n```\n\n## StringIO\n\nYou can load your local .env file as a StringIO object.\nBy default you are responsible for closing the StringIO\nobject. Though, there is an option to auto close upon program\ntermination.\n\n```python\nfrom pydotenvs import load_env\nstringObj = load_env(stringIO = True, auto_close = True)\ncontents = stringObj.getvalue()\n```\n\n## Transfer\n\nYou can now transfer an existing .env file variables to a new .env file,\nwith the option of preserving or overriding the existing values in the new\n.env file. You can use this feature via the CLI tool or by importing the\nfunction from the pydotenvs library. Preserve is True by default. Example:\n\n```python\nfrom pydotenvs import transfer_new_env, load_env\ntransfer_new_env(old_env_path = '.env', new_env_path = '.env-new', preserve = True)\n# load_env('.env-new')\n```\n\nor\n\n```bash\npyenv -f .env -n .newenv -t True\n```\n\n## Clear\n\nYou can clear environment variables during runtime with the ```clear_env```\nfunction. You can provide the .env file path or use the default file path.\nIf you've ran a transfer during the current runtime, it will only remove the\nvariables set in the new environment variable file. By default it will only\nclear the environment variables set in the .env file path provided. Example:\n\n```python\nfrom pydotenvs import clear_env\nclear_env(env_path = '.env', module_init_only=True)\n```\n\n## Command Line Tool - CLI\n\nYou can use PyEnv as a command line tool. All the same features apply.\nIt would be common to use the client tool for the Dictionary & StringIO\nfeatures of PyEnv.\n\nYou can run a command that requires your local environment variables\nwith PyEnv command line tool. Your variables will only exist in\nthat one instance.\n\n```bash\n pyenv --command 'echo $MY_VARIABLE'\n ```\n\n```bash\nUsage: pyenv [OPTIONS]\n\nOptions:\n  -f, --envpath PATH      Location of .env file, defaults to .env in current\n                          working directory  [required]\n  -n, --newpath PATH      Location of new .env file that you would like to\n                          transfer old env file variables to\n  -t, --transfer BOOLEAN  This must be true if you would like to transfer.\n                          --newpath is required as well.\n  -p, --preserve BOOLEAN  True or False whether or not to preserve existing\n                          envs during transfer\n  -c, --command TEXT      Run a command that requires local enviornment\n                          variables for one instance\n  -l, --loadobj BOOLEAN   Load .env file as object instead of environment\n                          variable\n  -s, --stringio BOOLEAN  Load .env file as StringIO object instead of\n                          environment variable\n  --clear BOOLEAN         Clear the environment variables set by pydotenvs or\n                          all variables during runtime.\n  -v, --verbose BOOLEAN   Verbose\n  --version               Show the version and exit.\n  --help                  Show this message and exit.\n  ```\n\n## Changelog\n\n* July 2022 - Minor version update\n  * When using ***load_env_object()*** you can now return the values as their respective data type. i.e ***load_env_object('.env', values_as_datatype=True)*** (Note: default is False. Data types supported are integer, float, dictionary, string, and list.)\n  * Squashed some bugs :)\n* March 2022 - Minor version udpate\n  * Bug fix where 'PWD' key was not found on linux systems.\n* January 2022 - Minfor version update\n  * You can now transfer an old .env file document to a new .env file document. Described above.\n  * Before, the .env file was required at root of the project directory. This is no longer the case, you\n    can now give any file path on the system.\n  * Option to clear all environment variables or only the ones imported by pydotenvs - Default: module_init_only=True\n* October 2020 - Minor version update\n  * Any message that should/shall be printed (unrelated to an error) will be controlled by the boolean value of verbose.\n  * Cleaned the CLI code, slightly\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Import environment variables from your .env file or run as command line tool; PyDotEnv Cli.",
    "version": "0.2.0",
    "split_keywords": [
        "environment variables",
        "deployments",
        "settings",
        "env",
        "pydotenvs",
        "configurations",
        "python",
        "pydotenvs",
        "python3",
        "dependencies"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ff2d57587d79693bab97b50433d88e7c51ddd0e01c9d716ce1a6b42c85561651",
                "md5": "be536b37a710cea53ed9df681423d7e3",
                "sha256": "e17f5b8b2826ecf9fd6e1124e1613867d2f2a47dc8518355b915994987ca757d"
            },
            "downloads": -1,
            "filename": "pydotenvs-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "be536b37a710cea53ed9df681423d7e3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 7600,
            "upload_time": "2022-07-12T19:15:30",
            "upload_time_iso_8601": "2022-07-12T19:15:30.625054Z",
            "url": "https://files.pythonhosted.org/packages/ff/2d/57587d79693bab97b50433d88e7c51ddd0e01c9d716ce1a6b42c85561651/pydotenvs-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cd51353bb71db59b5533cc3006c689a6567fd9b44ead9295659d4877c3661a9f",
                "md5": "db2f578916f99ec28accc6e0ef02ea47",
                "sha256": "cb74f7371dec9a955731d41c6a6b32b0abd6366075f5da89e50c4624275832fd"
            },
            "downloads": -1,
            "filename": "pydotenvs-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "db2f578916f99ec28accc6e0ef02ea47",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 6846,
            "upload_time": "2022-07-12T19:15:35",
            "upload_time_iso_8601": "2022-07-12T19:15:35.382833Z",
            "url": "https://files.pythonhosted.org/packages/cd/51/353bb71db59b5533cc3006c689a6567fd9b44ead9295659d4877c3661a9f/pydotenvs-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-07-12 19:15:35",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "ableinc",
    "github_project": "pyenv",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pydotenvs"
}
        
Elapsed time: 0.04081s