Python Registry Package
说明
这是一个 Python 配置快速调用模块,主要解决 Json or Yaml 深层次配置调用问题。
链接
安装
pip install py-ztj-registry
设置获取数据
from registry import Registry
registry = Registry()
registry.set('a', 'a')
registry.set('b', {'bb': 'bbb'})
registry.set('c.h', 'h')
print(registry.get())
print(registry.get('b.bb'))
加载字典
from registry import Registry
registry = Registry()
registry.load({'a': {'aa': 'aaa'}})
print(registry.get('a.aa'))
合并字典
from registry import Registry
registry = Registry()
registry.load({'a': {'a1': 'aaa1'}})
registry.merge('a', {'a2': 'aaa2' })
print(registry.get('a'))
设置默认值
from registry import Registry
registry = Registry()
registry.set('a', 'aaa')
registry.default('a', 'bbb')
registry.default('c', 'ccc')
print(registry.get('a'))
print(registry.get('c'))
钩子调用
import time
from registry import Registry
registry = Registry()
def callback():
print('callback')
registry.set_hook('hook', 3, callback)
time.sleep(1)
registry.refresh_hook('hook')
time.sleep(3)
registry.refresh_hook('hook')
扁平化数据
from registry import Registry
registry = Registry({'a': {'aa': 'aaa'}, 'b': {'bb': 'bbb'}})
print(registry.flat())
Metadata
Release files for py-ztj-registry 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| py-ztj-registry-0.0.4.tar.gz | 3.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| py_ztj_registry-0.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.5 kB
Release files / py-ztj-registry-0.0.4.tar.gz
| Download URL | py-ztj-registry-0.0.4.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8c12b29f6b64b752e99e58e9a95ed6c63736f5d465bcca85411311fe3bc5e643
|
|
BLAKE2b-256 checksum How to use checksums |
ceb88778d52266a7646a6078981301cf63602ccf340d3e7a50d74c6e1bd039b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
|
Release files / py_ztj_registry-0.0.4-py3-none-any.whl
| Download URL | py_ztj_registry-0.0.4-py3-none-any.whl |
|---|---|
| Size | 3.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6715b71fc28a8b46184e49610538dbab8e6b519c60d1ec27ba5d05f367c599f3
|
|
BLAKE2b-256 checksum How to use checksums |
de5aebed075f7ef7580c328b336e97a6c7fa592a5811690909455977225a20e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
|