no_config
把yaml、json和toml等配置文件映射为类,需要很多冗余代码或者魔术字符串。这对代码的维护工作提出了更高的要求,no_config能简化这种映射,仅仅需要两行代码即可完成映射。更多文档信息请参考https://ncdhz.github.io/no_config。
安装
pip安装
pip install no_config
源码安装
git clone https://github.com/ncdhz/no_config.git
# 进入no_config目录执行下面语句
pip install .
快速开始
下面将用一个简短的例子介绍本库该怎么使用,例子中使用的源码在examples/start/start.py。
把配置文件中的信息,映射到实体类
User中。
-
配置文件
# 创建配置文件start.yaml user: username: ncdhz password: ncdhz
-
源码文件
from os import path from no_config import Config # 配置注入 @Config class User: password = None username = None if __name__ == '__main__': # 配置初始化 # 全局只需一次初始化 # 在更改配置之后可以通过此函数刷新配置 Config.init(path.join(path.dirname(__file__), 'start.yaml')) print(User.password) print(User.username)
Metadata
Release files for no-config 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| no_config-0.1.5.tar.gz | 6.0 kB | Without provenance | Details for no_config-0.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| no_config-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for no_config-0.1.5-py3-none-any.whl |
Total release size: 12.6 kB
Release files / no_config-0.1.5.tar.gz
| Download URL | no_config-0.1.5.tar.gz |
|---|---|
| Size | 6.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cc174b40cb8d4dbdba62212df17cf0db5124d24f364b13adb942ad6b410973be
|
|
BLAKE2b-256 checksum How to use checksums |
1996ce97aa6ac5af797f130d70f58ca9dac0a580b15d01df8f8bb4850a2ff31d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.10
|
Release files / no_config-0.1.5-py3-none-any.whl
| Download URL | no_config-0.1.5-py3-none-any.whl |
|---|---|
| Size | 6.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
af77bbcd217ed3fec1fd226afa01833beef7584e6737387a8a5991c587fcdcfd
|
|
BLAKE2b-256 checksum How to use checksums |
c03423a158c385b5204bb974b5738dc186f1aacede2f7612f30f6fdc7bda38bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.10
|
Security for no-config 0.1.5
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.