Skip to main content

conftext

This package contains a couple of mudules:

  • conftext - a helper for managing configuration contexts.

  • conf_ini - unified configuration handling for ini files.

conftext

Motivation

Imagine handling multi-tenant services, that each require certain config contexts to be specified for using them (think db connection information for instance). A “configuration matrix” if you like. The parameters of these config options are the same, but their values differ. You are creating CLI tools for working with these services and find yourself doing:

$ some_task1(db_host=service_A_ip, db_name=service_A_name, param1, param2)
$ some_task2(db_host=service_A_ip, db_name=service_A_name)
$ some_task3(db_host=service_A_ip, db_name=service_A_name, param1)

$ some_task1(db_host=service_B_ip, db_name=service_B_name, param1, param2)
$ some_task2(db_host=service_B_ip, db_name=service_B_name)
$ some_task3(db_host=service_B_ip, db_name=service_B_name, param1)

This small library intends to help bring things back to:

$ some_task1(param1, param2)
$ some_task2()
$ some_task3(param1)

This is just an example. The tool is meant to be generic and is not nescessarily only made for this particular use case.

Operation

This tool works by providing a way to persist configuration coordinates that can be used to look up the appropriate configuration in the “configuarion matrix”. The configuration coordinates are stored in a file at well-known location (look at current dir, then traverse upwards in file hierarchy until / or ~/.config/conftext.ini).

A command-line tool, also called conftext, can be used to show and manipulate the conftext file.

Usage

Use get_config in code where context-aware config should be loaded. The conftext invoke task can then be used to switch the context config.

Example in code:

defaults = dict(
    service='dummy',
    context='local')

config = Conftext(section='package.module', default_config=defaults)

Command-line usage:

$ conftext show
$ conftext set --service <someservice>
$ conftext set --service <someservice> --context <somecontext>

Ideas

  • add a enter task for the CLI tool that will enter the conf context?
    • when inside conf context, consider modifying the prompt to show vital context config

    • add exit task as well

  • add python prompt with config context as well?

conf_ini

Provides unified configuarion for ini files.

Currently, this means that the configuration for a given package/module is expected to be found in:

~/.config/<package>/<module>.ini

and that the file is expected to in a .ini format that can be parsed by the configparser of the python standard library.

Metadata

Release files for conftext 0.0.12

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

Source distribution (sdist)

Source distribution for conftext 0.0.12
File Size Uploaded Provenance
conftext-0.0.12.tar.gz 18.2 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 36.4 kB

Release files / conftext-0.0.12.tar.gz

Download URL conftext-0.0.12.tar.gz
Size 18.2 kB
Tags Source
SHA-256 checksum
How to use checksums
5e349c713c08fa6acc9cb0e321627d4360077999dd97d0c42e440f0bb33bdcdf
BLAKE2b-256 checksum
How to use checksums
0c2ad3945e8781ce0f6b499de8520c0ab2c1da53f6fa3edd46461f42e3cf942d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.6

Release files / conftext-0.0.12-py3-none-any.whl

Download URL conftext-0.0.12-py3-none-any.whl
Size 18.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
56706e4dfebd6c26f63c1b2b7bd1f3323a20c67d55e7d7bfa9753ebc6df68d7f
BLAKE2b-256 checksum
How to use checksums
3a713470e9b493d98d3597f2938034e0d43c176db3011dbcd004f4ff003889da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.6

Security for conftext 0.0.12

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