mirror of
https://github.com/kennethreitz/clint.git
synced 2026-06-05 23:00:18 +00:00
a1808173d9
Some objects you might want to show progress on while iterating over do not support calling len(). In these cases you can now pass `expected_size` in to the progress.bar and progress.mill functions to avoid the len() call on the iterable.
28 lines
648 B
Python
Executable File
28 lines
648 B
Python
Executable File
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import sys
|
|
import os
|
|
|
|
sys.path.insert(0, os.path.abspath('..'))
|
|
|
|
from time import sleep
|
|
from random import random
|
|
from clint.textui import progress
|
|
|
|
|
|
if __name__ == '__main__':
|
|
for i in progress.bar(range(100)):
|
|
sleep(random() * 0.2)
|
|
|
|
for i in progress.dots(range(100)):
|
|
sleep(random() * 0.2)
|
|
|
|
for i in progress.mill(range(100)):
|
|
sleep(random() * 0.2)
|
|
|
|
# Override the expected_size, for iterables that don't support len()
|
|
D = dict(zip(range(100), range(100)))
|
|
for k, v in progress.bar(D.iteritems(), expected_size=len(D)):
|
|
sleep(random() * 0.2)
|