pyconject --- a highly opinionated PYthon CONfig inJECTor library.
Project description
pyconject
pyconject is a (highly) opinionated PYthon CONfig inJECTor library inspired by Spring Framework (and Spring Boot Framework).
How to pronounce
pyconject
pyconjectis pronounced PY-CON-JECT, a word play for Burmese "ပိုက်ကွန်ချက်" = "the art of throwing net". It represents how it can be used to capture all types of configs and inject them into all types of packages.
Usage
For detailed usage, refer to usage.
TL;DR
Instead of this:
# in usr_p/usr_sp/usr_m.py
from black_p.black_sp.black_m import black_func
# initialize values_a, value_b, value_c and value_d.
# this part is often the ugly mess because it involves
# reading yaml or other tree-like files and assigning values
import yaml
with open("./configs.yml", "rt") as f:
configs = yaml.safe_load(f)
black_func_parameters = configs["black_p"]["black_sp"]["black_m"]["black_func"]
value_a = black_func_parameters["a"]
# more ugly things here; you get the gist ...
black_func(a=value_a, b=value_b, c=value_c, d=value_d)
With pyconject, we can do this:
# in usr_p/usr_sp/usr_m.py
from black_p.black_sp.black_m import black_func
# pyconject initializes values of a, b, c and d.
from pyconject import pyconject
pyconject.init(globals())
with pyconject.cntx():
black_func()
Developing with pyconject
Instead of this:
# in dev_p/dev_sp/dev_m.py
import os
env = os.environ["environment"]
def dev_func(a=None, b=None, c=None, d=None):
if env == "dev":
if a is None: a = "dev-a"
if b is None: b = "dev-b"
# you know the rest
elif env == "stg":
if a is None: a = "stg-a"
if b is None: b = "stg-b"
# you know the rest
elif env == "prd":
if a is None: a = "prd-a"
if b is None: b = "prd-b"
# you know the rest
# ...
# your application logic
return results
With pyconject, you can do this:
# in dev_p/dev_sp/pyconject-dev_m-dev.py
dev_func:
a : "dev-a"
b : "dev_b"
...
# in dev_p/dev_sp/dev_m.py
from pyconject import pyconject
@pyconject.func
def dev_func(a, b, c, d):
# your application logic
return results
Features
-
Developer integration
- Functions
- Classes
- Modules
- Packages
-
Client integration
- Functions
- Classes
- Modules
- Packages
- Init (with
globals())
-
Type of configs
- yaml -- priority
- reference other yaml files
- environment/target selection
- yaml -- priority
To Dos
-
Generate config files
-
Raw retrieval of resolved configs (to manipulate by user)
-
Other types of configs
- .env
- override by
- environment variables
- commandline arguments
How to contribute
- Create a PR into
devbranch.- Github actions will run unit-tests.
- Periodically, the package maintainer will PR into
mainbranch.- Unit-tests will be run again.
- When merged, pypi package and github releases will be published.
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
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 pyconject-0.1.6.tar.gz.
File metadata
- Download URL: pyconject-0.1.6.tar.gz
- Upload date:
- Size: 16.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6961f6474a45dcbcc81490badedf1f37f3f9122cf008b1dfb020c7eeb6ddc471
|
|
| MD5 |
4bd541ff4cd08bbf7893f53a278ee84d
|
|
| BLAKE2b-256 |
25480e4039c24adff4bec9a24cc16c0099fc5327b176e5b253b7e6247dcf0f9e
|
Provenance
The following attestation bundles were made for pyconject-0.1.6.tar.gz:
Publisher:
main-push-release.yml on neolaw84/pyconject
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyconject-0.1.6.tar.gz -
Subject digest:
6961f6474a45dcbcc81490badedf1f37f3f9122cf008b1dfb020c7eeb6ddc471 - Sigstore transparency entry: 197349590
- Sigstore integration time:
-
Permalink:
neolaw84/pyconject@3c907256e7b85e4842411443ea337e4710e3d906 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/neolaw84
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main-push-release.yml@3c907256e7b85e4842411443ea337e4710e3d906 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyconject-0.1.6-py3-none-any.whl.
File metadata
- Download URL: pyconject-0.1.6-py3-none-any.whl
- Upload date:
- Size: 14.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e18886df37d932e0560d8a797f4f75d20ec52775a1176d8f94cbdbd0624d25fa
|
|
| MD5 |
0f31d19ef87530802773695455639cc6
|
|
| BLAKE2b-256 |
677e6714a3a0c3263abec5583f64ed758d5c59524b4d80cc8aeade0298f8e7db
|
Provenance
The following attestation bundles were made for pyconject-0.1.6-py3-none-any.whl:
Publisher:
main-push-release.yml on neolaw84/pyconject
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyconject-0.1.6-py3-none-any.whl -
Subject digest:
e18886df37d932e0560d8a797f4f75d20ec52775a1176d8f94cbdbd0624d25fa - Sigstore transparency entry: 197349597
- Sigstore integration time:
-
Permalink:
neolaw84/pyconject@3c907256e7b85e4842411443ea337e4710e3d906 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/neolaw84
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
main-push-release.yml@3c907256e7b85e4842411443ea337e4710e3d906 -
Trigger Event:
push
-
Statement type: