Skip to main content

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

ini_config_parser-0.3.tar.gz (3.1 kB view details)

Uploaded Source

File details

Details for the file ini_config_parser-0.3.tar.gz.

File metadata

  • Download URL: ini_config_parser-0.3.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

Hashes for ini_config_parser-0.3.tar.gz
Algorithm Hash digest
SHA256 dc7956769b95b4313ee33e471325dabd8fce929a48bfba859edabb3f3a4e99e5
MD5 481edd0a143c9519cbac1399f5c097df
BLAKE2b-256 3e87edfeafa943285514d022e8bb4c80d87fb2c6a8b345e164a4f0183d2fffaa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page