Skip to main content

PyPI version Build Status

conf

A very simple and lightweight configuration loader and parser for Python.

Supports:

  • yaml files (*.yml, *.yaml)

  • ini files (*.ini)

  • json files (*.json)

Installation

pip install conf

Usage

Starting your app

Start your app with your configuration file:

python your_app.py --config your_config.yml

Or:

python your_app.py --config config_env_var

The --config argument can be:

  • a relative path to a file;

  • an absolute path to a file;

  • the name of an environment variable which value holds one of the above.

You are allowed to provide multiple configuration names (separated by a single space), in which case any setting of a former configuration file can be overwritten by a setting of a later configuration file (if the name of that setting is identical).

Once you have supplied your application with some configuration, you can fetch the settings of that configuration. There are three options of how to do that.

Fetching your setting (option 1)

Simply get your setting from the conf module:

import conf
your_setting = conf.your_setting

Fetching your setting (option 2)

Import your setting directly:

from conf import your_setting

Fetching your setting (option 3)

You can provide a default value if you are not sure the setting will be present:

import conf
your_setting = conf.get('your_setting', 'your default value')

Note: If you use an ArgumentParser in your own application for other purposes, you must use the parse_known_args() method of the parser.

Fetching your setting (option 4)

You can get the configuration as a dictionary and get your setting as you would get any value from a dict:

import conf
conf_dict = conf.asdict()
your_setting = conf_dict.get('your_setting', 'your default value')

Meta

This lib was designed and written in 2018 by finetuned89 and ramonhagenaars.

Metadata

Release files for conf 0.3.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 conf 0.3.0
File Size Uploaded Provenance Actions
conf-0.3.0.tar.gz 3.7 kB Without provenance Details for conf-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for conf 0.3.0
File Interpreter ABI Platform Actions
conf-0.3.0-py3-none-any.whl Python 3 none any Details for conf-0.3.0-py3-none-any.whl

Total release size: 8.8 kB

Release files / conf-0.3.0.tar.gz

Download URL conf-0.3.0.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
ffeaf5c0a991a844f17e16f30acd78edcd9173ca18555ceab7543373a1982909
BLAKE2b-256 checksum
How to use checksums
9f3f9751b1169b8659d9a6b9337b4f1f062becc9a56a8ed369d1ba33e8c732ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0

Release files / conf-0.3.0-py3-none-any.whl

Download URL conf-0.3.0-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ddaf67af83ac8eadc9bfe5e22bbdb5eee7d77eb88d7eb4e84b7bd0367d26decf
BLAKE2b-256 checksum
How to use checksums
e2f19c6c54ca8567d8c733bfd5ddc62021683e65124e758454062be5aa42d97b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0

Security for conf 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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