Skip to main content
https://img.shields.io/pypi/v/p_config.svg https://img.shields.io/travis/zlqm/p_config.svg Documentation Status

Simple configure management tool for python project.

YAML file and environment variable both supported.

Install

$: pip install p_config --upgrade

Usage

  1. Initialize a Config instance. You can add some default value here.

  2. Load local file or environment value. Value with same key will be overridden.

  3. Access config through the instance

(default) p_config ) ENV=UAT ipython
Python 3.9.1 (default,)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.20.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from p_config import Config

In [2]: config = Config(ENV='SIT')

In [3]: config.ENV  # default config defined at [2]
Out[3]: 'SIT'

In [4]: !cat demo.yaml
ENV: PRD
BROKER_URI: redis://
DB:
  NAME: test
  HOST: localhost
  PORT: 3306

In [5]: config.load_yaml_file('demo.yaml')

In [6]: config.ENV  # overridden by config in demo.yaml
Out[6]: 'PRD'

In [7]: config.DB  # only support upper case
Out[7]: {'NAME': 'test', 'HOST': 'localhost', 'PORT': 3306}

In [8]: config.DB.HOST
Out[8]: 'localhost'

In [9]: config.load_env()

In [10]: config.ENV  # overridden by config in demo.yaml
Out[10]: 'UAT'

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

Metadata

Release files for p-config 1.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for p-config 1.4.0
File Size Uploaded
p_config-1.4.0.tar.gz 13.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for p-config 1.4.0
File Interpreter ABI Platform
p_config-1.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 21.4 kB

Release files / p_config-1.4.0.tar.gz

Download URL p_config-1.4.0.tar.gz
Size 13.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f71befc3e9eaea1799bdd37f3e5a3b09ab88bf53c1922a8ed9be5c344faf6a94
BLAKE2b-256 checksum
How to use checksums
8ac5b72032da87215db25cd3d1df6ae07d81def0dbd771522a4644dd131cd248
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

Release files / p_config-1.4.0-py3-none-any.whl

Download URL p_config-1.4.0-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0aacdbd5812f44e3c46ac5a6c261ab9271a694e84ae664f901338bd012bfee2b
BLAKE2b-256 checksum
How to use checksums
6a31551af1d24bb674fb1f680fe4e323af87e41c1cae63c3893c4b7d06f625eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

Release history Release notifications | RSS feed

This release

1.4.0 This release

2 release files

1.3.3

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page