Lightweight self-healing config manager
Project description
ConfigLite
A lightweight self-healing config handler.
Quickstart
Subclass from the base BaseConfig object and add your variables and defaults.
You can then set import this from wherever is needed and access properties.
Installation
git clone this repository, then use pip install . to install it in your current environment.
Usage
Creating a Config
Create a subclass of the base BaseConfig object, adding your parameters and their defaults.
For example:
from configlite import BaseConfig
class MyConfig(BaseConfig):
value: int = 10
name: str = "test"
pi: float = 3.14
Access
To use your created config, there are two methods:
- "globally", where a single instance created.
- "locally", initialising the class where needed.
Global
To create a global config, set up the config as a parameter in the toplevel __init__.py:
CONFIG = MyConfig("./path/to/config.yaml")
Then in the rest of your code you may import this object:
from my_package import CONFIG
value = CONFIG.value
This is most useful if your code requires a single config file for everything.
Local
Or a local config, where you create an instance of your subclass wherever it is needed:
from my_package import MyConfig
config = MyConfig("./path/to/config.yaml")
value = config.value
This can be useful if you are juggling multiple different config files dynamically.
Paths
The BaseConfig object can take either a single path, or a list of paths.
If a list is passed, the config will search each one in order, using the last one in the list if none are found.
Path Lists
Lets say you create a config this way:
class Config(BaseConfig):
...
CONFIG = Config(
paths=[
"config.yaml",
"~/.config/app/config.yaml",
]
)
In this case, Config will take these steps:
- Search for
config.yamlin the current working directory. - If not found, search for
~/.config/app/config.yaml. - If still no file exists, create a default config at
~/.config/app/config.yaml
If we get to step 3, but then create a new config at ./config.yaml, this will take priority over the one found at ~/.config/app/config.yaml.
Example
See usage.py for an example.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file configlite-0.1.5.tar.gz.
File metadata
- Download URL: configlite-0.1.5.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
673d57ef73ef59ad8b0ea27bb805da0f691a2be57ee24a7125c1ae130546fcf9
|
|
| MD5 |
5377578cd66a78eb1af8150f08abdf75
|
|
| BLAKE2b-256 |
7955f9438c402b43f301d7689d35d7eed9da8120aabb7ba3019f43e0f096a695
|
Provenance
The following attestation bundles were made for configlite-0.1.5.tar.gz:
Publisher:
push-to-pypi.yml on ljbeal/ConfigLite
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
configlite-0.1.5.tar.gz -
Subject digest:
673d57ef73ef59ad8b0ea27bb805da0f691a2be57ee24a7125c1ae130546fcf9 - Sigstore transparency entry: 767383429
- Sigstore integration time:
-
Permalink:
ljbeal/ConfigLite@517907d6f9b550435772379f165bdbf43c1061db -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/ljbeal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
push-to-pypi.yml@517907d6f9b550435772379f165bdbf43c1061db -
Trigger Event:
release
-
Statement type:
File details
Details for the file configlite-0.1.5-py3-none-any.whl.
File metadata
- Download URL: configlite-0.1.5-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4da632e0472a41e75158174c33524b740075fdac673abd1655bd107e8ed75fb6
|
|
| MD5 |
16fab6b8060b4aa67f773628156cc4d9
|
|
| BLAKE2b-256 |
d64d6dab95e138d81d93f25d8a5a3aaa48ec411d14ff7f4ee8d81df1943965f1
|
Provenance
The following attestation bundles were made for configlite-0.1.5-py3-none-any.whl:
Publisher:
push-to-pypi.yml on ljbeal/ConfigLite
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
configlite-0.1.5-py3-none-any.whl -
Subject digest:
4da632e0472a41e75158174c33524b740075fdac673abd1655bd107e8ed75fb6 - Sigstore transparency entry: 767383434
- Sigstore integration time:
-
Permalink:
ljbeal/ConfigLite@517907d6f9b550435772379f165bdbf43c1061db -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/ljbeal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
push-to-pypi.yml@517907d6f9b550435772379f165bdbf43c1061db -
Trigger Event:
release
-
Statement type: