From 3b5352a50eda66ca4ff951718b7a67f3e5dc9eac Mon Sep 17 00:00:00 2001 From: Mikhail Korobov Date: Mon, 8 Jun 2015 03:06:41 +0500 Subject: [PATCH 1/4] cleanup * bring tox.ini back; * switch Travis to use tox, for consistency; * enable branch coverage; * drop Makefile; * bring back setup.cfg for proper wheels; * fix modules vs packages in setup.py; * set version back to 1.0 for now; --- .coveragerc | 4 ++++ .gitignore | 4 +++- .travis.yml | 25 ++++++++++++------------- Makefile | 23 ----------------------- setup.cfg | 2 ++ setup.py | 4 ++-- tox.ini | 22 ++++++++++++++++++++++ tqdm/_tqdm.py | 2 +- 8 files changed, 46 insertions(+), 40 deletions(-) create mode 100644 .coveragerc delete mode 100644 Makefile create mode 100644 setup.cfg create mode 100644 tox.ini 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/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 index a3f8f146..2ec8bc99 100644 --- 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..7bd39c0b --- /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 --max-line-length=100 --count --statistics tqdm/ diff --git a/tqdm/_tqdm.py b/tqdm/_tqdm.py index 10fe4873..7344b7f5 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 From 98955ab13856b2e2a5d910433cad4f2c0135fc75 Mon Sep 17 00:00:00 2001 From: Mikhail Korobov Date: Mon, 8 Jun 2015 03:19:28 +0500 Subject: [PATCH 2/4] use 80 columns again Fixes GH-7 --- README.md | 22 ++++++++++++---------- tox.ini | 2 +- tqdm/_tqdm.py | 20 +++++++++++--------- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 997b4835..c583b529 100644 --- a/README.md +++ b/README.md @@ -27,25 +27,27 @@ pip install -e git+https://github.com/tqdm/tqdm.git#egg=master 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. + + """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. + 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. + 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. + 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. + If less than min_interval seconds or miniters iterations have passed + since the last progress meter update, it is not updated again. """ def trange(*args, **kwargs): diff --git a/tox.ini b/tox.ini index 7bd39c0b..99216eb0 100644 --- a/tox.ini +++ b/tox.ini @@ -19,4 +19,4 @@ after_success: basepython = python2.7 deps = flake8 commands = - flake8 --max-line-length=100 --count --statistics tqdm/ + flake8 --count --statistics tqdm/ diff --git a/tqdm/_tqdm.py b/tqdm/_tqdm.py index 7344b7f5..6e11191a 100644 --- a/tqdm/_tqdm.py +++ b/tqdm/_tqdm.py @@ -58,24 +58,26 @@ 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. + """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. + 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. + 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. + 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. + If less than min_interval seconds or miniters iterations have passed + since the last progress meter update, it is not updated again. """ if total is None: try: From 71c46107315a90cec85b6018b68115dd2d3eb735 Mon Sep 17 00:00:00 2001 From: Mikhail Korobov Date: Mon, 8 Jun 2015 03:27:22 +0500 Subject: [PATCH 3/4] Rename min_interval back to mininterval; add defaults to docstring; document miniters and iterable parameters. --- README.md | 30 ++++++++++++++++++------------ tqdm/_tqdm.py | 31 +++++++++++++++++++------------ tqdm/tests/tests_tqdm.py | 2 +- 3 files changed, 38 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index c583b529..688efb2c 100644 --- a/README.md +++ b/README.md @@ -26,28 +26,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): - + 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 + 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 + 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` - 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. + 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): diff --git a/tqdm/_tqdm.py b/tqdm/_tqdm.py index 6e11191a..6ab13159 100644 --- a/tqdm/_tqdm.py +++ b/tqdm/_tqdm.py @@ -57,27 +57,34 @@ class StatusPrinter(object): def tqdm(iterable, desc='', total=None, leave=False, file=sys.stderr, - min_interval=0.5, miniters=1): + 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 + 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 + 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` - 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. + 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: @@ -100,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() From 3ae3bc42195c844c3052ce620e801d18a8064cc9 Mon Sep 17 00:00:00 2001 From: Mikhail Korobov Date: Mon, 8 Jun 2015 03:33:43 +0500 Subject: [PATCH 4/4] update contributing docs; remove a whitespace before !; add executable flag to setup.py --- README.md | 15 ++++----------- setup.py | 0 2 files changed, 4 insertions(+), 11 deletions(-) mode change 100644 => 100755 setup.py diff --git a/README.md b/README.md index 688efb2c..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. @@ -63,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.py b/setup.py old mode 100644 new mode 100755