Skip to main content

又一个终端微调器

项目描述

亚斯平标志

yaspin : Y et A other Terminal Spinner for Python

覆盖范围 皮皮 黑片

版本 车轮 例子

下载Tot 下载W

Yaspin提供了一个功能齐全的终端微调器,用于显示长时间挂起操作的进度。

https://raw.githubusercontent.com/pavdmyt/yaspin/master/gifs/demo.gif

通过将其用作上下文管理器 或函数装饰器,可以轻松地将其集成到现有代码库中:

import time
from yaspin import yaspin

# Context manager:
with yaspin():
    time.sleep(3)  # time consuming code

# Function decorator:
@yaspin(text="Loading...")
def some_operations():
    time.sleep(3)  # time consuming code

some_operations()

Yaspin还提供了一个直观而强大的 API。例如,您可以轻松召唤鲨鱼:

import time
from yaspin import yaspin

with yaspin().white.bold.shark.on_blue as sp:
    sp.text = "White bold shark in a blue sea"
    time.sleep(5)
https://raw.githubusercontent.com/pavdmyt/yaspin/master/gifs/shark.gif

特征

$ python script_that_uses_yaspin.py > script.log
$ python script_that_uses_yaspin.py | grep ERROR

安装

PyPI使用pip包管理器:

pip install --upgrade yaspin

或者从 GitHub 安装最新的源代码:

pip install https://github.com/pavdmyt/yaspin/archive/master.zip

用法

基本示例

https://raw.githubusercontent.com/pavdmyt/yaspin/master/gifs/basic_example.gif