Skip to main content

A configuration file handler supporting YAML, JSON and TOML formats

Project description

bp-config

一个支持 YAML/JSON/TOML 格式的配置文件处理器

功能特性

  • 支持读取和写入 YAML、JSON、TOML 格式的配置文件
  • 自动根据文件扩展名选择对应的解析器
  • 支持 UTF-8 编码,完美处理中文内容
  • 简洁易用的 API 设计

安装

pip install bp-config

快速开始

from bp_config import ConfigHandler

# 初始化处理器
handler = ConfigHandler()  # 默认使用当前目录

# 读取配置
config = handler.read_config("config.yaml")  # 或 config.json/config.toml

# 修改配置
config["new_key"] = "value"

# 写入配置
handler.write_config("config.yaml", config)

API 文档

ConfigHandler()

read_config(filename)
读取并解析配置文件

参数:
filename: 配置文件名(相对或绝对路径)
返回: 解析后的字典对象
异常:
ValueError: 不支持的格式
FileNotFoundError: 文件不存在
IOError: 读取失败

write_config(filename, config)
将配置写入文件

参数:
filename: 要写入的文件名
config: 要写入的配置字典
异常:
ValueError: 不支持的格式
IOError: 写入失败

许可证 MIT 许可证 - 详见 LICENSE 文件

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

bp_config-0.1.1.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bp_config-0.1.1-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file bp_config-0.1.1.tar.gz.

File metadata

  • Download URL: bp_config-0.1.1.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.7

File hashes

Hashes for bp_config-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f27be092bf2e690d4846feaf516c019603a49210f9f23f687ab92999e029987b
MD5 684be566046d19973893772592dba5f5
BLAKE2b-256 28bd726389fc4b6f372e0d3bbcb918c9ef069888bd43a711df33e85128c25eea

See more details on using hashes here.

File details

Details for the file bp_config-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: bp_config-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.7

File hashes

Hashes for bp_config-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ae1c028406fe05b40f12b5cd595ef247f389c16a81ad2ae80d27e4ff3ec6628f
MD5 ed79a7bcb105610a85515dded2ff560b
BLAKE2b-256 4ec222a90bb69d06e7e78790af2febef86a1387b79f6d7bfb0fabf8209c4a002

See more details on using hashes here.

Supported by

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