A package designed to simplify configurable defaults from argparse.
Project description
cfg_param_wrapper 1.0.0
a config wrapper I made. It's made to wrap simple functions, and intercept configurations in tandem with a CfgDict object.
Installation
# from pypi:
pip install cfg-argparser
# from github:
git clone "https://github.com/zeptofine/cfg-argparser"
cd cfg-argparser
pip install -e .
Example
from cfg_param_wrapper import wrap_config, CfgDict
cfg = CfgDict("test.json")
@wrap_config(cfg)
def test_function(s: str, is_real: bool = True): # I'd advise only wrapping functions all having default methods
return f"{s} is {'real' if is_real else 'fake'}"
if __name__ == "__main__":
print(test_function("We"))
cfg['s'] = "us"
print(test_function()) # Linters hate him!
Compatibilty
This was mainly tested on 3.9 and 3.10, but it should work from 3.6 onwards. i can't test earlier versions for some reason.
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
Close
Hashes for cfg_param_wrapper-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40264003bfd2ed28304b1a83d9e21f0d78b6c201620765a6608d147d39aca0c2 |
|
MD5 | 3389aec7241f64fde53dd611f3a87f1f |
|
BLAKE2b-256 | 6edecc209afefc02c0e2210235950bb0fe868ee10611f815fe6ccbea55b01860 |