2024-05-14 01:22:57 +00:00
|
|
|
<div align="center">
|
|
|
|
|
|
|
|
![](.media/icon-128x128_round.png)
|
|
|
|
|
2022-04-19 02:16:23 +00:00
|
|
|
# cfig
|
|
|
|
|
2024-05-14 01:22:57 +00:00
|
|
|
Configuration helper for Python
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
## Links
|
|
|
|
|
|
|
|
[![PyPI](https://img.shields.io/pypi/v/cfig)](https://pypi.org/project/cfig)
|
|
|
|
|
|
|
|
[![Documentation](https://img.shields.io/readthedocs/cfig)](https://cfig.readthedocs.io/en/latest/)
|
2022-04-19 02:16:23 +00:00
|
|
|
|
2024-05-14 01:22:57 +00:00
|
|
|
## Example
|
2022-04-19 02:19:23 +00:00
|
|
|
|
2022-04-19 02:16:23 +00:00
|
|
|
```python
|
|
|
|
import cfig
|
|
|
|
|
|
|
|
config = cfig.Configuration()
|
|
|
|
|
|
|
|
@config.required()
|
|
|
|
def SECRET_KEY(val: str) -> str:
|
2022-04-20 02:15:10 +00:00
|
|
|
"""Secret string used to manage HTTP session tokens."""
|
2022-04-19 02:16:23 +00:00
|
|
|
return val
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
config.cli()
|
|
|
|
```
|
|
|
|
|
2022-04-19 02:18:05 +00:00
|
|
|
```python
|
2022-04-19 02:19:23 +00:00
|
|
|
from mypackage.mycfig import SECRET_KEY
|
2022-04-19 02:18:05 +00:00
|
|
|
|
2022-04-19 02:18:22 +00:00
|
|
|
print(f"My SECRET_KEY is: {SECRET_KEY}")
|
2022-04-19 02:18:05 +00:00
|
|
|
```
|
|
|
|
|
2022-04-19 02:16:23 +00:00
|
|
|
```console
|
2022-04-19 02:19:23 +00:00
|
|
|
$ python -m mypackage.mycfig
|
2022-04-20 02:15:10 +00:00
|
|
|
===== Configuration =====
|
2022-04-19 02:16:23 +00:00
|
|
|
|
|
|
|
SECRET_KEY → Required, but not set.
|
|
|
|
Secret string used to manage HTTP session tokens.
|
2022-04-20 02:15:10 +00:00
|
|
|
|
|
|
|
===== End =====
|
2022-04-19 02:16:23 +00:00
|
|
|
```
|