python registry package
Project description
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())
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
py-ztj-registry-0.0.3.tar.gz
(3.2 kB
view details)
Built Distribution
File details
Details for the file py-ztj-registry-0.0.3.tar.gz
.
File metadata
- Download URL: py-ztj-registry-0.0.3.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 09e35d5d7d475347d1726bc56aff85c30cc02f92d1224401c68fcfdcb1e0c399 |
|
MD5 | ff067f2e553570611fed83f96e43c1b2 |
|
BLAKE2b-256 | ce1f2f8276658801cac363f9d2dafbb04cd60ea07e6672a0c03a58a36624ac83 |
File details
Details for the file py_ztj_registry-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: py_ztj_registry-0.0.3-py3-none-any.whl
- Upload date:
- Size: 3.2 kB
- Tags: Python 3
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b286d00f0cd94998d7809d98228e36d5b5b01a7e80fbdce3fd29332ac98bc49c |
|
MD5 | 81716e00e9cfc97bfd9508f936742a00 |
|
BLAKE2b-256 | 7964dde68942bc06b44ecf36c6c3a77a8ecdf6af267b216f8fe904e4d65e52df |