Skip to main content

Easy configs for python projects

Project description

P-Conf

Easy use Configs for python projects. Allows loading the config files in the application directory (os specific). Once set the config can be used as a singleton across the project or pass around.

Locations for the config file

The following are the default locations that will be searched

  • ~/.config/<appname>/config.(toml|json|ini|yaml)
  • <system config directory>/<appname>/config.(toml|json|ini|yaml)

Example code

The example code uses the following as the example configuration file

# My config.toml file
foo = 1
[bar]
a = 2

Using inside of a single script

from pi_conf import load_config
cfg = load_config("ourappname")

print(cfg.foo) # 1
print(cfg.bar.a) # 2

Using inside of applications

The following is the preferred way of using the pi-conf module.

# __init__.py

from pi_conf import load_config
cfg = load_config("ourappname") ## Loads the config from the application <appname> directory

Using the config in files

Once it the config has been set you can use it from any file doing either of the following methods.

  • Option 1
from ourappname import cfg ## Import cfg from what we set in __init__.py

print(cfg.foo) # 1
  • Option 2
from pi_conf import load_config ## Just load it again
cfg = load_config("ourappname")

print(cfg.foo) # 1

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

pi_conf-0.8.1.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

pi_conf-0.8.1-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file pi_conf-0.8.1.tar.gz.

File metadata

  • Download URL: pi_conf-0.8.1.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.9 Darwin/23.0.0

File hashes

Hashes for pi_conf-0.8.1.tar.gz
Algorithm Hash digest
SHA256 24dca16e717f13a8aa09d9fa167d2262d4b71f25f1e0014d71b365e93dd43701
MD5 afd21672843efdd0decf251afa4a1950
BLAKE2b-256 1373a83424d9ecfd216dc3af0918443d59e8bc7e04362788e45888c860ae54e8

See more details on using hashes here.

File details

Details for the file pi_conf-0.8.1-py3-none-any.whl.

File metadata

  • Download URL: pi_conf-0.8.1-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.9 Darwin/23.0.0

File hashes

Hashes for pi_conf-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d69d54b3746b5856b8482195ad29ce963ac7a9877c92d57f53ff12988ed4895d
MD5 5233f450304ff623f648eab15624d4d1
BLAKE2b-256 c41b1e00fce8ec7874e7f27a257ba9e25a7c5a4cf65f83e56b800ce9e90bb5ba

See more details on using hashes here.

Supported by

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