本文整理汇总了Python中logilab.common.shellutils.ProgressBar类的典型用法代码示例。如果您正苦于以下问题:Python ProgressBar类的具体用法?Python ProgressBar怎么用?Python ProgressBar使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ProgressBar类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_refresh_l_size
def test_refresh_l_size(self):
pgb_stream = StringIO()
expected_stream = StringIO()
pgb = ProgressBar(20, 3, stream=pgb_stream)
pgb.refresh()
expected_stream.write("\r["+' '*3+"]")
self.assertEqual(pgb_stream.getvalue(), expected_stream.getvalue())
示例2: test_refresh
def test_refresh(self):
pgb_stream = StringIO()
expected_stream = StringIO()
pgb = ProgressBar(20, stream=pgb_stream)
self.assertEqual(pgb_stream.getvalue(), expected_stream.getvalue()) # nothing print before refresh
pgb.refresh()
expected_stream.write("\r["+' '*20+"]")
self.assertEqual(pgb_stream.getvalue(), expected_stream.getvalue())
示例3: test_update_relative
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())
示例4: test_update_exact
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())
示例5: _update_test
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())