All Projects → capless → envs

capless / envs

Licence: Apache-2.0 license
Easy access of environment variables from Python with support for typing (ex. booleans, strings, lists, tuples, integers, floats, and dicts). Now with CLI settings file converter.

Programming Languages

python
139335 projects - #7 most used programming language
Jinja
831 projects

Projects that are alternatives of or similar to envs

Awesome Taleb
A curated list of awesome things about Nassim Nicholas Taleb
Stars: ✭ 221 (+784%)
Mutual labels:  lists
Awesome-GRE-Materials
A curated list of materials to prepare for the GRE.
Stars: ✭ 231 (+824%)
Mutual labels:  lists
MySoftwareList
My top picks of software I use everyday. | WIP 🚧
Stars: ✭ 24 (-4%)
Mutual labels:  lists
Awesome Js Posts
A curated list of latest posts, blogs and repositories related to JavaScript.
Stars: ✭ 232 (+828%)
Mutual labels:  lists
Problem-Solving
This Repository consists of my solutions💡 in Python 3 to various problems in Data Structures and Algorithms.🎖️
Stars: ✭ 17 (-32%)
Mutual labels:  strings
algoexpert
AlgoExpert is an online platform that helps software engineers to prepare for coding and technical interviews.
Stars: ✭ 8 (-68%)
Mutual labels:  strings
Checklist Checklist
🌈 A Curated List of Checklists ✔︎✔︎
Stars: ✭ 2,372 (+9388%)
Mutual labels:  lists
slice
A JavaScript implementation of Python's negative indexing and extended slice syntax.
Stars: ✭ 53 (+112%)
Mutual labels:  strings
dotenvy
Speed up your production sites by ditching .env for key/value variable pairs as Apache, Nginx, and shell equivalents
Stars: ✭ 31 (+24%)
Mutual labels:  environment-variables
tfenv
Transform environment variables for use with Terraform (e.g. `HOSTNAME` ⇨ `TF_VAR_hostname`)
Stars: ✭ 120 (+380%)
Mutual labels:  environment-variables
Front End Checklist
🗂 The perfect Front-End Checklist for modern websites and meticulous developers
Stars: ✭ 57,386 (+229444%)
Mutual labels:  lists
CBioInfCpp-0-
The lib CBioInfCpp.h contains 3 groups of functions for C++: "Input-Output", "Working with strings", "Working with graphs". Data structures "Adjacency vector" and "Adjacency map" are implemented in the last one (i.e. in "Working with graphs"). See About_CBioInfCpp for details.
Stars: ✭ 12 (-52%)
Mutual labels:  strings
envsafe
🔒 Makes sure you don't accidentally deploy apps with missing or invalid environment variables.
Stars: ✭ 705 (+2720%)
Mutual labels:  environment-variables
Awesome Flame
An awesome list that curates the best Flame games, projects, libraries, tools, tutorials, articles and more.
Stars: ✭ 227 (+808%)
Mutual labels:  lists
jsonargparse
Implement minimal boilerplate CLIs derived from type hints and parse from command line, config files and environment variables
Stars: ✭ 168 (+572%)
Mutual labels:  environment-variables
Xd Awesome
Awesome community-created resources for extending Adobe XD
Stars: ✭ 217 (+768%)
Mutual labels:  lists
ini
📝 Go INI config management. support multi file load, data override merge. parse ENV variable, parse variable reference. Dotenv file parse and loader. INI配置读取管理,支持多文件加载,数据覆盖合并, 解析ENV变量, 解析变量引用。DotEnv 解析加载
Stars: ✭ 72 (+188%)
Mutual labels:  environment-variables
Algorithm-Implementation
This is our effort to collect the best implementations to tough algorithms. All codes are written in c++.
Stars: ✭ 16 (-36%)
Mutual labels:  strings
csharp-workshop
NDC London 2019, Workshop: Become a better C# programmer: more Value, more Expressions, no Waiting
Stars: ✭ 21 (-16%)
Mutual labels:  tuples
awesome-vacuum
A curated list of free and open source software and hardware to build and control a robot vacuum.
Stars: ✭ 187 (+648%)
Mutual labels:  lists

envs

Easy access of environment variables from Python with support for booleans, strings, lists, tuples, integers, floats, and dicts.

Use Case

If you need environment variables for your settings but need an easy way of using Python objects instead of just strings. For example, if you need a list of strings.

Features

  • CLI to convert settings
  • CLI to list and check environment variables
  • Use strings, lists, tuples, integers, floats or dicts. IMPORTANT: When setting the variables in your environmenet (ex. in .env file) wrap them in single or double quotes (ex. "['some','list']")

Build Status

Quick Start

Install

Install without CLI Requirements

pip install envs

Install with CLI Requirements

pip install envs["cli"]

Run Convert Settings

IMPORTANT: Don't name this file the same as the original module (you have added the imports back yet).

envs convert_settings --settings-file your.settings.module

Copy and Paste the Imports and Logic Code From Original File

Envs does not copy and paste your imports from your original code, so you have to do this manually.

Run List Envs

This tells you what envs have default v

envs list_envs --settings-file your.settings.module

General API

from envs import env

env('SOMEVAR','default value for that var',var_type='string',allow_none=True)

Strings

Environment Variable Example: SECRET_KEY='adfadfadfafasf'

>>>from envs import env

>>>env('SECRET_KEY','default secret key here')
'adfadfadfafasf'

Lists

Environment Variable Example: SERVER_NAMES="['coastal','inland','western']"

>>>from envs import env

>>>env('SERVER_NAMES',var_type='list')
['coastal','inland','western']

Tuples

Environment Variable Example: SERVER_NAMES="('coastal','inland','western')"

>>>from envs import env

>>>env('SERVER_NAMES',var_type='tuple')
('coastal','inland','western')

Dicts

Environment Variable Example: DATABASE="{'USER':'name','PASSWORD':'password'}"

>>>from envs import env

>>>env('DATABASE',var_type='dict')
{'USER':'name','PASSWORD':'password'}

Integers

Environment Variable Example: NO_SERVERS=12

>>>from envs import env

>>>env('NO_SERVERS',var_type='integer')
12

Floats

Environment Variable Example: INDEX_WEIGHT=0.9

>>>from envs import env

>>>env('INDEX_WEIGHT',var_type='float')
0.9

Booleans

Environment Variable Example: USE_PROFILE=false

>>>from envs import env

>>>env('USE_PROFILE',var_type='boolean')
False

Decimals

Environment Variable Example: HALF_SEVEN=3.5

>>> from envs import env

>>> env('HALF_SEVEN', var_type='decimal')
Decimal('3.5')

Command Line Utils

IMPORTANT: All of the command arguments will fallback to becoming prompts if not set when calling the commands.

Convert Module (convert_module)

Converts an existing settings file so it uses envs. IMPORTANT: This command does not copy your import stataements to the new module.

Arguments

  • settings-file: - Dot notated import string for settings file
envs convert_module --settings-file your.settings

List Envs (list_envs)

Shows a list of env instances set in a settings file.

  • settings-file: - Dot notated import string for settings file
  • keep-result: - Keep the .env_results file generated by this command (default: False)
envs list_envs --settings-file your.settings --keep-result False

Check Envs (check_envs)

Make sure that the defined envs with no default value have a value set in the environment. This command will raise an EnvsValueException if there is environment variable that should be set that is not. This command is meant for use with a CI/CD tool as a way to halt the build if there isn't a value for an environment variable.

  • settings-file: - Dot notated import string for settings file
envs check_envs --settings-file your.settings

Author

Twitter::@brianjinwright Github: bjinwright

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].