From 3dc5e2236a8ce45fe92df6f0c3b1f3647299cef9 Mon Sep 17 00:00:00 2001 From: Casper da Costa-Luis Date: Thu, 17 Dec 2015 20:53:39 +0000 Subject: [PATCH] minor docfixes, flake8 fixes, optimisations --- README.rst | 27 ++++++++------------------- tqdm/_tqdm.py | 2 +- tqdm/_utils.py | 7 ++----- 3 files changed, 11 insertions(+), 25 deletions(-) diff --git a/README.rst b/README.rst index 2fd6bb3a..ea1974c2 100644 --- a/README.rst +++ b/README.rst @@ -36,8 +36,8 @@ version is much more visually appealing. ``tqdm`` works on any platform (Linux/Windows/Mac), in any console or in a GUI, and is also friendly with IPython/Jupyter notebooks. -``tqdm`` does not require any library nor curses to run, just a Python -interpreter. +``tqdm`` does not require any library (not even curses!) to run, just a +vanilla Python interpreter will do. Installation @@ -187,6 +187,7 @@ Returns Experimental GUI version of trange! """ + Examples and Advanced Usage --------------------------- @@ -285,19 +286,8 @@ Nested progress bars ~~~~~~~~~~~~~~~~~~~~ ``tqdm`` supports nested progress bars, you just need to specify the -`nested=True` argument for all tqdm instanciation except the most outer bar. -Here's an example: - -.. code:: python - - from tqdm import trange - from time import sleep - - for i in trange(10, desc='1st loop', leave=True): - for j in trange(100, desc='2nd loop', leave=True, nested=True): - sleep(0.01) - -You can of course use as many nested loops as you want, get funky: +`nested=True` argument for all tqdm instanciation except the **outermost** +bar. Here's an example: .. code:: python @@ -309,10 +299,9 @@ You can of course use as many nested loops as you want, get funky: for k in trange(100, desc='3nd loop', leave=True, nested=True): sleep(0.01) -Note that on Windows, you need `colorama `__ -if you want to have a beautiful nested display. But in case you don't have -colorama, nested bars will still work without in-place replacement of parent -bars. +On Windows `colorama `__ will be used if +available to produce a beautiful nested display. + Contributions ------------- diff --git a/tqdm/_tqdm.py b/tqdm/_tqdm.py index 4eed162f..a31f5c4d 100644 --- a/tqdm/_tqdm.py +++ b/tqdm/_tqdm.py @@ -12,7 +12,7 @@ Usage: from __future__ import division, absolute_import # import compatibility functions and utilities from ._utils import _supports_unicode, _environ_cols_wrapper, _range, _unich, \ - _term_move_up + _term_move_up import sys from time import time diff --git a/tqdm/_utils.py b/tqdm/_utils.py index d3ca7f78..5f6fa5ac 100755 --- a/tqdm/_utils.py +++ b/tqdm/_utils.py @@ -113,9 +113,6 @@ def _environ_cols_linux(fp): # pragma: no cover def _term_move_up(): # pragma: no cover if os.name == 'nt': - if colorama: - return '\x1b[A' - else: + if colorama is None: return '' - else: - return '\x1b[A' + return '\x1b[A'