Skip to main content

No project description provided

Project description

AIO-Conf

AIO-Conf is a tiny configuration system that unifies values from multiple sources: command-line arguments, environment variables, configuration files and defaults. Specifications are declared up front so each option knows how to be parsed and coerced into the correct Python type.

Installation

This project uses Poetry. From the project directory install dependencies with:

poetry install

Defining a specification

You can declare options programmatically using OptionSpec and ConfigSpec:

from aio_conf.core import ConfigSpec, OptionSpec

spec = ConfigSpec([
    OptionSpec("port", int, default=8000, env="APP_PORT", cli="--port"),
    OptionSpec("debug", bool, default=False, env="APP_DEBUG", cli="--debug"),
])

The spec can also be stored in JSON and loaded with ConfigSpec.from_json_file() or via AIOConfig.load_from_spec().

Loading configuration

AIOConfig merges all sources with the following precedence:

  1. CLI arguments
  2. Environment variables
  3. File values (json or yaml)
  4. Defaults defined in the spec
from aio_conf import AIOConfig

cfg = AIOConfig(spec)
cfg.load(
    cli_args=["--port", "9000"],
    env={"APP_DEBUG": "true"},
    file_path="config.json",
)
print(cfg.as_dict())

The env parameter accepts a mapping of environment variables and defaults to os.environ when omitted.

Configuration can be written to an INI file:

cfg.save_ini("settings.ini")

Testing

Run the test suite with:

pytest -q

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

aio_conf-1.0.0.dev7.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aio_conf-1.0.0.dev7-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

Details for the file aio_conf-1.0.0.dev7.tar.gz.

File metadata

  • Download URL: aio_conf-1.0.0.dev7.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for aio_conf-1.0.0.dev7.tar.gz
Algorithm Hash digest
SHA256 6244f4799df8f742f783cbe607708bd487af29ad64ae577dfb60e15e11c2cd25
MD5 de003591e0506df90e863aeeb9de49ec
BLAKE2b-256 8f62f929ee09cc2a87f117955718d9cc967312963f57f18db02ab3370228fd2e

See more details on using hashes here.

Provenance

The following attestation bundles were made for aio_conf-1.0.0.dev7.tar.gz:

Publisher: release.yml on Inspyre-Softworks/AIO-Conf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aio_conf-1.0.0.dev7-py3-none-any.whl.

File metadata

  • Download URL: aio_conf-1.0.0.dev7-py3-none-any.whl
  • Upload date:
  • Size: 16.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for aio_conf-1.0.0.dev7-py3-none-any.whl
Algorithm Hash digest
SHA256 f221f9aefc38c9e725a105addc94fdff060dae782b5478fd6a10c7520f67fc05
MD5 93e95e7b80ae855575aa6293dde41e66
BLAKE2b-256 9b783080634d5ab828ec3b0147dde7cf9b27f40a6f99ca56ae621bd94b1bc37b

See more details on using hashes here.

Provenance

The following attestation bundles were made for aio_conf-1.0.0.dev7-py3-none-any.whl:

Publisher: release.yml on Inspyre-Softworks/AIO-Conf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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