2021-12-01 20:47:00 +00:00
|
|
|
"""
|
|
|
|
Automatically choose between `tqdm.notebook` and `tqdm.std`.
|
|
|
|
|
|
|
|
Usage:
|
|
|
|
>>> from tqdm.autonotebook import trange, tqdm
|
|
|
|
>>> for i in trange(10):
|
|
|
|
... ...
|
|
|
|
"""
|
2020-06-10 16:04:54 +00:00
|
|
|
import os
|
2021-12-01 20:47:00 +00:00
|
|
|
import sys
|
2020-06-10 16:04:54 +00:00
|
|
|
|
|
|
|
try:
|
2021-12-01 20:47:00 +00:00
|
|
|
get_ipython = sys.modules['IPython'].get_ipython
|
2020-06-10 16:04:54 +00:00
|
|
|
if 'IPKernelApp' not in get_ipython().config: # pragma: no cover
|
|
|
|
raise ImportError("console")
|
|
|
|
if 'VSCODE_PID' in os.environ: # pragma: no cover
|
|
|
|
raise ImportError("vscode")
|
2021-12-01 20:47:00 +00:00
|
|
|
except Exception:
|
2020-06-10 16:04:54 +00:00
|
|
|
from .std import tqdm, trange
|
|
|
|
else: # pragma: no cover
|
2021-12-01 20:47:00 +00:00
|
|
|
from warnings import warn
|
|
|
|
|
2020-06-10 16:04:54 +00:00
|
|
|
from .notebook import tqdm, trange
|
|
|
|
from .std import TqdmExperimentalWarning
|
|
|
|
warn("Using `tqdm.autonotebook.tqdm` in notebook mode."
|
|
|
|
" Use `tqdm.tqdm` instead to force console mode"
|
|
|
|
" (e.g. in jupyter console)", TqdmExperimentalWarning, stacklevel=2)
|
|
|
|
__all__ = ["tqdm", "trange"]
|