Provides convenient interface for easily managing multiple enviroments (ex: test, prod) just from one config.ini
Project description
ini_config_parser
Provides convenient interface for easily managing multiple enviroments (ex: test, prod) just from one config.ini
Usage
# config_parser.py
ini_parser_singleton = IniParserSingleton().get_environment_as_cmd_arg()
config = ini_parser_singleton.config
# config.py
from config_parser import config
PORT = config("PORT", int)
TOKEN = config("TOKEN")
; config.ini
[global]
PORT = 1000
TOKEN = ""
[prod]
PORT = 8000
TOKEN = "foo"
[test]
TOKEN = "bar"
Now if you run python3 your_project.py prod: PORT == 8000 and TOKEN == "foo"
If you run python3 your_project.py test: PORT == 1000 and TOKEN == "bar"
You can also get current environment from file:
# config_parser.py
ini_parser_singleton = IniParserSingleton().get_environment_from_file(".env")
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file ini_config_parser-0.3.1.tar.gz.
File metadata
- Download URL: ini_config_parser-0.3.1.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47e423cbe8a902aed214c840ede73f44ab8f76925379ad5b16e07d977767330b
|
|
| MD5 |
cd7e6c1f8cc6418138fc4f0658d5f147
|
|
| BLAKE2b-256 |
f676ffca05a160b909ac7128120e7e7cc7c4a210b4a970b5705df0c5c886ba20
|