Merge pull request #6 from tqdm/cleanup

cleanup
This commit is contained in:
Hadrien Mary 2015-06-08 08:32:03 +02:00
commit 0421006786
10 changed files with 102 additions and 86 deletions

4
.coveragerc Normal file
View File

@ -0,0 +1,4 @@
[run]
branch = True
omit =
tqdm/tests/*

4
.gitignore vendored
View File

@ -18,13 +18,15 @@ develop-eggs
lib
lib64
__pycache__
MANIFEST
cover/
# Installer logs
pip-log.txt
# Unit test / coverage reports
.coverage
.tox
.tox/
nosetests.xml
# Translations

View File

@ -1,16 +1,15 @@
language: python
python:
- "2.7"
- "3.4"
python: 2.7
env:
- TOXENV=py26
- TOXENV=py27
- TOXENV=py32
- TOXENV=py33
- TOXENV=py34
- TOXENV=pypy
- TOXENV=pypy3
- TOXENV=flake8
install:
- pip install nose flake8 coverage python-coveralls
- pip install .
- pip install tox
script:
- make flake8
- make coverage
after_success:
- coveralls
- tox

View File

@ -1,23 +0,0 @@
.PHONY: test flake8 coverage clean
help:
@echo "Please use make <target> where <target> is one of"
@echo " test : run tests"
@echo " flake8 : run flake8 to check PEP8"
@echo " coverage : run tests and check code coverage"
@echo " clean : clean current repository"
test:
nosetests tqdm/ -v
flake8:
flake8 --exclude "test_*" --max-line-length=100 --count --statistics --exit-zero tqdm/
coverage:
nosetests --with-coverage --cover-package=tqdm -v tqdm/
clean:
find . -name "*.so" -exec rm -rf {} \;
find . -name "*.pyc" -exec rm -rf {} \;
find . -depth -name "__pycache__" -type d -exec rm -rf '{}' \;
rm -rf build/ dist/ tqdm.egg-info/

View File

@ -5,7 +5,8 @@
[![Build Status](https://travis-ci.org/tqdm/tqdm.svg?branch=master)](https://travis-ci.org/tqdm/tqdm)
[![Coverage Status](https://coveralls.io/repos/tqdm/tqdm/badge.svg)](https://coveralls.io/r/tqdm/tqdm)
Instantly make your loops show a progress meter - just wrap any iterable with "tqdm(iterable)", and you're done !
Instantly make your loops show a progress meter - just wrap any iterable with
"tqdm(iterable)", and you're done!
tqdm (read ta<i>qa</i>dum, تقدّم) means "progress" in arabic.
@ -26,26 +27,34 @@ pip install -e git+https://github.com/tqdm/tqdm.git#egg=master
```python
def tqdm(iterable, desc='', total=None,
leave=False, file=sys.stderr,
min_interval=0.5, miniters=1):
"""Get an iterable object, and return an iterator which acts exactly like the
iterable, but prints a progress meter and updates it every time a value is
requested.
mininterval=0.5, miniters=1):
"""Get an iterable object, and return an iterator which acts exactly like
the iterable, but prints a progress meter and updates it every time a
value is requested.
Parameters
----------
desc: str
A short string, describing the progress, that is added in the beginning of the line.
total : int
The number of expected iterations. If not given, len(iterable) is used if it is defined.
file : `io.TextIOWrapper` or `io.StringIO`
A file-like object to output the progress message to.
leave : bool
If it is False, tqdm deletes its traces from screen after it has finished iterating over
all elements.
min_interval : float
If less than min_interval seconds or miniters iterations have passed since the last
progress meter update, it is not updated again.
iterable: iterable
Iterable to show progress for.
desc: str, optional
A short string, describing the progress, that is added in the beginning
of the line.
total : int, optional
The number of expected iterations. If not given, len(iterable) is used
if it is defined.
file : `io.TextIOWrapper` or `io.StringIO`, optional
A file-like object to output the progress message to. By default,
sys.stderr is used.
leave : bool, optional
If it is False (default), tqdm deletes its traces from screen after
it has finished iterating over all elements.
mininterval : float, optional
If less than mininterval seconds have passed since the last progress
meter update, it is not updated again (default: 0.5).
miniters : float, optional
If less than miniters iterations have passed since the last progress
meter update, it is not updated again (default: 1).
"""
def trange(*args, **kwargs):
@ -55,16 +64,8 @@ def trange(*args, **kwargs):
## Contributions
During development you may want to use these commands :
```sh
$ make help
Please use make <target> where <target> is one of
test : run tests
flake8 : run flake8 to check PEP8
coverage : run tests and check code coverage
clean : clean current repository
```
To run the testing suite please make sure tox (http://tox.testrun.org/)
is installed, then type `tox` from the command line.
## License

2
setup.cfg Normal file
View File

@ -0,0 +1,2 @@
[bdist_wheel]
universal = 1

4
setup.py Normal file → Executable file
View File

@ -4,13 +4,13 @@ from setuptools import setup
setup(
name='tqdm',
version='2.0',
version='1.0',
description='A Simple Python Progress Meter',
license='MIT License',
author='Noam Yorav-Raphael',
author_email='noamraph@gmail.com',
url='https://github.com/tqdm/tqdm',
py_modules=['tqdm'],
packages=['tqdm'],
classifiers=[
'Development Status :: 5 - Production/Stable',
'License :: OSI Approved :: MIT License',

22
tox.ini Normal file
View File

@ -0,0 +1,22 @@
# Tox (http://tox.testrun.org/) is a tool for running tests
# in multiple virtualenvs. This configuration file will run the
# test suite on all supported python versions. To use it, "pip install tox"
# and then run "tox" from this directory.
[tox]
envlist = py26, py27, py32, py33, py34, pypy, pypy3, flake8
[testenv]
deps =
nose
coverage
python-coveralls
commands = nosetests --with-coverage --cover-package=tqdm -v tqdm/
after_success:
- coveralls
[testenv:flake8]
basepython = python2.7
deps = flake8
commands =
flake8 --count --statistics tqdm/

View File

@ -1,4 +1,4 @@
from __future__ import division
from __future__ import division, absolute_import
import sys
import time
@ -57,25 +57,34 @@ class StatusPrinter(object):
def tqdm(iterable, desc='', total=None,
leave=False, file=sys.stderr,
min_interval=0.5, miniters=1):
"""Get an iterable object, and return an iterator which acts exactly like the
iterable, but prints a progress meter and updates it every time a value is
requested.
mininterval=0.5, miniters=1):
"""Get an iterable object, and return an iterator which acts exactly like
the iterable, but prints a progress meter and updates it every time a
value is requested.
Parameters
----------
desc: str
A short string, describing the progress, that is added in the beginning of the line.
total : int
The number of expected iterations. If not given, len(iterable) is used if it is defined.
file : `io.TextIOWrapper` or `io.StringIO`
A file-like object to output the progress message to.
leave : bool
If it is False, tqdm deletes its traces from screen after it has finished iterating over
all elements.
min_interval : float
If less than min_interval seconds or miniters iterations have passed since the last
progress meter update, it is not updated again.
iterable: iterable
Iterable to show progress for.
desc: str, optional
A short string, describing the progress, that is added in the beginning
of the line.
total : int, optional
The number of expected iterations. If not given, len(iterable) is used
if it is defined.
file : `io.TextIOWrapper` or `io.StringIO`, optional
A file-like object to output the progress message to. By default,
sys.stderr is used.
leave : bool, optional
If it is False (default), tqdm deletes its traces from screen after
it has finished iterating over all elements.
mininterval : float, optional
If less than mininterval seconds have passed since the last progress
meter update, it is not updated again (default: 0.5).
miniters : float, optional
If less than miniters iterations have passed since the last progress
meter update, it is not updated again (default: 1).
"""
if total is None:
try:
@ -98,7 +107,7 @@ def tqdm(iterable, desc='', total=None,
if n - last_print_n >= miniters:
# We check the counter first, to reduce the overhead of time.time()
cur_t = time.time()
if cur_t - last_print_t >= min_interval:
if cur_t - last_print_t >= mininterval:
sp.print_status(prefix + format_meter(n, total, cur_t-start_t))
last_print_n = n
last_print_t = cur_t

View File

@ -97,7 +97,7 @@ def test_trange():
def test_min_interval():
our_file = StringIO()
for i in tqdm(range(3), file=our_file, min_interval=1e-10):
for i in tqdm(range(3), file=our_file, mininterval=1e-10):
pass
our_file.seek(0)
assert "|----------| 0/3 0% [elapsed: 00:00 left" in our_file.read()