Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

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

高级用法

### 实例化 Redis
Redis(**registry.get(prefix))

### 初始化 Mysql
Mysql(**registry.get(prefix))

Project details


Download files

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

Files for py-configs-registry, version 0.0.2
Filename, size File type Python version Upload date Hashes
Filename, size py_configs_registry-0.0.2-py3-none-any.whl (3.6 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size py_configs_registry-0.0.2.tar.gz (2.4 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page