Skip to main content

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

Reason this release was yanked:

有严重bug

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-2.0.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

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

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for lopk-2.0.0.tar.gz
Algorithm Hash digest
SHA256 62c6c5bd2870f7ede3822b7330b024d4051780a10139050281d40165c1151def
MD5 b4f901f77151ccf39d3db8389bb6250b
BLAKE2b-256 c3fe2d66da2e3960690f8dc71cb303ce88cb191690ee8bb5e18e58265662cb06

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lopk-2.0.0-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-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 76b0edef679a854873f5d1ebfa8d033c87771066b73d096536adefb5a4890b6d
MD5 ce1f4a6d67b2ef67e9f88ba9751bc53d
BLAKE2b-256 37200994809c8c79ae7afe2d6eab8a08cf3e2fb66381b6aedf4dd901929826e2

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