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["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.2.tar.gz (4.1 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.2-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for bp_config-0.1.2.tar.gz
Algorithm Hash digest
SHA256 68764ea6596aa0a95a2992f278cf4f0192f32b543c4e068832741dadf058bd2a
MD5 1b69952dcffc1999a956dead01f9ef99
BLAKE2b-256 af342e783f332ec0db17950e03c2a48a7e36c1e0393ef1b789062a81edd3c3d3

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for bp_config-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1ea0b8e678958cbf7df1c63c03a4d118a705140a144b852f2e75688b7f5a336b
MD5 f4d4e0a8d84e0f4882ba058adb2430ab
BLAKE2b-256 bbd9e666c3cfa335adbc4488fabc1564a5a5a223a8d69d390a1503b26bd44c32

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