Skip to main content

Simple configuration handling in Python.

Project description

no_config

yamljsontoml等配置文件映射为类,需要很多冗余代码或者魔术字符串。这对代码的维护工作提出了更高的要求,no_config能简化这种映射,仅仅需要两行代码即可完成映射。更多文档信息请参考https://ncdhz.github.io/no_config

快速开始

下面将用一个简短的例子介绍本库该怎么使用,例子中使用的源码在examples/start/start.py

  1. 配置文件

    # 创建配置文件start.yaml
    user:
        username: ncdhz
        password: ncdhz
    
  2. 源码文件

    from os import path
    from no_config import Config
    
    # 配置注入
    @Config
    class User:
        password = None
        username = None
    
    if __name__ == '__main__':
        # 配置初始化
        # 全局只需一次初始化
        # 在更改配置之后可以通过此函数刷新配置
        Config.init(path.join(path.dirname(__file__), 'start.yaml'))
        print(User.password)
        print(User.username)
    

安装

pip安装

pip install no_config

源码安装

git clone https://github.com/ncdhz/no_config.git
# 进入no_config目录执行下面语句
pip install .

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

no_config-0.0.2.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

no_config-0.0.2-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file no_config-0.0.2.tar.gz.

File metadata

  • Download URL: no_config-0.0.2.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for no_config-0.0.2.tar.gz
Algorithm Hash digest
SHA256 4e4e97e34abfc9fd6f0f5d41c3ae39b19a1c12871eab231d7d04cfec99ea086e
MD5 ebc2eceac09e89bedeeb16a04d6f8c68
BLAKE2b-256 bfc5da85431d21ac476d461ec2e044a2a6fea0b13b9588409d5174214e55918a

See more details on using hashes here.

File details

Details for the file no_config-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: no_config-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for no_config-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 319c06b6826d37e6bb9ef4120933c44dd4a8c3298fa21d6aa5c5f1c77457d7b5
MD5 b6ff4d1bf880e263bbfc220189ea260b
BLAKE2b-256 fcbcfe89e6e373a5834a6e0e72a70ec455050005fa02f1c2034644d595f662bc

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