本文整理汇总了Python中logilab.common.shellutils.ProgressBar.update方法的典型用法代码示例。如果您正苦于以下问题:Python ProgressBar.update方法的具体用法?Python ProgressBar.update怎么用?Python ProgressBar.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类logilab.common.shellutils.ProgressBar
的用法示例。
在下文中一共展示了ProgressBar.update方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_update_relative
# 需要导入模块: from logilab.common.shellutils import ProgressBar [as 别名]
# 或者: from logilab.common.shellutils.ProgressBar import update [as 别名]
def test_update_relative(self):
pgb_stream = StringIO()
expected_stream = StringIO()
size=20
pgb = ProgressBar(100, size, stream=pgb_stream)
last = 0
for dots in xrange(5, 105, 5):
pgb.update(5, exact=False)
dots /= 5
expected_stream.write("\r["+('.'*dots)+(' '*(size-dots))+"]")
self.assertEqual(pgb_stream.getvalue(), expected_stream.getvalue())
示例2: test_update_exact
# 需要导入模块: from logilab.common.shellutils import ProgressBar [as 别名]
# 或者: from logilab.common.shellutils.ProgressBar import update [as 别名]
def test_update_exact(self):
pgb_stream = StringIO()
expected_stream = StringIO()
size=20
pgb = ProgressBar(100, size, stream=pgb_stream)
last = 0
for dots in range(10, 105, 15):
pgb.update(dots, exact=True)
dots //= 5
expected_stream.write("\r["+('='*dots)+(' '*(size-dots))+"]")
self.assertEqual(pgb_stream.getvalue(), expected_stream.getvalue())
示例3: _update_test
# 需要导入模块: from logilab.common.shellutils import ProgressBar [as 别名]
# 或者: from logilab.common.shellutils.ProgressBar import update [as 别名]
def _update_test(self, nbops, expected, size = None):
pgb_stream = StringIO()
expected_stream = StringIO()
if size is None:
pgb = ProgressBar(nbops, stream=pgb_stream)
size=20
else:
pgb = ProgressBar(nbops, size, stream=pgb_stream)
last = 0
for round in expected:
if not hasattr(round, '__int__'):
dots, update = round
else:
dots, update = round, None
pgb.update()
if update or (update is None and dots != last):
last = dots
expected_stream.write("\r["+('.'*dots)+(' '*(size-dots))+"]")
self.assertEqual(pgb_stream.getvalue(), expected_stream.getvalue())