python脚本的基本动画ascii加载程序
pyloaders的Python项目详细描述
挂载机
python脚本的基本动画ascii加载程序。
- 旋转装载机
- 文本加载器
- 装料机
- 进度加载器
安装
pip install pyloaders
源代码
git clone https://gitlab.com/ml394/pyloaders.git
cd pyloaders
python setup.py install
用法
所有加载程序都是通过调用LoaderClass(<arguments>)
参数
Option | Description | Type | Choices | Default | Valid For |
---|---|---|---|---|---|
text | Text displayed while loading | str | 'Loading' | Text, Spinning | |
size | Full width of loader | str | small, medium, large | 'medium' | Text, Bar, Progress |
character | ASCII value used in loader | str | . = * > ~ # @ $ + ! ? , | '.' / '=' | Text, Bar, Progress |
speed | Time between loader paints | float | .25 | Text, Spinning, Bar | |
duration | Runtime of fixed loader, in seconds | int | 10 | Text, Spinning, Bar | |
direction | Initial direction of moving loader | str | ltr, rtl | 'ltr' | Text, Bar |
animation | Continuous or oscillating movement | str | loop, bounce | 'loop' | Text, Bar |
colour | Terminal colour support required | str | blue, green, yellow, red | None | ALL |
style | Terminal styles support required | str | header, bold, underline | None | ALL |
complete_text | Text displayed after loader ends | str | 'Done!' | ALL | |
start | Progress loader start position | int | 0 | Progress | |
total | Progress loader total count | int | 100 | Progress |
不确定
可用类:spinningloader、textloader、barloader
作为线程运行,可以在任何阶段由您动态启动和停止。
- 要启动加载程序,请调用其
start()
方法。 - 完成任务后,调用加载程序的
stop()
方法终止线程。 - 如果设置了加载程序的固定duration,请调用
run()
方法以在设置的时间内运行加载程序。
螺纹
fromloadersimportTextLoaderloader=TextLoader()loader.start()# Perform some tasksloader.stop()
固定持续时间
fromloadersimportTextLoaderfixed_loader=TextLoader(duration=10)fixed_loader.run()# Pauses program execution and runs loader for 10s
输出
/ Loading... # SpinningLoader
.....Loading... # TextLoader
| ====== | # BarLoader
记住:不要试图同时启动多个加载程序!
确定
可用类:progressloader
用于测量循环或函数的完成进度。
初始化ProgressLoader
对象时,应将循环中将执行的迭代总数指定为total
参数。
在每次迭代中,调用加载程序的progress(n)
方法,其中n
是当前迭代计数,以更新终端中的进度条。
fromloadersimportProgressLoaderloader=ProgressLoader(total=10)foriinrange(10):# Perform some task each looploader.progress(i)
输出
|========== | 50%
记住:加载程序运行时,不要向控制台打印任何内容!
测试
有一个小测试套件使用pytest模块。
- 克隆存储库
- 安装pytest和依赖项
- 从项目文件夹运行pytest
git clone https://gitlab.com/ml394/pyloaders.git
cd pyloaders
pip install -r requirements.txt
pytest
示例
可以通过从项目目录运行example.py
来执行可视化示例。
这将运行一套在文件中指定的示例加载程序,每次运行5秒。默认情况下,不确定的示例在固定的持续时间上运行。要将它们作为线程运行,请使用可选的thread
参数。
# Fixed duration python example.py # Threaded python example.py thread
贡献
要参与此项目,请克隆master并创建自己的开发分支。
git clone https://gitlab.com/ml394/pyloaders.git git checkout -b <feature-name>
远程推送你的分支,并创建一个合并请求,以便我们可以审查你的代码。
如果合并请求被批准,您的新功能将被合并并推送到下一个版本。
待办事项
- [X]加载器颜色/样式
- [X]CI/CD管道
- []API文档
- []加载程序运行时打印输出
捐赠
BTC捐款(无论多小)可在钱包地址接受:
1PSWQrgbagNARvtum6pGS7rPUub4YiLmzX