Skip to main content

百宝,方便好用的 Python 常用功能库。把日常开发中反复用到的能力封装成简洁的 API,开箱即用。

Project description

BaiBao (百宝)

方便好用的 Python 常用功能库。把日常开发中反复用到的能力(日志、包管理、数据库、邮件、OCR)封装成简洁的 API,开箱即用。

优势

  • 依赖自动安装import_module() 首次导入时自动下载安装缺失的包,无需手动 pip install
  • 镜像自动切换 — 内置清华、阿里云、中科大等多个 PyPI 镜像,按优先级自动 fallback,国内网络畅通无阻
  • 配置即代码 — 所有配置类均为 dataclass,支持从 JSON 文件一键加载,自动校验必填字段
  • 数据库开箱即用 — 连接池基于 DBUtils,驱动包首次连接时自动安装,支持 MySQL / PostgreSQL
  • OCR 统一接口 — EasyOCR 和 PaddleOCR 共享同一抽象基类,运行时随时切换引擎

模块概览

模块 说明
baibao.base.log 带颜色和级别的日志输出
baibao.base.pip 多镜像源自动切换的包安装工具
baibao.base.util 动态导入模块、加载 JSON 配置等通用工具
baibao.db 数据库连接池(支持 MySQL / PostgreSQL)
baibao.message.email 邮件发送(支持纯文本、HTML、附件)
baibao.util.ocr OCR 文字识别(支持 EasyOCR / PaddleOCR)

安装

# 基础安装(安装后 import baibao 即可使用)
python -m pip install . -i https://pypi.tuna.tsinghua.edu.cn/simple/

# 开发模式(修改源码立刻生效,无需重新安装)
python -m pip install -e . -i https://pypi.tuna.tsinghua.edu.cn/simple/

# 可选:安装 OCR 引擎依赖
python -m pip install ".[easyocr]"    # EasyOCR
python -m pip install ".[paddleocr]"  # PaddleOCR
python -m pip install ".[all]"        # 全部

快速上手

from baibao.base import util

# 自动下载并导入 numpy(如果本机没装的话)
numpy = util.import_module("numpy")

更多用法请查看 使用示例

开发环境

# 安装开发依赖
python -m pip install ".[dev]"

# 代码风格检查
python -m ruff check src/

# 类型检查
python -m mypy src/

# 运行测试
python -m pytest tests/

许可证

GPL-3.0-or-later

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

baibao-0.0.1.tar.gz (21.1 kB view details)

Uploaded Source

Built Distribution

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

baibao-0.0.1-py3-none-any.whl (26.9 kB view details)

Uploaded Python 3

File details

Details for the file baibao-0.0.1.tar.gz.

File metadata

  • Download URL: baibao-0.0.1.tar.gz
  • Upload date:
  • Size: 21.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for baibao-0.0.1.tar.gz
Algorithm Hash digest
SHA256 f94218bc01b5aee64cd0eb5288d88ef9e27905f7dc4ad70b18dbf8abdfbf9b67
MD5 217a36ce6a7148d46222974b6da26ea7
BLAKE2b-256 c8300194419697d0470600fb74046ecd9646b19f4e474f72c8bd5c943e9af275

See more details on using hashes here.

File details

Details for the file baibao-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: baibao-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 26.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for baibao-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 69c2bcc8bb8df368d75b165137b469ac351a406332b4cc47d34ad2ac412ca9fc
MD5 966b6a4b22336d1aefc3978da4acb22d
BLAKE2b-256 f3c60b54581af0449e37084c3752f45ae6d355981e86af4241bc6ff60bd56021

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