易于使用的ETA计算和进度条库。

etaprogress的Python项目详细描述


在您的控制台应用程序中绘制带有颜色空间、显示速率和ETA的进度条。埃塔图书馆是自己的 类,以便它可以在其他非控制台应用程序中使用。用简单线性回归计算etas。

此库支持已定义和未定义的进度条。未定义的进度条是那些没有 “总尺寸”。类似于wget下载文件大小未知的文件。因此,未定义进度条 没有百分比,也没有预计到达时间。定义的进度条是带有百分比和ETA的常用进度条。

  • Linux和OS X支持Python 2.6、2.7、3.3和3.4。
  • 在windows上支持python 2.7、3.3和3.4(python的32位和64位版本)。

在WindowsXP和Windows10技术预览版上测试。

Build Status WindowsBuild StatusCoverage StatusLatest VersionDownloads

快速启动

安装:

pip install etaprogress

示例实现

Example Scripts Screenshot

示例的源代码:example.pyexample_colors.py, 以及example_wget.py

用法

如果您只需要一个带有eta的进度条,那么只需要在etaprogress.progress模块中导入一个类。 只需将进度条本身转换为字符串或打印实例。

简单用法

importtimefrometaprogress.progressimportProgressBartotal=5bar=ProgressBar(total,max_width=40)foriinrange(total+1):bar.numerator=iprintbartime.sleep(1)
  0% (0/5) [               ] eta --:-- -
 20% (1/5) [###            ] eta 00:05 \
 40% (2/5) [######         ] eta 00:04 |
 60% (3/5) [#########      ] eta 00:03 /
 80% (4/5) [############   ] eta 00:02 -
100% (5/5) [###############] eta 00:00 \

当然这不是一个很好的进度条动画。这里有一个更好的print_function

from__future__importprint_functionimportsysimporttimefrometaprogress.progressimportProgressBartotal=5bar=ProgressBar(total,max_width=40)foriinrange(total+1):bar.numerator=iprint(bar,end='\r')sys.stdout.flush()time.sleep(1)print()
100% (5/5) [###############] eta 00:00 \

终端颜色支持

使用colorclass支持颜色。看一看 example_colors.py关于如何实现 彩色进度条。您可能需要将progressbar类(甚至baseprogressbar)的一个子类进行子类化以添加颜色。 到进度条的每个角落。

类属性

有五个不同的进度条类具有视觉差异:

  • ProgressBar–一个简单的进度条。
  • ProgressBarBits–类似于ProgressBar,但将数字转换为位、千位等。
  • ProgressBarBytes–类似于ProgressBar,但将数字转换为字节、千字节(kibibytes)等。
  • ProgressBarWget–一个进度条,看起来像gnuwget应用程序中的进度条。
  • ProgressBarYum–一个进度条,看起来像centos/rhel 7yum实用程序中的进度条。
NameDescription/Notes
^{tt12}$Limit number of characters shown (by default the full progress bar takes up the entire terminal width).
^{tt13}$Calculate and cache the ETA string after this many numerator setting iteration. Default is every iter.
^{tt14}$For undefined progress bars this indicates that the progress has completed.
^{tt15}$‘ProgressBarYum’ only. The string to display before the progress bar. Limited to whatever space is available in the terminal.

类属性

NameDescription/Notes
^{tt16}$Returns the denominator of the progress bars. The same value provided when instantiating.
^{tt17}$Returns True if the progress has completed.
^{tt18}$Read/write. Returns the numerator as an integer or sets a new numerator. When setting a numerator it must be equal to or greater than the previous one.
^{tt19}$Returns the percent as a float.
^{tt20}$Returns the rate of the progress as a float.
^{tt21}$Return True if the progress bar is undefined.

更改日志

1.1.1

  • 修复了损坏的setup.py文件。

1.1.0

  • 添加了Windows支持。

1.0.0

  • 初次发布。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java在panelgrid中填充包含行和列的列表   Java中swing JList作为选项卡   java Zookeeper与spotify kafka图像的cprestproxy连接失败   java maven 3.0+跳过“mvn部署”上的插件执行   多线程在Java中,如何在同一网络上的服务器和客户端之间创建同步连接?   java Hibernate JPA“未找到关联类”,使用另一个实体作为键,可嵌入作为值   java在javamail api中用于会话的库   java活动生命周期回调混乱?   产生乱码输出的java if语句   java我无法从RESTAPI URL获取JSON对象   java如何在dropwizard中禁用cron作业   java公共静态工厂方法   java com。脸谱网。反应桥JavaJSExecutor$ProxyExecutor异常   Java中的安卓事件处理   java如何将p6spy与proxydatasource一起使用   使用JPQL时@Version的java行为   java不支持JDK7NIO。2在Linux上使用Epoll等?   使用Java Redis客户端(莴苣)连接到Amazon ElastiCache   在Java中将SQL Server的所有列中的一种数据类型更改为另一种数据类型   java在程序中删除抽象类的对象