一个python模块,用于以关键字样式json格式管理配置文件。

kwconfig的Python项目详细描述


https://badge.fury.io/py/kwconfig.svghttps://img.shields.io/github/issues/rrwen/kwconfig.svghttps://travis-ci.org/rrwen/kwconfig.svg?branch=masterhttps://coveralls.io/repos/github/rrwen/kwconfig/badge.svg?branch=masterhttps://img.shields.io/badge/license-MIT-blue.svghttps://img.shields.io/github/forks/rrwen/kwconfig.svghttps://img.shields.io/github/stars/rrwen/kwconfig.svghttps://img.shields.io/twitter/url/https/github.com/rrwen/kwconfig.svg?style=social

安装

  1. 安装Python
  2. 通过pip
  3. 安装kwconfig
pip install kwconfig

有关最新的开发人员版本,请参见Developer Install

用法

importkwconfig# Specify a file path for creating kwconfig objectconfig=kwconfig.manage('config.json',defaults={'key0':'value0'})# Update the config file with a key and value dictconfig.update({'key1':'value1','key2':'value2'})# Add a keyword dict to existing config file# If a key exists, it will be updated# If a key does not exist, it will be addedother_config={'key3':'value3'}other_config=config.add(other_config)# Write new values using keyword dictconfig.overwrite({'new_key1':'new_value1','new_key2':'new_value2'})# Obtain a dict of the config file contentskw=config.read()# Remove the key named "key1"config.remove('key1')# Reset to defaultsconfig.reset()# Parsing a keyword list into dict ----# Create a sample list of keyword argumentsargv=['--key1=value1','--key2=value2']# Parse into a keyword dictkwdict=kwconfig.parse(argv)# View the values of key1 and key2print('key1: '+kwdict['key1'])print('key2: '+kwdict['key2'])

有关更多用法详细信息,请参见Documentation

开发人员注释

开发者安装

使用来自github的pip安装最新的开发人员版本:

pip install git+https://github.com/rrwen/kwconfig

git克隆源安装:

  1. 确保git已安装
  2. 克隆到当前路径
  3. 通过pip
  4. 安装
git clone https://github.com/rrwen/kwconfig
cd kwconfig
pip install . -I

测试

  1. 克隆到当前路径git clone https://github.com/rrwen/kwconfig
  2. 进入文件夹cd kwconfig
  3. 确保unittest可用
  4. 运行测试
pip install . -I
python -m unittest

文档维护

  1. 确保sphinx已安装pip install -U sphinx
  2. 更新docs/
  3. 中的文档
pip install . -I
sphinx-build -b html docs/source docs

上传到github

  1. 确保git已安装
  2. 添加所有文件并提交更改
  3. 推到Github
git add .
git commit -a -m "Generic update"
git push

上传到pypi

  1. 确保twine已安装pip install twine
  2. 确保sphinx已安装pip install -U sphinx
  3. 运行测试并检查OK状态
  4. 删除dist目录
  5. kwconfig/__init__.py
  6. 中更新版本
  7. 更新docs/
  8. 中的文档
  9. 创建源分发
  10. 上传到PyPi
pip install . -I
python -m unittest
sphinx-build -b html docs/source docs
python setup.py sdist
twine upload dist/*

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
如何在Java和Javascript之间共享常量   c#无法使用Gson反序列化字节[]   如果字符串是实十进制数字,则在Java中仅显示十进制数字   与Android Studio的java FireBase同步失败   web应用程序的Java Oracle数据库更改通知问题   数组中缺少整数的java嵌套循环   zos在z/os上以TOD格式(一天中的时间)转换Java时间戳   java JAXB未根据注释生成XML(JDK 1.7)   java使用Twitter4j和Geolocation查找在该地区发布推文的用户,但如何获取用户ID?   在Libgdx中实现简单运动模糊的java意外结果   java在Android数据库中插入另一个EditText值?   java标准偏差数组(我的算法错误)   java如何修复M1 Mac的Ant javascript标记?   java遍历树标记值的长度   java理解Springboot中的Cron,自动发送电子邮件   java如何将“Data.Json”文件从资产保存到内部存储器,然后将其用于读/写   java代码在编写FirstDuplicate方法时会遇到时间限制问题   java将HTML转换为PDF并将其添加到段落中   javascript css()未设置正文标记的背景属性