-
Pre-requisites:
Pre-requisite Installation python3 python3 downloads pip3 Download the get-pip.py file and run python3 get-pip.py
poetry (pip improvement) Run pip3 install poetry
-
Installing the package
poetry add secret-garden
-
Check if the package is installed
poetry show secret-garden
You can put your variables in a file or use the environment namespace
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
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
from secret_garden import load_file
load_file(
'path/to/your/file',
format_='<your_format>',
globals_=globals()
)
Add your variables into the environment namespace
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
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
from secret_garden import load_space
load_space(
['STR_VAR', 'INT_VAR', 'FLOAT_VAR', 'BOOL_VAR', 'LIST_VAR', 'DICT_VAR'],
globals_=globals()
)
-
This is done using the
load
function by declaring in order:- the path to the file containing the variables
- the variables to be included from the environment namespace
-
If both path and include are provided, the variables are loaded from the file and the include argument is ignored.
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.
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, )
-
All development is done on the
dev
branch and thus all pull requests should be made here. -
The
main
andpackaging
branches are out of bounds. -
Do not include development dependencies in the
requirements.txt
file.Update requirements.txt as shown in step 3 of the contribution process.
-
Pre-requisites:
Pre-requisite Installation python3.10 python3.10 pip3.10 Download the get-pip.py file and run python3.10 get-pip.py
poetry pip3.10 install poetry
-
Fork the repository and clone it
git clone https://github.com/danielmuringe/secret-garden
-
Create a new branch from the
dev
branch:git checkout dev git checkout -b <feature-branch-name>
-
Install the development dependencies and activate a virtual environment:
poetry install --no-root poetry shell
-
Make your changes and ensure you have created tests to cover the changes.
-
Create a pull request to the
dev
branch and wait for confirmation.
-
Support for multiline declaration in the
'env'
and'environ'
formats -
Support for nested dictionary and list types in the
'env'
and'environ'
formats
Contributor | |
---|---|
Daniel Muringe | danielmuringe@gmail.com |
This project is licensed under the MIT License - see the LICENCE.md file for details.