secret-garden


Namesecret-garden JSON
Version 1.0.0 PyPI version JSON
download
home_page
SummaryA better way to manage your dotenv variables
upload_time2024-02-26 08:40:58
maintainer
docs_urlNone
authorDanielMuringe
requires_python>=3.10,<4.0
license
keywords dotenv environment variables environment variables dotenv variables typed dotenv typed environment variables typed dotenv variables dotenv management environment management secret variables
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # [secret-garden](https://github.com/danielmuringe/secret-garden)
## A better way to manage your dotenv variables


### Installation
- You can use your most preferred package manager to install the package

    `pip install secret-garden` or `poetry add secret-garden` ...


## Table of Contents

1. [Usage](#usage)
    - [loading from a file](#load_file-function)
    - [loading from the environment namespace](#load_space-function)
    - [loading from a file using the environment namespace as an alternative](#load-function)

1. [Examples](#examples)
    - [Using a file](#using-a-file)
        - [env](#env)
        - [json](#json)
        - [toml](#toml)
        - [yaml](#yaml)
    - [Using the environment namespace](#using-the-environment-namespace)

1. [Objects](#objects)
    - [load](#load)
    - [load_file](#load_file)
    - [load_space](#load_space)

1. [Upcoming Features](#upcoming-features)


<h2 id="usage">Usage</h2>

You can put your variables in a file or use the environment namespace

<h3 id="load_file-function">Loading from a file</h3>

Create a file using one of the following formats and add your variables:

- `.env`
- `.json`
- `.yaml`
- `.toml`

    **Note: When using the `.env` file, the variables should be declared as python variables**
    

Use the `load_file` function to load the variables, specifying the format of the file

```python
from secret_garden import load_file
load_file('path/to/your/file', format_='<your_format>')
```

Pass the globals dictionary if you want to load the variables into the global namespace

```python
from secret_garden import load_file
load_file(
    'path/to/your/file',
    format_='<your_format>',
    globals_=globals()
)
```

<h3 id="load_space-function">Loading from the environment namespace</h3>

Add your variables into the environment namespace

```bash
export STR_VAR="string"
export INT_VAR=1
export FLOAT_VAR=1.0
export BOOL_VAR=True
export LIST_VAR="['item1', 'item2']"
export DICT_VAR="{'key1': 'value1', 'key2': 'value2'}"
```

Use the `load_space` function to load the variables

```python
from secret_garden import load_space
load_space(['STR_VAR', 'INT_VAR', 'FLOAT_VAR', 'BOOL_VAR', 'LIST_VAR', 'DICT_VAR'])
```

Pass the globals dictionary if you want to load the variables into the global namespace

```python
from secret_garden import load_space
load_space(
    ['STR_VAR', 'INT_VAR', 'FLOAT_VAR', 'BOOL_VAR', 'LIST_VAR', 'DICT_VAR'],
    globals_=globals()
)
```


<h3 id="load-function">Loading from a file using the environment namespace as an alternative</h3>

- This is done using the `load` function.

- If both path and include are provided, the variables are loaded from the file and the include argument is ignored.

    ```python
    from secret_garden import load
    load(
        "/path/to/your/file", # path to the file containing the variables
        ["VAR1", "VAR2"], # this will be ignored
        format_ = 'env',
        globals_ = None, 
    )
    ```

- If path does not exist, the variables are loaded from the environment namespace. The include argument is used to know which variables to get from the environment namespace.
    ```python
    from secret_garden import load
    load(
        "/path/to/the/non-existent/file", # path to the non-existent file
        ["VAR1", "VAR2"], # variables to be included from the environment namespace
        format_ = 'env',
        globals_ = None, 
    )
    ```

<h2 id="examples">Examples</h2>

<h3 id="using-a-file">Using a file</h3>

<h4 id="env">env</h4>

- Add your variables into the `.env` file

    ```python
    STR_VAR="string"
    INT_VAR=1
    FLOAT_VAR=1.0
    BOOL_VAR=True
    LIST_VAR=['item1', 'item2']
    DICT_VAR={'key1': 'value1', 'key2': 'value2'}
    ```

- Use the `load_file` function to load the variables

    ```python
    from secret_garden import load_file
    load_file('path/to/your/file.env', format_='env')
    ```

- Using the `globals_` parameter

    ```python
    from secret_garden import load_file
    load_file(
        'path/to/your/.env',
        format_='env',
        globals_=globals()
    )
    ```

<h4 id="json">json</h4>

- Add your variables into the `.json` file

    ```json
    {
        "STR_VAR": "string",
        "INT_VAR": 1,
        "FLOAT_VAR": 1.0,
        "BOOL_VAR": true,
        "LIST_VAR": ["item1", "item2"],
        "DICT_VAR": {"key1": "value1", "key2": "value2"}
    }
    ```

- Use the `load_file` function to load the variables

    ```python
    from secret_garden import load_file
    load_file('path/to/your/file.json', format_='json')
    ```

- Using the `globals_` parameter

    ```python
    from secret_garden import load_file
    load_file(
        'path/to/your/file.json',
        format_='json',
        globals_=globals()
    )
    ```

<h4 id="toml">toml</h4>

#####

- Add your variables into the `.toml` file

    ```toml
    STR_VAR = "string"
    INT_VAR = 1
    FLOAT_VAR = 1.0
    BOOL_VAR = true
    LIST_VAR = ["item1", "item2"]
    DICT_VAR = {key1 = "value1", key2 = "value2"}
    ```
- Use the `load_file` function to load the variables

    ```python
    from secret_garden import load_file
    load_file('path/to/your/file.toml', format_='toml')
    ```
- Using the `globals_` parameter

    ```python
    from secret_garden import load_file
    load_file(
        'path/to/your/file.toml',
        format_='toml',
        globals_=globals()
    )
    ```

<h4 id="yaml">yaml</h4>

#####

- Add your variables into the `.yaml` file

    ```yaml
    STR_VAR: string
    INT_VAR: 1
    FLOAT_VAR: 1.0
    BOOL_VAR: true
    LIST_VAR:
        - item1
        - item2
    DICT_VAR:
        key1: value1
        key2: value2
    ```

- Use the `load_file` function to load the variables

    ```python
    from secret_garden import load_file
    load_file('path/to/your/file.yaml', format_='yaml')
    ```

- Using the `globals_` parameter

    ```python
    from secret_garden import load_file
    load_file(
        'path/to/your/file.yaml',
        format_='yaml',
        globals_=globals()
    )
    ```

<h3 id="using-the-environment-namespace">Using the environment namespace</h3>

#####

- Add your variables into the environment namespace

    ```bash
    export STR_VAR="string"
    export INT_VAR=1
    export FLOAT_VAR=1.0
    export BOOL_VAR=True
    export LIST_VAR="['item1', 'item2']"
    export DICT_VAR="{'key1': 'value1', 'key2': 'value2'}"
    ```

- Use the `load_space` function to load the variables

    ```python
    from secret_garden import load_space
    load_space(['STR_VAR', 'INT_VAR', 'FLOAT_VAR', 'BOOL_VAR', 'LIST_VAR', 'DICT_VAR'])
    ```

- Using the `globals_` parameter

    ```python
    from secret_garden import load_space
    load_space(
        ['STR_VAR', 'INT_VAR', 'FLOAT_VAR', 'BOOL_VAR', 'LIST_VAR', 'DICT_VAR'],
        globals_=globals()
    )
    ```


<h2  id="objects">Objects</h2>

- <h3 id="load"><code>load</code></h3>

    ```python
    load(
        path_or_include: Path | PathLike | str | list[str], # path to the file or a list of variables to be included from the environment namespace
        format_: str = 'environ', # the format of the file if path_or_include is a path
        globals_: dict = None, # the execution global namespace to load the variables into
    )
    ```

    If both path and include are provided, the variables are loaded from the file and the include argument is ignored

    If path does not exist, the variables are loaded from the environment namespace and the include argument is used to filter the variables.


    - `path` (Path | PathLike | str): The path to the file containing the environment variables
    - `include` (list[str]): The variables to include when loading from the environment namespace
    - `format_` - Format of the file containing the variables.It can be one of the following:
        - 'env' - *Variables are declared as python variables*
        - 'environ' - *Variables are declared as environment variables where value are in quotes*
        - 'json'
        - 'yaml'
        - 'toml'
    - `globals_` - If not provided, variables will returned as a dictionary


- <h3 id="load_file"><code>load_file</code></h3>

    ```python
    load_file(
        path: str, # path to the file
        format_: str = 'environ', # the format of the file
        globals_: dict = None, # the execution global namespace to load the variables into
    )

    ```
    - `path` - The path to the file containing the variables
    - `format_` - Format of the file containing the variables.It can be one of the following:
        - 'env' - *Variables are declared as python variables*
        - 'json'
        - 'yaml'
        - 'toml'
    - `globals_` - If not provided, variables will returned as a dictionary

- <h3 id="load_space"><code>load_space</code></h3>

    ```python
    load_space(
        include: list, # a list of variables to be included from the environment namespace
        globals_: dict = None, # the execution global namespace to load the variables into
    )
    ```
    - `include` - A list of variables to be included from the environment namespace
    - `globals_` - If not provided, variables will returned as a dictionary


<h2 id="upcoming-features">Upcoming Features</h2>

- Support for multiline declaration in the `'env'` and `'environ'` formats

- Support for nested dictionary and list types in the `'env'` and `'environ'` formats

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "secret-garden",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "",
    "keywords": "dotenv,environment,variables,environment variables,dotenv variables,typed dotenv,typed environment variables,typed dotenv variables,dotenv management,environment management,secret variables",
    "author": "DanielMuringe",
    "author_email": "danielmuringe@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/ac/9c/37b8f820a474007e4be58c3c439a8c9e6e8aa40ba16c849dbdf3537e416e/secret_garden-1.0.0.tar.gz",
    "platform": null,
    "description": "# [secret-garden](https://github.com/danielmuringe/secret-garden)\n## A better way to manage your dotenv variables\n\n\n### Installation\n- You can use your most preferred package manager to install the package\n\n    `pip install secret-garden` or `poetry add secret-garden` ...\n\n\n## Table of Contents\n\n1. [Usage](#usage)\n    - [loading from a file](#load_file-function)\n    - [loading from the environment namespace](#load_space-function)\n    - [loading from a file using the environment namespace as an alternative](#load-function)\n\n1. [Examples](#examples)\n    - [Using a file](#using-a-file)\n        - [env](#env)\n        - [json](#json)\n        - [toml](#toml)\n        - [yaml](#yaml)\n    - [Using the environment namespace](#using-the-environment-namespace)\n\n1. [Objects](#objects)\n    - [load](#load)\n    - [load_file](#load_file)\n    - [load_space](#load_space)\n\n1. [Upcoming Features](#upcoming-features)\n\n\n<h2 id=\"usage\">Usage</h2>\n\nYou can put your variables in a file or use the environment namespace\n\n<h3 id=\"load_file-function\">Loading from a file</h3>\n\nCreate a file using one of the following formats and add your variables:\n\n- `.env`\n- `.json`\n- `.yaml`\n- `.toml`\n\n    **Note: When using the `.env` file, the variables should be declared as python variables**\n    \n\nUse the `load_file` function to load the variables, specifying the format of the file\n\n```python\nfrom secret_garden import load_file\nload_file('path/to/your/file', format_='<your_format>')\n```\n\nPass the globals dictionary if you want to load the variables into the global namespace\n\n```python\nfrom secret_garden import load_file\nload_file(\n    'path/to/your/file',\n    format_='<your_format>',\n    globals_=globals()\n)\n```\n\n<h3 id=\"load_space-function\">Loading from the environment namespace</h3>\n\nAdd your variables into the environment namespace\n\n```bash\nexport STR_VAR=\"string\"\nexport INT_VAR=1\nexport FLOAT_VAR=1.0\nexport BOOL_VAR=True\nexport LIST_VAR=\"['item1', 'item2']\"\nexport DICT_VAR=\"{'key1': 'value1', 'key2': 'value2'}\"\n```\n\nUse the `load_space` function to load the variables\n\n```python\nfrom secret_garden import load_space\nload_space(['STR_VAR', 'INT_VAR', 'FLOAT_VAR', 'BOOL_VAR', 'LIST_VAR', 'DICT_VAR'])\n```\n\nPass the globals dictionary if you want to load the variables into the global namespace\n\n```python\nfrom secret_garden import load_space\nload_space(\n    ['STR_VAR', 'INT_VAR', 'FLOAT_VAR', 'BOOL_VAR', 'LIST_VAR', 'DICT_VAR'],\n    globals_=globals()\n)\n```\n\n\n<h3 id=\"load-function\">Loading from a file using the environment namespace as an alternative</h3>\n\n- This is done using the `load` function.\n\n- If both path and include are provided, the variables are loaded from the file and the include argument is ignored.\n\n    ```python\n    from secret_garden import load\n    load(\n        \"/path/to/your/file\", # path to the file containing the variables\n        [\"VAR1\", \"VAR2\"], # this will be ignored\n        format_ = 'env',\n        globals_ = None, \n    )\n    ```\n\n- If path does not exist, the variables are loaded from the environment namespace. The include argument is used to know which variables to get from the environment namespace.\n    ```python\n    from secret_garden import load\n    load(\n        \"/path/to/the/non-existent/file\", # path to the non-existent file\n        [\"VAR1\", \"VAR2\"], # variables to be included from the environment namespace\n        format_ = 'env',\n        globals_ = None, \n    )\n    ```\n\n<h2 id=\"examples\">Examples</h2>\n\n<h3 id=\"using-a-file\">Using a file</h3>\n\n<h4 id=\"env\">env</h4>\n\n- Add your variables into the `.env` file\n\n    ```python\n    STR_VAR=\"string\"\n    INT_VAR=1\n    FLOAT_VAR=1.0\n    BOOL_VAR=True\n    LIST_VAR=['item1', 'item2']\n    DICT_VAR={'key1': 'value1', 'key2': 'value2'}\n    ```\n\n- Use the `load_file` function to load the variables\n\n    ```python\n    from secret_garden import load_file\n    load_file('path/to/your/file.env', format_='env')\n    ```\n\n- Using the `globals_` parameter\n\n    ```python\n    from secret_garden import load_file\n    load_file(\n        'path/to/your/.env',\n        format_='env',\n        globals_=globals()\n    )\n    ```\n\n<h4 id=\"json\">json</h4>\n\n- Add your variables into the `.json` file\n\n    ```json\n    {\n        \"STR_VAR\": \"string\",\n        \"INT_VAR\": 1,\n        \"FLOAT_VAR\": 1.0,\n        \"BOOL_VAR\": true,\n        \"LIST_VAR\": [\"item1\", \"item2\"],\n        \"DICT_VAR\": {\"key1\": \"value1\", \"key2\": \"value2\"}\n    }\n    ```\n\n- Use the `load_file` function to load the variables\n\n    ```python\n    from secret_garden import load_file\n    load_file('path/to/your/file.json', format_='json')\n    ```\n\n- Using the `globals_` parameter\n\n    ```python\n    from secret_garden import load_file\n    load_file(\n        'path/to/your/file.json',\n        format_='json',\n        globals_=globals()\n    )\n    ```\n\n<h4 id=\"toml\">toml</h4>\n\n#####\n\n- Add your variables into the `.toml` file\n\n    ```toml\n    STR_VAR = \"string\"\n    INT_VAR = 1\n    FLOAT_VAR = 1.0\n    BOOL_VAR = true\n    LIST_VAR = [\"item1\", \"item2\"]\n    DICT_VAR = {key1 = \"value1\", key2 = \"value2\"}\n    ```\n- Use the `load_file` function to load the variables\n\n    ```python\n    from secret_garden import load_file\n    load_file('path/to/your/file.toml', format_='toml')\n    ```\n- Using the `globals_` parameter\n\n    ```python\n    from secret_garden import load_file\n    load_file(\n        'path/to/your/file.toml',\n        format_='toml',\n        globals_=globals()\n    )\n    ```\n\n<h4 id=\"yaml\">yaml</h4>\n\n#####\n\n- Add your variables into the `.yaml` file\n\n    ```yaml\n    STR_VAR: string\n    INT_VAR: 1\n    FLOAT_VAR: 1.0\n    BOOL_VAR: true\n    LIST_VAR:\n        - item1\n        - item2\n    DICT_VAR:\n        key1: value1\n        key2: value2\n    ```\n\n- Use the `load_file` function to load the variables\n\n    ```python\n    from secret_garden import load_file\n    load_file('path/to/your/file.yaml', format_='yaml')\n    ```\n\n- Using the `globals_` parameter\n\n    ```python\n    from secret_garden import load_file\n    load_file(\n        'path/to/your/file.yaml',\n        format_='yaml',\n        globals_=globals()\n    )\n    ```\n\n<h3 id=\"using-the-environment-namespace\">Using the environment namespace</h3>\n\n#####\n\n- Add your variables into the environment namespace\n\n    ```bash\n    export STR_VAR=\"string\"\n    export INT_VAR=1\n    export FLOAT_VAR=1.0\n    export BOOL_VAR=True\n    export LIST_VAR=\"['item1', 'item2']\"\n    export DICT_VAR=\"{'key1': 'value1', 'key2': 'value2'}\"\n    ```\n\n- Use the `load_space` function to load the variables\n\n    ```python\n    from secret_garden import load_space\n    load_space(['STR_VAR', 'INT_VAR', 'FLOAT_VAR', 'BOOL_VAR', 'LIST_VAR', 'DICT_VAR'])\n    ```\n\n- Using the `globals_` parameter\n\n    ```python\n    from secret_garden import load_space\n    load_space(\n        ['STR_VAR', 'INT_VAR', 'FLOAT_VAR', 'BOOL_VAR', 'LIST_VAR', 'DICT_VAR'],\n        globals_=globals()\n    )\n    ```\n\n\n<h2  id=\"objects\">Objects</h2>\n\n- <h3 id=\"load\"><code>load</code></h3>\n\n    ```python\n    load(\n        path_or_include: Path | PathLike | str | list[str], # path to the file or a list of variables to be included from the environment namespace\n        format_: str = 'environ', # the format of the file if path_or_include is a path\n        globals_: dict = None, # the execution global namespace to load the variables into\n    )\n    ```\n\n    If both path and include are provided, the variables are loaded from the file and the include argument is ignored\n\n    If path does not exist, the variables are loaded from the environment namespace and the include argument is used to filter the variables.\n\n\n    - `path` (Path | PathLike | str): The path to the file containing the environment variables\n    - `include` (list[str]): The variables to include when loading from the environment namespace\n    - `format_` - Format of the file containing the variables.It can be one of the following:\n        - 'env' - *Variables are declared as python variables*\n        - 'environ' - *Variables are declared as environment variables where value are in quotes*\n        - 'json'\n        - 'yaml'\n        - 'toml'\n    - `globals_` - If not provided, variables will returned as a dictionary\n\n\n- <h3 id=\"load_file\"><code>load_file</code></h3>\n\n    ```python\n    load_file(\n        path: str, # path to the file\n        format_: str = 'environ', # the format of the file\n        globals_: dict = None, # the execution global namespace to load the variables into\n    )\n\n    ```\n    - `path` - The path to the file containing the variables\n    - `format_` - Format of the file containing the variables.It can be one of the following:\n        - 'env' - *Variables are declared as python variables*\n        - 'json'\n        - 'yaml'\n        - 'toml'\n    - `globals_` - If not provided, variables will returned as a dictionary\n\n- <h3 id=\"load_space\"><code>load_space</code></h3>\n\n    ```python\n    load_space(\n        include: list, # a list of variables to be included from the environment namespace\n        globals_: dict = None, # the execution global namespace to load the variables into\n    )\n    ```\n    - `include` - A list of variables to be included from the environment namespace\n    - `globals_` - If not provided, variables will returned as a dictionary\n\n\n<h2 id=\"upcoming-features\">Upcoming Features</h2>\n\n- Support for multiline declaration in the `'env'` and `'environ'` formats\n\n- Support for nested dictionary and list types in the `'env'` and `'environ'` formats\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A better way to manage your dotenv variables",
    "version": "1.0.0",
    "project_urls": null,
    "split_keywords": [
        "dotenv",
        "environment",
        "variables",
        "environment variables",
        "dotenv variables",
        "typed dotenv",
        "typed environment variables",
        "typed dotenv variables",
        "dotenv management",
        "environment management",
        "secret variables"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a37d62591364ea5fb6a2ecb9a4a5892f49867f9aea245f264c44dd95fff1bb0b",
                "md5": "fd776a0e34baee08020e9813bbec57cd",
                "sha256": "933a8cfb7361915ca7ceccaa9fa340ee066046e3397b5dba183df44e97a30464"
            },
            "downloads": -1,
            "filename": "secret_garden-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fd776a0e34baee08020e9813bbec57cd",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 7460,
            "upload_time": "2024-02-26T08:40:56",
            "upload_time_iso_8601": "2024-02-26T08:40:56.136065Z",
            "url": "https://files.pythonhosted.org/packages/a3/7d/62591364ea5fb6a2ecb9a4a5892f49867f9aea245f264c44dd95fff1bb0b/secret_garden-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ac9c37b8f820a474007e4be58c3c439a8c9e6e8aa40ba16c849dbdf3537e416e",
                "md5": "84db3cfb1ccc79f06dc016e8a7a5fd3b",
                "sha256": "3ff2241dc526aaa38e1d9ab623c85aff9367c45c8cfb0cb5b07b72c399f33ad6"
            },
            "downloads": -1,
            "filename": "secret_garden-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "84db3cfb1ccc79f06dc016e8a7a5fd3b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 7358,
            "upload_time": "2024-02-26T08:40:58",
            "upload_time_iso_8601": "2024-02-26T08:40:58.694608Z",
            "url": "https://files.pythonhosted.org/packages/ac/9c/37b8f820a474007e4be58c3c439a8c9e6e8aa40ba16c849dbdf3537e416e/secret_garden-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-26 08:40:58",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "secret-garden"
}
        
Elapsed time: 0.18728s