Skip to main content

一个简单的 Python 调试辅助工具包

Project description

debug-helpers

一个简单的 Python 调试辅助工具包。

PyPI version Python Version License: MIT

功能特性

  • hello(name) - 返回问候语
  • add(a, b) - 两数相加
  • print_dict(data, level) - 格式化打印字典,支持日志分级

安装

从 PyPI 安装(推荐)

pip install debug-helpers

从 TestPyPI 安装(测试版本)

pip install -i https://test.pypi.org/simple/ debug-helpers

开发模式安装

git clone <repository>
cd python_debug_helpers
pip install -e .

快速开始

from debug_helpers import hello, add, print_dict

# 基本功能
print(hello("World"))  # Hello, World!
print(add(1, 2))       # 3

# 打印字典
data = {
    "name": "Alice",
    "age": 30,
    "hobbies": ["reading", "coding"]
}
print_dict(data)

输出:

{
  "name": "Alice",
  "age": 30,
  "hobbies": [
    "reading",
    "coding"
  ]
}

高级用法

日志分级

print_dict 支持不同的日志级别:

import logging
logging.basicConfig(level=logging.DEBUG)

from debug_helpers import print_dict

# 不同级别的日志
print_dict({"info": "data"}, level="info")      # INFO 级别
print_dict({"warning": "msg"}, level="warning") # WARNING 级别
print_dict({"error": "msg"}, level="error")     # ERROR 级别
print_dict({"debug": "msg"}, level="debug")     # DEBUG 级别

嵌套结构

支持复杂的嵌套数据结构:

from debug_helpers import print_dict

complex_data = {
    "project": "debug_helpers",
    "version": "0.3.0",
    "features": ["hello", "add", "print_dict"],
    "metadata": {
        "author": "Example Author",
        "tags": ["python", "debug", "tools"]
    }
}

print_dict(complex_data)

本地开发

使用 Makefile(推荐)

# 查看所有命令
make help

# 开发模式安装
make install-local

# 运行示例
make example

# 运行测试
make test

# 清理构建文件
make clean

# 构建包
make build

手动操作

# 克隆项目
git clone <repository>
cd python_debug_helpers

# 开发模式安装
pip install -e .

# 运行示例
python examples/test.py

# 运行测试
pytest tests/ -v

# 构建
python -m build

项目结构

python_debug_helpers/
├── src/
│   └── debug_helpers/      # 源代码
│       ├── __init__.py
│       ├── main.py
│       └── print.py
├── tests/                  # 单元测试
│   └── test_example.py
├── examples/               # 使用示例
│   ├── test.py
│   └── readme.md
├── docs/                   # 文档
│   ├── 01_README.md       # 文档索引
│   ├── 01_release.md      # 发布指南
│   ├── 02_local_development.md
│   ├── 03_package_vs_module_name.md
│   └── ...
├── scripts/                # 发布脚本
│   ├── publish_testpypi.sh
│   └── publish_pypi.sh
├── Makefile               # 自动化任务
├── pyproject.toml         # 项目配置
├── CHANGELOG.md           # 更新日志
├── LICENSE                # 许可证
└── README.md              # 本文件

文档

快速链接

重要说明

包名 vs 模块名

  • 安装时使用pip install debug-helpers(包名,带连字符)
  • 导入时使用from debug_helpers import ...(模块名,带下划线)

详见:包名与模块名详解

发布流程

使用 Makefile(推荐)

# 1. 发布到 TestPyPI 测试
make publish-test

# 2. 从 TestPyPI 安装验证
make install-test

# 3. 发布到正式 PyPI
make publish-pypi

# 4. 从 PyPI 安装验证
make install

使用脚本

# 发布到 TestPyPI
./scripts/publish_testpypi.sh

# 发布到正式 PyPI
./scripts/publish_pypi.sh

详见:发布指南

系统要求

  • Python >= 3.9
  • pip >= 21.0

版本历史

版本 日期 主要变更
0.3.0 2026-01-24 改名为 debug-helpers,优化示例代码,添加 Makefile
0.2.0 2026-01-24 添加 print_dict 功能
0.1.0 2026-01-24 初始版本

完整更新日志:CHANGELOG.md

贡献

欢迎贡献!请遵循以下步骤:

  1. Fork 项目
  2. 创建特性分支 (git checkout -b feature/AmazingFeature)
  3. 提交更改 (git commit -m 'Add some AmazingFeature')
  4. 推送到分支 (git push origin feature/AmazingFeature)
  5. 开启 Pull Request

问题反馈

如果遇到问题或有建议,请:

  1. 查看 文档
  2. 查看 已知问题
  3. 提交 Issue

许可证

MIT License - 详见 LICENSE 文件

作者

Example Author

相关链接


注意:本项目原名为 debug-tools,因 PyPI 名称冲突改为 debug-helpers。详见 Issue 记录

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

debug_helpers-0.4.0.tar.gz (52.7 kB view details)

Uploaded Source

Built Distribution

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

debug_helpers-0.4.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file debug_helpers-0.4.0.tar.gz.

File metadata

  • Download URL: debug_helpers-0.4.0.tar.gz
  • Upload date:
  • Size: 52.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for debug_helpers-0.4.0.tar.gz
Algorithm Hash digest
SHA256 ba1c2726459955de57f8c6e401b58ead489d1572813af05703ca3b87ac2108c7
MD5 1aa618fd7bcb6511c08b39e129ed6dce
BLAKE2b-256 a41b3c61f6ece1478be69d6a94aba58f05729675faef2ea1a2b786dd1719d001

See more details on using hashes here.

File details

Details for the file debug_helpers-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: debug_helpers-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for debug_helpers-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 80836d7da6c5bd36988f0a87bec0ce1587d75b1df9f27387d540a98bd877520e
MD5 daf6bfaed41253a18282f9f64bfdcc13
BLAKE2b-256 166b9646757c4efb37d440edc8080a9d28799686bbb277e9dff657783d5d7b53

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