Skip to main content

YACF - Yet Another Configuration Framework

Simple framework to parse multiple configuration files of different formats and update them.

Usage

The usage of this framework is straight-forward.

Create a Configuration instance. When creating one, give the inputs to read from as arguments. The input can be either a dictionary, to be immediately used, or alternatively a file name which ends on one of the supported file types below.

Afterwards, call the load function on the configuration instance. This function allows to define additional inputs. It's a matter of choice whether one wants to define the inputs in the constructor or in the load call.

The load function uses the previously defined configuration inputs. The function builds one large configuration dictionary out of all the inputs. Overlapping parameters are always overwritten.

This makes it easy to define configurations of different priorities. One good approach is to define the configuration inputs as follows:

[defaults, custom configuration, environment variables, command line arguments]

To access the values of the configuration, one can either use the regular access of dictionaries, e.g. a concatenation of gets(). Alternatively one can simply use dot notation. However, the most convenient way to access attributes of the configuration is the regular attribute access. The recursive nature of the framework makes it work like a charm.:

config = Configuration('api-config.json').load()
sample = config.get('api').get('hostname')

# Alternative dot notation
sample = config.get('api.hostname')

# Attribute notation
sample = config.api.hostname

Additional Features

Custom Seperator

If you, for some reason dislike the regular seperator '.' in the dot notation you can choose a custom one when initializing the configuration instance.

Supported File Types

  • json
  • toml

Caveats

The framework is solely implemented and tested on Linux. I can not guarantee for any expected behaviour on other platforms. If you use the framework on another platform, please share your experiences with me.

In addition, the attribute notation (config.api.hostname) is just tested for the default seperator .. Since the . has a special meaning in Python, it is easiest to use. To keep the framework simple and still flexible, we decided to not add an internal representation to circumvent the seperator limitation.

License

MIT License Copyright (c) 2021 Max Resing

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Metadata

Release files for yacf 1.1.1

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

Source distribution (sdist)

Source distribution for yacf 1.1.1
File Size Uploaded Provenance
yacf-1.1.1.tar.gz 8.0 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 16.8 kB

Release files / yacf-1.1.1.tar.gz

Download URL yacf-1.1.1.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e6fe09e230dbaf799a5d2dea737087986fdf7ce83f2f2607b3131021a1cee64f
BLAKE2b-256 checksum
How to use checksums
331621f4bb1b537c00b1621a438e8098a4fca958bd0fe1caf7f08e5035dd8dab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.7

Release files / yacf-1.1.1-py3-none-any.whl

Download URL yacf-1.1.1-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c2403c8eba37604552c04fd69aeebc8a3687d7e22a031f5a09d141c9ae7470c3
BLAKE2b-256 checksum
How to use checksums
d3e256b61e4021dc3649f6eafff97d08839d94939f210b4c828b337a833ed6d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.7

Security for yacf 1.1.1

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