C41811.Config 0.2.0
pip install C41811.Config
Released:
Simplifies config management with flexible API and formats.
Navigation
Verified details
These details have been verified by PyPIProject links
GitHub Statistics
Maintainers
Unverified details
These details have not been verified by PyPIProject links
Meta
- Author: C418____11
- Tags config, yaml, toml, json
- Requires: Python >=3.12
-
Provides-Extra:
docs
,dev
,tox
,test
,flake8
,mypy
,pyyamlsl
,ruamelyamlsl
,tomlsl
Classifiers
- Development Status
- Intended Audience
- Natural Language
- Operating System
- Programming Language
- Topic
- Typing
Project description
C41811.Config
English | 中文
文档 | |
---|---|
PyPI | |
仓库 | |
代码质量-主分支 | |
代码质量-开发分支 |
简介
C41811.Config 旨在通过提供一套简洁的 API 和灵活的配置处理机制,来简化配置文件的管理。无论是简单的键值对配置,还是复杂的嵌套结构,都能轻松应对。它不仅支持多种配置格式,还提供了丰富的错误处理和验证功能,确保配置数据的准确性和一致性。
特性
- 多格式支持:支持多种流行的配置格式,包括 JSON、YAML、TOML 和 Pickle,满足不同项目的需求。
- 模块化设计:通过模块化的设计,提供了灵活地扩展机制,开发者可以根据需要添加自定义的配置处理器。
- 验证功能:支持通过验证器来验证配置数据的合法性,确保配置数据的正确性。
- 易于使用:提供了一套简洁的 API,开发者可以轻松地加载、修改和保存配置文件。
适用场景
C41811.Config 适用于多种配置管理场景,特别是以下几种情况:
- 大型项目:允许通过命名空间或配置池隔离项目各部分的配置,使得配置管理更加清晰和有序。
- 分散的配置文件:通过提供统一的接口和灵活地处理机制,使得分散的配置文件能够被集中管理和访问,提高了配置的效率和一致性。
- 复杂的数据模型:自动填充缺失的键默认值,并对配置数据进行类型验证,确保配置数据的完整性和准确性。
- 需要对配置进行复杂操作:提供了 get、setdefault、unset 等方法,简化了对配置数据的复杂操作。
- 多种配置格式混搭:支持根据文件后缀自动从注册的处理器中推断合适的配置格式,使得不同格式的配置文件可以无缝混用。
- 动态配置更新:支持在运行时动态更新配置,无需重启应用即可应用新的配置。
安装
pip install C41811.Config
一个简单的示例
from C41811.Config import MappingConfigData
from C41811.Config import JsonSL
from C41811.Config import requireConfig
from C41811.Config import saveAll
JsonSL().register_to()
cfg: MappingConfigData = requireConfig(
'', "Hello World.json",
{ # 简单且强大的配置数据验证器
"Hello": "World",
"foo": dict, # 包含foo下的所有键
"foo\\.bar": { # foo.bar仅包含baz键
"baz": "qux"
}
}
).check()
saveAll()
print(f"{cfg=}")
print()
print("与dict完全相同的数据访问方式")
print(f"{cfg["Hello"]=}")
print(f"{cfg["foo"]["bar"]=}")
print()
print("通过属性访问数据")
print(f"{cfg.foo=}")
print(f"{cfg.foo.bar.baz=}")
print()
print("通过特殊语法访问数据")
print(f"{cfg.retrieve("foo\\.bar\\.baz")=}")
print()
print("一些常用方法")
print(f"{cfg.unset("foo\\.bar\\.baz").exists("foo\\.bar\\.baz")=}")
print(f"{cfg.get("foo\\.bar\\.baz")=}")
print(f"{cfg.setdefault("foo\\.bar\\.baz","qux")=}")
print(f"{cfg.get("foo\\.bar\\.baz", default="default")=}")
print(f"{cfg.modify("foo\\.bar\\.baz", [1, 2, 3]).retrieve("foo\\.bar\\.baz\\[1\\]")=}")
print(f"{cfg.delete("foo\\.bar\\.baz").get("foo\\.bar\\.baz", default="default")=}")
Project details
Verified details
These details have been verified by PyPIProject links
GitHub Statistics
Maintainers
Unverified details
These details have not been verified by PyPIProject links
Meta
- Author: C418____11
- Tags config, yaml, toml, json
- Requires: Python >=3.12
-
Provides-Extra:
docs
,dev
,tox
,test
,flake8
,mypy
,pyyamlsl
,ruamelyamlsl
,tomlsl
Classifiers
- Development Status
- Intended Audience
- Natural Language
- Operating System
- Programming Language
- Topic
- Typing
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
File details
Details for the file c41811_config-0.2.0.tar.gz
.
File metadata
- Download URL: c41811_config-0.2.0.tar.gz
- Upload date:
- Size: 51.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e29f6d93c140fc27ca94fa1a341eac72116185856185683cae14f6495d6056ac |
|
MD5 | c37977d59581c36363298a0ecc4b3ebf |
|
BLAKE2b-256 | 755f2abe303baf48c30bdd56a2039cf7628bab278ddeddadddb95f429bd80022 |
Provenance
The following attestation bundles were made for c41811_config-0.2.0.tar.gz
:
Publisher:
python-publish.yml
on C418-11/C41811_Config
-
Statement:
- Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
c41811_config-0.2.0.tar.gz
- Subject digest:
e29f6d93c140fc27ca94fa1a341eac72116185856185683cae14f6495d6056ac
- Sigstore transparency entry: 198894857
- Sigstore integration time:
- Permalink:
C418-11/C41811_Config@218b8eaa5b55f93e90e1c69dd58724202d2511b5
- Branch / Tag:
refs/tags/v0.2.0
- Owner: https://github.com/C418-11
- Access:
public
- Token Issuer:
https://token.actions.githubusercontent.com
- Runner Environment:
github-hosted
- Publication workflow:
python-publish.yml@218b8eaa5b55f93e90e1c69dd58724202d2511b5
- Trigger Event:
release
- Statement type:
File details
Details for the file c41811_config-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: c41811_config-0.2.0-py3-none-any.whl
- Upload date:
- Size: 69.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 648bfafe9902b48d216e51e7f89ae66a8dc4271a277c137cc2840134f9f7266b |
|
MD5 | a47db468de34050e3a648f84a8af6ccb |
|
BLAKE2b-256 | 875a5abc46c38f5340346b2ce054ba394118a4c67fc578a60d45e4d3cd7e6fb7 |
Provenance
The following attestation bundles were made for c41811_config-0.2.0-py3-none-any.whl
:
Publisher:
python-publish.yml
on C418-11/C41811_Config
-
Statement:
- Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
c41811_config-0.2.0-py3-none-any.whl
- Subject digest:
648bfafe9902b48d216e51e7f89ae66a8dc4271a277c137cc2840134f9f7266b
- Sigstore transparency entry: 198894868
- Sigstore integration time:
- Permalink:
C418-11/C41811_Config@218b8eaa5b55f93e90e1c69dd58724202d2511b5
- Branch / Tag:
refs/tags/v0.2.0
- Owner: https://github.com/C418-11
- Access:
public
- Token Issuer:
https://token.actions.githubusercontent.com
- Runner Environment:
github-hosted
- Publication workflow:
python-publish.yml@218b8eaa5b55f93e90e1c69dd58724202d2511b5
- Trigger Event:
release
- Statement type: