Skip to main content

Python Config Registry Package

说明

这是一个 Python 配置快速注册调用模块,主要解决多维数组深层次配置调用问题。

链接

安装

pip install config-registry

设置获取数据

from ConfigRegistry import ConfigRegistry

setting = Registry()

setting.set('a', 'a')
setting.set('b', {'bb': 'bbb'})
setting.set('c.h', 'h')

print(setting.get())
print(setting.get('b.bb'))

加载字典

from ConfigRegistry import ConfigRegistry

setting = ConfigRegistry()

setting.load({'a': {'aa': 'aaa'}})
print(setting.get('a.aa'))

合并字典

from ConfigRegistry import ConfigRegistry

setting = ConfigRegistry()

setting.load({'a': {'a1': 'aaa1'}})
setting.merge('a', {'a2': 'aaa2' })
print(setting.get('a'))

设置默认值

from ConfigRegistry import ConfigRegistry

setting = ConfigRegistry()

setting.set('a', 'aaa')
setting.default('a', 'bbb')
setting.default('c', 'ccc')
print(setting.get('a'))
print(setting.get('c'))

钩子调用

import time
from ConfigRegistry import ConfigRegistry

setting = ConfigRegistry()

def callback():
    print('callback')

setting.set_hook('hook', 3, callback)
time.sleep(1)
setting.refresh_hook('hook')
time.sleep(3)
setting.refresh_hook('hook')

扁平化数据

from ConfigRegistry import ConfigRegistry

setting = ConfigRegistry({'a': {'aa': 'aaa'}, 'b': {'bb': 'bbb'}})
print(setting.flat())

Metadata

Release files for config-registry 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for config-registry 1.0.0
File Size Uploaded
config-registry-1.0.0.tar.gz 3.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for config-registry 1.0.0
File Interpreter ABI Platform
config_registry-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 6.5 kB

Release files / config-registry-1.0.0.tar.gz

Download URL config-registry-1.0.0.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
f39d4c90978de404e18157b9b3d1ad84612402d103f9f34a5106e3aaa0d7758d
BLAKE2b-256 checksum
How to use checksums
c0579f8c661892693227a06c78626ba9afc3852901f1ce9088fd86ad70895b54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.4.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

Release files / config_registry-1.0.0-py3-none-any.whl

Download URL config_registry-1.0.0-py3-none-any.whl
Size 3.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c1fb73260cf0023ce37a332e4b86f9d2003e72e0663de6f174f3371319730101
BLAKE2b-256 checksum
How to use checksums
04203cd7f3a43a04b9bd9d1733246b204d7ab2d9f7a849186d50efd7655ac7e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.4.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page