diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 00000000..c2b9031f --- /dev/null +++ b/.coveragerc @@ -0,0 +1,4 @@ +[run] +branch = True +omit = + tqdm/tests/* diff --git a/.gitignore b/.gitignore index 1a1f52ac..7caab158 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/.travis.yml b/.travis.yml index 3694df63..4fe7ae33 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/Makefile b/Makefile deleted file mode 100644 index a1cca4a2..00000000 --- a/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -.PHONY: test flake8 coverage clean - -help: - @echo "Please use make where 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/ diff --git a/README.md b/README.md index 997b4835..a58d3bf3 100644 --- a/README.md +++ b/README.md @@ -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 taqadum, تقدّم) 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 where 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 diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..2a9acf13 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal = 1 diff --git a/setup.py b/setup.py old mode 100644 new mode 100755 index a3f8f146..2ec8bc99 --- a/setup.py +++ b/setup.py @@ -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', diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..99216eb0 --- /dev/null +++ b/tox.ini @@ -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/ diff --git a/tqdm/_tqdm.py b/tqdm/_tqdm.py index 10fe4873..6ab13159 100644 --- a/tqdm/_tqdm.py +++ b/tqdm/_tqdm.py @@ -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 diff --git a/tqdm/tests/tests_tqdm.py b/tqdm/tests/tests_tqdm.py index 25f7aaba..fbf8f367 100644 --- a/tqdm/tests/tests_tqdm.py +++ b/tqdm/tests/tests_tqdm.py @@ -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()