Skip to main content

python registry package

Project description

Python Registry Package

说明

这是一个 Python 配置快速调用模块,主要解决 Json or Yaml 深层次配置调用问题。

使用

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')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

File details

Details for the file py_ztj_registry-0.0.1-20190904054932-py3-none-any.whl.

File metadata

  • Download URL: py_ztj_registry-0.0.1-20190904054932-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

File hashes

Hashes for py_ztj_registry-0.0.1-20190904054932-py3-none-any.whl
Algorithm Hash digest
SHA256 e1dafef456d9856c646600e4448737b503c0005bffa2e0daa4e64de558eeada2
MD5 94152bf7515ded997b7e33076636cc54
BLAKE2b-256 1dc8cc2034e8c6d06ed01a2cd97bf73957fff2e2f3839eab9109fa0605fd5003

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page