Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Import environment variables from your .env file or run as command line tool; PyDotEnv Cli.
Import environment variables from your .env file or run as command line tool; PyDotEnv Cli.
Stable: v0.2.0
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
from pydotenvs import load_env
load_env()
or
load_env('.myEnvFile')
or
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!
Run this to see a working example
python example/demo.py
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.
from pydotenvs import load_env
stringObj = load_env(stringIO = True, auto_close = True)
contents = stringObj.getvalue()
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:
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
pyenv -f .env -n .newenv -t True
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:
from pydotenvs import clear_env
clear_env(env_path = '.env', module_init_only=True)
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.
pyenv --command 'echo $MY_VARIABLE'
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.
FAQs
Import environment variables from your .env file or run as command line tool; PyDotEnv Cli.
We found that pydotenvs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.