Skip to main content

Tool to simplify config management in a program

Project description

loadconfig

Docs Pypi package Tests


A tool to simplify configuration management

We live in an incredible moment in software history. As never before, the quality and quantity of excellent open source software have unleashed massive advances in pretty much all fields of human knowledge. It is overwhelming to have such vast posibilities, and often having a hard time trying to understand how the pieces fit together. More importantly, we are concern on how can we use the software for things that matter to us.

Plenty of times we find what is really needed is a small custom configuration we can easily understand and a handful ways to run the software. And although we barely think about it as we are too busy trying to understand all the bells and whistles, the interface and documentation is at the center of any software.

loadconfig syntax is designed to be clean and DRY, to foster descriptive programming, and to leverage version control systems. loadconfig can be used as a light wrapper around programs to make them behave and to document them the way we designed.

>>> from loadconfig import Config
>>> c = Config('greeter: Hi there')
>>> c
{greeter: Hi there}

>>> c.greeter
'Hi there'

$ loadconfig -E="greeter: Welcome to the loadconfig documentation"
export GREETER="Welcome to the loadconfig documentation"

Technical description

loadconfig dynamically creates a python configuration ordered dictionary from sources like the command line, configuration files and yaml strings that can be used in python code and shell scripts. Dependencies are pyyaml and clg.

Installation

Installation is straightforward using a wheel from pypi:

pip install loadconfig

Alternatively, install from github:

pip install git+https://github.com/mzdaniel/loadconfig

Local test and build

Assumptions for this section: A unix system, python >= 3.11, and pip >= 24.3

loadconfig is hosted on github:

# Download the project using git
git clone https://github.com/mzdaniel/loadconfig
cd loadconfig

# or from the source tarball from github, first finding the latest tag
# released on https://github.com/mzdaniel/loadconfig/releases/latest
wget -O- https://github.com/mzdaniel/loadconfig/archive/0.2.0.tar.gz | tar xz
cd loadconfig

!!! note "" loadconfig tests are exhaustive and also tests described in the documentation are exercised to have confidence loadconfig code is as reliable as posible.

python programs and libraries depend on the environment where it is run.
At a minimun, it is adviced to run the tests and build process in a
venv (python virtual environment)
# Create and activate venv (python virtual environment)
python -m venv build/venv
source build/venv/bin/activate

# Install loadconfig dependencies and pytest with coverage and linting
pip install 'clg>=3.3' 'PyYAML>=6.0.2' 'pytest-cov>=6.2.1' 'pytest-ruff>=0.5'

# Run the tests
pytest

Building loadconfig pip installable wheel (on build/wheel) is as easy as:

pip wheel -w build/wheel .

To test and build (on build/site) loadconfig documentation:

pip install 'mkdocs>=1.6.1' 'mkdocs-codeinclude-plugin>=0.2.1'
mkdocs build

If you are curious, since loadconfig 0.1.2, github actions CI continuos integration server shows the test runs for each commit and pull requests done in the loadconfig repo.

Security

Disclosure: loadconfig is meant for both flexibility and productivity. It does not attempt to be safe with untrusted input. There are ways (linux containers, PyPy’s sandboxing) that can be implemented for such environments and left for the user to consider.

Thanks!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

loadconfig-0.2.1-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file loadconfig-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: loadconfig-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for loadconfig-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1941248f3c6bda43ef7d9808a5fd95eac595a13ead5d8e5f55430f1bbccef194
MD5 36614c9864cc8dd339ac627f2c5dda0c
BLAKE2b-256 98050d16c66d49f78610407cda6a18c6ef2c262accb3501aef2eebd214b9ea99

See more details on using hashes here.

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