Skip to main content

Lightweight Operational Progress Kit - 轻量级操作进度工具包

Reason this release was yanked:

版本号问题

Project description

Lightweight Operational Progress Kit (LOPK) v2.0

Python Version License: MIT PyPI Version

一个轻量级的操作进度工具包,提供丰富的进度条和终端操作功能。

✨ 新特性 (v2.0)

  • 🎨 彩色进度条 - 支持多种颜色主题
  • 🔄 旋转指示器 - 异步任务状态指示
  • ⏱️ 倒计时器 - 精确的倒计时功能
  • 📊 多进度条管理 - 同时管理多个进度条
  • 🖥️ 终端工具函数 - 清屏、光标控制等
  • 🌐 跨平台支持 - Windows、Linux、macOS
  • 📦 PyPI发布就绪 - 完整的打包配置

安装

pip install lopk

快速开始

基本进度条

from LOPK11 import ProgressBar

# 创建进度条
bar = ProgressBar(100, "下载", color="cyan", show_time=True)

# 更新进度
for i in range(101):
    bar.update(i)
    time.sleep(0.1)

旋转指示器

from LOPK11 import Spinner

# 使用上下文管理器
with Spinner("正在处理数据"):
    # 执行耗时操作
    time.sleep(3)
print("处理完成!")

倒计时器

from LOPK11 import CountdownTimer

# 5秒倒计时
with CountdownTimer(5, "准备开始"):
    pass
print("开始!")

多进度条

from LOPK11 import MultiProgressBar

# 创建多进度条管理器
multi_bar = MultiProgressBar(3)

# 添加多个进度条
bar1 = multi_bar.add_bar(100, "任务1", color="green")
bar2 = multi_bar.add_bar(50, "任务2", color="blue")
bar3 = multi_bar.add_bar(200, "任务3", color="red")

# 同时更新多个进度条
for i in range(101):
    multi_bar.update(bar1, i)
    multi_bar.update(bar2, min(i*2, 50))
    multi_bar.update(bar3, min(i*2, 200))
    time.sleep(0.05)

API 参考

ProgressBar 类

ProgressBar(total, prefix='', suffix='', length=50, fill='█', 
            print_end="\r", color='green', show_time=True)
  • total: 总进度值
  • prefix: 进度条前缀文本
  • suffix: 进度条后缀文本
  • length: 进度条长度(字符数)
  • fill: 进度条填充字符
  • color: 颜色主题 (green, blue, red, yellow, cyan, magenta)
  • show_time: 是否显示耗时

方法:

  • update(progress=None, suffix=None): 更新进度
  • reset(): 重置进度条
  • finish(): 强制完成

Spinner 类

Spinner(message="处理中...", delay=0.1)

方法:

  • start(): 开始旋转
  • stop(): 停止旋转

CountdownTimer 类

CountdownTimer(seconds, message="倒计时")

方法:

  • start(): 开始倒计时

工具函数

  • AK(): 等待用户按下回车
  • cls(): 清屏(跨平台)
  • clear_line(): 清除当前行
  • get_terminal_size(): 获取终端尺寸
  • colored_text(text, color): 彩色文本输出

命令行工具

安装后可以使用命令行演示:

lopk-demo

开发

安装开发版本

git clone https://github.com/your-username/lopk.git
cd lopk
pip install -e .[dev]

运行测试

pytest

代码格式化

black .
flake8

贡献

欢迎提交 Issue 和 Pull Request!

许可证

MIT License - 详见 LICENSE 文件

更新日志

v2.0.0 (2024-01-01)

  • ✨ 新增彩色进度条功能
  • 🔄 添加旋转指示器
  • ⏱️ 新增倒计时器
  • 📊 支持多进度条管理
  • 📦 完整的PyPI发布配置
  • 📚 完善的文档和示例

v1.0.0 (2023-12-01)

  • 🎯 基础进度条功能
  • 🖥️ 基本终端操作函数
  • 📝 初始版本发布

作者: I-love-china
邮箱: your-email@example.com
项目地址: https://github.com/your-username/lopk

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

lopk-4.0.1.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

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

lopk-4.0.1-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file lopk-4.0.1.tar.gz.

File metadata

  • Download URL: lopk-4.0.1.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for lopk-4.0.1.tar.gz
Algorithm Hash digest
SHA256 ee99075ecd8ae090a4b10bfd2e5708ae347157688cb863912a9e6929156c1631
MD5 42b6046d48cb7aea691f71c2a2d8c36e
BLAKE2b-256 c19f396faa4d381e29c057f8f90138bb95f06985eff676595f3b3e0077a62258

See more details on using hashes here.

File details

Details for the file lopk-4.0.1-py3-none-any.whl.

File metadata

  • Download URL: lopk-4.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for lopk-4.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e8b4a61b6232e5dd33947256313066e71d67565bc8371a298620298c64002997
MD5 60e8dc86798e452e5a0c6a0abca091f2
BLAKE2b-256 b32d1638aec8c89f5a46121e390977e9fc5cd5824b538793168d12080c9c463e

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