repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
python-prompt-toolkit
src/prompt_toolkit/key_binding/bindings/search.py
.py
""" Search related key bindings. """ from __future__ import annotations from prompt_toolkit import search from prompt_toolkit.application.current import get_app from prompt_toolkit.filters import Condition, control_is_searchable, is_searching from prompt_toolkit.key_binding.key_processor import KeyPressEvent from .....
97
2,632
python-prompt-toolkit
src/prompt_toolkit/key_binding/bindings/basic.py
.py
# pylint: disable=function-redefined from __future__ import annotations from prompt_toolkit.application.current import get_app from prompt_toolkit.filters import ( Condition, emacs_insert_mode, has_selection, in_paste_mode, is_multiline, vi_insert_mode, ) from prompt_toolkit.key_binding.key_pro...
258
7,229
python-prompt-toolkit
src/prompt_toolkit/key_binding/bindings/focus.py
.py
from __future__ import annotations from prompt_toolkit.key_binding.key_processor import KeyPressEvent __all__ = [ "focus_next", "focus_previous", ] E = KeyPressEvent def focus_next(event: E) -> None: """ Focus the next visible Window. (Often bound to the `Tab` key.) """ event.app.layout...
27
507
python-prompt-toolkit
src/prompt_toolkit/key_binding/bindings/vi.py
.py
# pylint: disable=function-redefined from __future__ import annotations import codecs import string from collections.abc import Callable, Iterable from enum import Enum from itertools import accumulate from typing import TypeVar from prompt_toolkit.application.current import get_app from prompt_toolkit.buffer import ...
2,235
75,622
python-prompt-toolkit
src/prompt_toolkit/key_binding/bindings/emacs.py
.py
# pylint: disable=function-redefined from __future__ import annotations from prompt_toolkit.application.current import get_app from prompt_toolkit.buffer import Buffer, indent, unindent from prompt_toolkit.completion import CompleteEvent from prompt_toolkit.filters import ( Condition, emacs_insert_mode, em...
564
19,634
python-prompt-toolkit
src/prompt_toolkit/key_binding/bindings/cpr.py
.py
from __future__ import annotations from prompt_toolkit.key_binding.key_processor import KeyPressEvent from prompt_toolkit.keys import Keys from ..key_bindings import KeyBindings __all__ = [ "load_cpr_bindings", ] E = KeyPressEvent def load_cpr_bindings() -> KeyBindings: key_bindings = KeyBindings() @...
31
786
python-prompt-toolkit
src/prompt_toolkit/styles/pygments.py
.py
""" Adaptor for building prompt_toolkit styles, starting from a Pygments style. Usage:: from pygments.styles.tango import TangoStyle style = style_from_pygments_cls(pygments_style_cls=TangoStyle) """ from __future__ import annotations from typing import TYPE_CHECKING from .style import Style if TYPE_CHECK...
71
1,974
python-prompt-toolkit
src/prompt_toolkit/styles/named_colors.py
.py
""" All modern web browsers support these 140 color names. Taken from: https://www.w3schools.com/colors/colors_names.asp """ from __future__ import annotations __all__ = [ "NAMED_COLORS", ] NAMED_COLORS: dict[str, str] = { "AliceBlue": "#f0f8ff", "AntiqueWhite": "#faebd7", "Aqua": "#00ffff", "Aq...
163
4,367
python-prompt-toolkit
src/prompt_toolkit/styles/style_transformation.py
.py
""" Collection of style transformations. Think of it as a kind of color post processing after the rendering is done. This could be used for instance to change the contrast/saturation; swap light and dark colors or even change certain colors for other colors. When the UI is rendered, these transformations can be appli...
375
12,436
python-prompt-toolkit
src/prompt_toolkit/styles/__init__.py
.py
""" Styling for prompt_toolkit applications. """ from __future__ import annotations from .base import ( ANSI_COLOR_NAMES, DEFAULT_ATTRS, Attrs, BaseStyle, DummyStyle, DynamicStyle, ) from .defaults import default_pygments_style, default_ui_style from .named_colors import NAMED_COLORS from .pyg...
68
1,640
python-prompt-toolkit
src/prompt_toolkit/styles/style.py
.py
""" Tool for creating styles from a dictionary. """ from __future__ import annotations import itertools import re from collections.abc import Hashable from enum import Enum from typing import TypeVar from prompt_toolkit.cache import SimpleCache from .base import ( ANSI_COLOR_NAMES, ANSI_COLOR_NAMES_ALIASES,...
409
13,290
python-prompt-toolkit
src/prompt_toolkit/styles/defaults.py
.py
""" The default styling. """ from __future__ import annotations from prompt_toolkit.cache import memoized from .base import ANSI_COLOR_NAMES, BaseStyle from .named_colors import NAMED_COLORS from .style import Style, merge_styles __all__ = [ "default_ui_style", "default_pygments_style", ] #: Default stylin...
237
8,699
python-prompt-toolkit
src/prompt_toolkit/styles/base.py
.py
""" The base classes for the styling. """ from __future__ import annotations from abc import ABCMeta, abstractmethod from collections.abc import Callable, Hashable from typing import NamedTuple __all__ = [ "Attrs", "DEFAULT_ATTRS", "ANSI_COLOR_NAMES", "ANSI_COLOR_NAMES_ALIASES", "BaseStyle", ...
190
5,091
python-prompt-toolkit
src/prompt_toolkit/contrib/ssh/server.py
.py
""" Utility for running a prompt_toolkit application in an asyncssh server. """ from __future__ import annotations import asyncio import traceback from asyncio import get_running_loop from collections.abc import Callable, Coroutine from typing import Any, TextIO, cast import asyncssh from prompt_toolkit.application...
180
6,157
python-prompt-toolkit
src/prompt_toolkit/contrib/ssh/__init__.py
.py
from __future__ import annotations from .server import PromptToolkitSSHServer, PromptToolkitSSHSession __all__ = [ "PromptToolkitSSHSession", "PromptToolkitSSHServer", ]
9
180
python-prompt-toolkit
src/prompt_toolkit/contrib/completers/__init__.py
.py
from __future__ import annotations from .system import SystemCompleter __all__ = ["SystemCompleter"]
6
103
python-prompt-toolkit
src/prompt_toolkit/contrib/completers/system.py
.py
from __future__ import annotations from prompt_toolkit.completion.filesystem import ExecutableCompleter, PathCompleter from prompt_toolkit.contrib.regular_languages.compiler import compile from prompt_toolkit.contrib.regular_languages.completion import GrammarCompleter __all__ = [ "SystemCompleter", ] class Sys...
65
2,057
python-prompt-toolkit
src/prompt_toolkit/contrib/regular_languages/regex_parser.py
.py
""" Parser for parsing a regular expression. Take a string representing a regular expression and return the root node of its parse tree. usage:: root_node = parse_regex('(hello|world)') Remarks: - The regex parser processes multiline, it ignores all whitespace and supports multiple named groups with the same n...
280
7,732
python-prompt-toolkit
src/prompt_toolkit/contrib/regular_languages/completion.py
.py
""" Completer for a regular grammar. """ from __future__ import annotations from collections.abc import Iterable from prompt_toolkit.completion import CompleteEvent, Completer, Completion from prompt_toolkit.document import Document from .compiler import Match, _CompiledGrammar __all__ = [ "GrammarCompleter", ...
101
3,477
python-prompt-toolkit
src/prompt_toolkit/contrib/regular_languages/lexer.py
.py
""" `GrammarLexer` is compatible with other lexers and can be used to highlight the input using a regular grammar with annotations. """ from __future__ import annotations from collections.abc import Callable from prompt_toolkit.document import Document from prompt_toolkit.formatted_text.base import StyleAndTextTuple...
95
3,424
python-prompt-toolkit
src/prompt_toolkit/contrib/regular_languages/__init__.py
.py
r""" Tool for expressing the grammar of an input as a regular language. ================================================================== The grammar for the input of many simple command line interfaces can be expressed by a regular language. Examples are PDB (the Python debugger); a simple (bash-like) shell with "pw...
81
3,279
python-prompt-toolkit
src/prompt_toolkit/contrib/regular_languages/compiler.py
.py
r""" Compiler for a regular grammar. Example usage:: # Create and compile grammar. p = compile('add \s+ (?P<var1>[^\s]+) \s+ (?P<var2>[^\s]+)') # Match input string. m = p.match('add 23 432') # Get variables. m.variables().get('var1') # Returns "23" m.variables().get('var2') # Return...
582
21,979
python-prompt-toolkit
src/prompt_toolkit/contrib/regular_languages/validation.py
.py
""" Validator for a regular language. """ from __future__ import annotations from prompt_toolkit.document import Document from prompt_toolkit.validation import ValidationError, Validator from .compiler import _CompiledGrammar __all__ = [ "GrammarValidator", ] class GrammarValidator(Validator): """ Val...
61
2,059
python-prompt-toolkit
src/prompt_toolkit/contrib/telnet/server.py
.py
""" Telnet server. """ from __future__ import annotations import asyncio import contextvars import socket from asyncio import get_running_loop from collections.abc import Callable, Coroutine from typing import Any, TextIO, cast from prompt_toolkit.application.current import create_app_session, get_app from prompt_to...
430
13,488
python-prompt-toolkit
src/prompt_toolkit/contrib/telnet/__init__.py
.py
from __future__ import annotations from .server import TelnetServer __all__ = [ "TelnetServer", ]
8
104
python-prompt-toolkit
src/prompt_toolkit/contrib/telnet/protocol.py
.py
""" Parser for the Telnet protocol. (Not a complete implementation of the telnet specification, but sufficient for a command line interface.) Inspired by `Twisted.conch.telnet`. """ from __future__ import annotations import struct from collections.abc import Callable, Generator from .log import logger __all__ = [ ...
210
5,611
python-prompt-toolkit
src/prompt_toolkit/contrib/telnet/log.py
.py
""" Python logger for the telnet server. """ from __future__ import annotations import logging logger = logging.getLogger(__package__) __all__ = [ "logger", ]
14
167
python-prompt-toolkit
src/prompt_toolkit/layout/layout.py
.py
""" Wrapper for the layout. """ from __future__ import annotations from collections.abc import Generator, Iterable from prompt_toolkit.buffer import Buffer from .containers import ( AnyContainer, ConditionalContainer, Container, Window, to_container, ) from .controls import BufferControl, Search...
413
13,958
python-prompt-toolkit
src/prompt_toolkit/layout/menus.py
.py
from __future__ import annotations import math from collections.abc import Callable, Iterable, Sequence from itertools import zip_longest from typing import TYPE_CHECKING, TypeVar, cast from weakref import WeakKeyDictionary from prompt_toolkit.application.current import get_app from prompt_toolkit.buffer import Compl...
750
27,222
python-prompt-toolkit
src/prompt_toolkit/layout/utils.py
.py
from __future__ import annotations from collections.abc import Iterable from typing import TYPE_CHECKING, TypeVar, cast, overload from prompt_toolkit.formatted_text.base import OneStyleAndTextTuple if TYPE_CHECKING: from typing_extensions import SupportsIndex __all__ = [ "explode_text_fragments", ] _T = Ty...
82
2,392
python-prompt-toolkit
src/prompt_toolkit/layout/mouse_handlers.py
.py
from __future__ import annotations from collections import defaultdict from collections.abc import Callable from typing import TYPE_CHECKING from prompt_toolkit.mouse_events import MouseEvent if TYPE_CHECKING: from prompt_toolkit.key_binding.key_bindings import NotImplementedOrNone __all__ = [ "MouseHandler...
58
1,616
python-prompt-toolkit
src/prompt_toolkit/layout/screen.py
.py
from __future__ import annotations from collections import defaultdict from collections.abc import Callable from typing import TYPE_CHECKING from prompt_toolkit.cache import FastDictCache from prompt_toolkit.data_structures import Point from prompt_toolkit.utils import get_cwidth if TYPE_CHECKING: from .containe...
325
10,140
python-prompt-toolkit
src/prompt_toolkit/layout/scrollable_pane.py
.py
from __future__ import annotations from prompt_toolkit.data_structures import Point from prompt_toolkit.filters import FilterOrBool, to_filter from prompt_toolkit.key_binding import KeyBindingsBase from prompt_toolkit.mouse_events import MouseEvent from .containers import Container, ScrollOffsets from .dimension impo...
495
19,264
python-prompt-toolkit
src/prompt_toolkit/layout/containers.py
.py
""" Container for the layout. (Containers can contain other containers or user interface controls.) """ from __future__ import annotations from abc import ABCMeta, abstractmethod from collections.abc import Callable, Sequence from enum import Enum from functools import partial from typing import TYPE_CHECKING, Union,...
2,768
100,195
python-prompt-toolkit
src/prompt_toolkit/layout/__init__.py
.py
""" Command line layout definitions ------------------------------- The layout of a command line interface is defined by a Container instance. There are two main groups of classes here. Containers and controls: - A container can contain other containers or controls, it can have multiple children and it decides abou...
148
3,603
python-prompt-toolkit
src/prompt_toolkit/layout/dummy.py
.py
""" Dummy layout. Used when somebody creates an `Application` without specifying a `Layout`. """ from __future__ import annotations from prompt_toolkit.formatted_text import HTML from prompt_toolkit.key_binding import KeyBindings from prompt_toolkit.key_binding.key_processor import KeyPressEvent from .containers imp...
41
1,047
python-prompt-toolkit
src/prompt_toolkit/layout/processors.py
.py
""" Processors are little transformation blocks that transform the fragments list from a buffer before the BufferControl will render it to the screen. They can insert fragments before or after, or highlight fragments by replacing the fragment types. """ from __future__ import annotations import re from abc import AB...
1,018
34,323
python-prompt-toolkit
src/prompt_toolkit/layout/controls.py
.py
""" User interface Controls for the layout. """ from __future__ import annotations import time from abc import ABCMeta, abstractmethod from collections.abc import Callable, Hashable, Iterable from typing import TYPE_CHECKING, NamedTuple from prompt_toolkit.application.current import get_app from prompt_toolkit.buffe...
958
36,020
python-prompt-toolkit
src/prompt_toolkit/layout/margins.py
.py
""" Margin implementations for a :class:`~prompt_toolkit.layout.containers.Window`. """ from __future__ import annotations from abc import ABCMeta, abstractmethod from collections.abc import Callable from typing import TYPE_CHECKING from prompt_toolkit.filters import FilterOrBool, to_filter from prompt_toolkit.forma...
306
10,402
python-prompt-toolkit
src/prompt_toolkit/layout/dimension.py
.py
""" Layout dimensions are used to give the minimum, maximum and preferred dimensions for containers and controls. """ from __future__ import annotations from collections.abc import Callable from typing import TYPE_CHECKING __all__ = [ "Dimension", "D", "sum_layout_dimensions", "max_layout_dimensions"...
212
6,804
python-prompt-toolkit
src/prompt_toolkit/filters/app.py
.py
""" Filters that accept a `Application` as argument. """ from __future__ import annotations from typing import TYPE_CHECKING from prompt_toolkit.application.current import get_app from prompt_toolkit.cache import memoized from prompt_toolkit.enums import EditingMode from .base import Condition if TYPE_CHECKING: ...
420
10,374
python-prompt-toolkit
src/prompt_toolkit/filters/utils.py
.py
from __future__ import annotations from .base import Always, Filter, FilterOrBool, Never __all__ = [ "to_filter", "is_true", ] _always = Always() _never = Never() _bool_to_filter: dict[bool, Filter] = { True: _always, False: _never, } def to_filter(bool_or_filter: FilterOrBool) -> Filter: ""...
42
859
python-prompt-toolkit
src/prompt_toolkit/filters/__init__.py
.py
""" Filters decide whether something is active or not (they decide about a boolean state). This is used to enable/disable features, like key bindings, parts of the layout and other stuff. For instance, we could have a `HasSearch` filter attached to some part of the layout, in order to show that part of the user interfa...
72
1,990
python-prompt-toolkit
src/prompt_toolkit/filters/cli.py
.py
""" For backwards-compatibility. keep this file. (Many people are going to have key bindings that rely on this file.) """ from __future__ import annotations from .app import * __all__ = [ # Old names. "HasArg", "HasCompletions", "HasFocus", "HasSelection", "HasValidationError", "IsDone", ...
66
1,867
python-prompt-toolkit
src/prompt_toolkit/filters/base.py
.py
from __future__ import annotations from abc import ABCMeta, abstractmethod from collections.abc import Callable, Iterable __all__ = ["Filter", "Never", "Always", "Condition", "FilterOrBool"] class Filter(metaclass=ABCMeta): """ Base class for any filter to activate/deactivate a feature, depending on a c...
261
6,851
python-prompt-toolkit
src/prompt_toolkit/formatted_text/utils.py
.py
""" Utilities for manipulating formatted text. When ``to_formatted_text`` has been called, we get a list of ``(style, text)`` tuples. This file contains functions for manipulating such a list. """ from __future__ import annotations from collections.abc import Iterable from typing import cast from prompt_toolkit.uti...
104
3,071
python-prompt-toolkit
src/prompt_toolkit/formatted_text/pygments.py
.py
from __future__ import annotations from typing import TYPE_CHECKING from prompt_toolkit.styles.pygments import pygments_token_to_classname from .base import StyleAndTextTuples if TYPE_CHECKING: from pygments.token import Token __all__ = [ "PygmentsTokens", ] class PygmentsTokens: """ Turn a pygme...
33
780
python-prompt-toolkit
src/prompt_toolkit/formatted_text/__init__.py
.py
""" Many places in prompt_toolkit can take either plain text, or formatted text. For instance the :func:`~prompt_toolkit.shortcuts.prompt` function takes either plain text or formatted text for the prompt. The :class:`~prompt_toolkit.layout.FormattedTextControl` can also take either plain text or formatted text. In an...
60
1,509
python-prompt-toolkit
src/prompt_toolkit/formatted_text/ansi.py
.py
from __future__ import annotations from collections.abc import Generator from string import Formatter from prompt_toolkit.output.vt100 import BG_ANSI_COLORS, FG_ANSI_COLORS from prompt_toolkit.output.vt100 import _256_colors as _256_colors_table from .base import StyleAndTextTuples __all__ = [ "ANSI", "ansi...
303
9,833
python-prompt-toolkit
src/prompt_toolkit/formatted_text/html.py
.py
from __future__ import annotations import xml.dom.minidom as minidom from string import Formatter from typing import Any from .base import FormattedText, StyleAndTextTuples __all__ = ["HTML"] class HTML: """ HTML formatted text. Take something HTML-like, for use as a formatted string. :: ...
146
4,374
python-prompt-toolkit
src/prompt_toolkit/formatted_text/base.py
.py
from __future__ import annotations from collections.abc import Callable, Iterable from typing import TYPE_CHECKING, Union, cast from prompt_toolkit.mouse_events import MouseEvent if TYPE_CHECKING: from typing_extensions import Protocol from prompt_toolkit.key_binding.key_bindings import NotImplementedOrNone...
180
5,071
tqdm
tqdm/_monitor.py
.py
import atexit from threading import Event, Thread, current_thread from time import time from warnings import warn __all__ = ["TMonitor", "TqdmSynchronisationWarning"] class TqdmSynchronisationWarning(RuntimeWarning): """ tqdm multi-thread/-process errors which may cause incorrect nesting but otherwise no...
105
4,013
tqdm
tqdm/gui.py
.py
""" Matplotlib GUI progress bar decorator for iterators. Usage: >>> from tqdm.gui import trange, tqdm >>> for i in trange(10): ... ... """ # future division is important to divide integers and get as # a result precise floating numbers (instead of truncated int) import re from warnings import warn # to inherit fr...
180
5,481
tqdm
tqdm/_utils.py
.py
from warnings import warn from .std import TqdmDeprecationWarning from .utils import ( # noqa: F401, pylint: disable=unused-import CUR_OS, IS_NIX, IS_WIN, RE_ANSI, Comparable, FormatReplace, SimpleTextIOWrapper, _environ_cols_wrapper, _is_ascii, _is_utf, _screen_shape_linux, _screen_shape_tput, _screen_sh...
12
559
tqdm
tqdm/_tqdm_gui.py
.py
from warnings import warn from .gui import * # NOQA from .gui import __all__ # NOQA from .std import TqdmDeprecationWarning warn("This function will be removed in tqdm==5.0.0\n" "Please use `tqdm.gui.*` instead of `tqdm._tqdm_gui.*`", TqdmDeprecationWarning, stacklevel=2)
10
287
tqdm
tqdm/asyncio.py
.py
""" Asynchronous progress bar decorator for iterators. Includes a default `range` iterator printing to `stderr`. Usage: >>> from tqdm.asyncio import trange, tqdm >>> async for i in trange(10): ... ... """ import asyncio from sys import version_info from .std import tqdm as std_tqdm __author__ = {"github.com/": [...
104
3,196
tqdm
tqdm/utils.py
.py
""" General helpers required for `tqdm.std`. """ import os import re import sys from functools import partial, partialmethod, wraps from inspect import signature # TODO consider using wcswidth third-party package for 0-width characters from unicodedata import east_asian_width from warnings import warn from weakref impo...
329
9,746
tqdm
tqdm/autonotebook.py
.py
""" Automatically choose between `tqdm.notebook` and `tqdm.std`. Usage: >>> from tqdm.autonotebook import trange, tqdm >>> for i in trange(10): ... ... """ import os import sys from warnings import warn try: if 'ipykernel.zmqshell' in sys.modules: if any(i == 'QT_API' or i.startswith('SPYDER') for i i...
39
1,440
tqdm
tqdm/_tqdm_pandas.py
.py
import sys __author__ = "github.com/casperdcl" __all__ = ['tqdm_pandas'] def tqdm_pandas(tclass, **tqdm_kwargs): """ Registers the given `tqdm` instance with `pandas.core.groupby.DataFrameGroupBy.progress_apply`. """ from tqdm import TqdmDeprecationWarning if isinstance(tclass, type) or (get...
25
888
tqdm
tqdm/rich.py
.py
""" `rich.progress` decorator for iterators. Usage: >>> from tqdm.rich import trange, tqdm >>> for i in trange(10): ... ... """ from warnings import warn from rich.progress import ( BarColumn, Progress, ProgressColumn, Text, TimeElapsedColumn, TimeRemainingColumn, filesize) from .std import TqdmExperimentalW...
155
5,255
tqdm
tqdm/__main__.py
.py
from .cli import main main()
4
30
tqdm
tqdm/__init__.py
.py
from ._monitor import TMonitor, TqdmSynchronisationWarning from ._tqdm_pandas import tqdm_pandas from .cli import main # TODO: remove in v5.0.0 from .gui import tqdm as tqdm_gui # TODO: remove in v5.0.0 from .gui import trange as tgrange # TODO: remove in v5.0.0 from .std import ( TqdmDeprecationWarning, TqdmExp...
39
1,572
tqdm
tqdm/version.py
.py
"""`tqdm` version detector. Precedence: installed dist, git, 'UNKNOWN'.""" from importlib.metadata import PackageNotFoundError, version try: __version__ = version('tqdm') except PackageNotFoundError: __version__ = "UNKNOWN"
8
233
tqdm
tqdm/_tqdm.py
.py
from warnings import warn from .std import * # NOQA from .std import __all__ # NOQA from .std import TqdmDeprecationWarning warn("This function will be removed in tqdm==5.0.0\n" "Please use `tqdm.std.*` instead of `tqdm._tqdm.*`", TqdmDeprecationWarning, stacklevel=2)
10
283
tqdm
tqdm/_main.py
.py
from warnings import warn from .cli import * # NOQA from .cli import __all__ # NOQA from .std import TqdmDeprecationWarning warn("This function will be removed in tqdm==5.0.0\n" "Please use `tqdm.cli.*` instead of `tqdm._main.*`", TqdmDeprecationWarning, stacklevel=2)
10
283
tqdm
tqdm/dask.py
.py
from functools import partial from dask.callbacks import Callback from .auto import tqdm as tqdm_auto __author__ = {"github.com/": ["casperdcl"]} __all__ = ['TqdmCallback'] class TqdmCallback(Callback): """Dask callback for task progress.""" def __init__(self, start=None, pretask=None, tqdm_class=tqdm_auto...
45
1,319
tqdm
tqdm/notebook.py
.py
""" IPython/Jupyter Notebook progress bar decorator for iterators. Includes a default `range` iterator printing to `stderr`. Usage: >>> from tqdm.notebook import trange, tqdm >>> for i in trange(10): ... ... """ # import compatibility functions and utilities import re import sys from html import escape from weakre...
318
10,888
tqdm
tqdm/keras.py
.py
from copy import copy from functools import partial from .auto import tqdm as tqdm_auto try: import keras except (ImportError, AttributeError) as e: try: from tensorflow import keras except ImportError: raise e __author__ = {"github.com/": ["casperdcl"]} __all__ = ['TqdmCallback'] class ...
124
4,396
tqdm
tqdm/std.py
.py
""" Customisable progress bar decorator for iterators. Includes a default `range` iterator printing to `stderr`. Usage: >>> from tqdm import trange, tqdm >>> for i in trange(10): ... ... """ import sys from collections import OrderedDict, defaultdict from contextlib import contextmanager from datetime import datet...
1,534
58,074
tqdm
tqdm/tk.py
.py
""" Tkinter GUI progress bar decorator for iterators. Usage: >>> from tqdm.tk import trange, tqdm >>> for i in trange(10): ... ... """ import re import sys import tkinter import tkinter.ttk as ttk from warnings import warn from .std import TqdmExperimentalWarning, TqdmWarning from .std import tqdm as std_tqdm __...
197
6,702
tqdm
tqdm/cli.py
.py
""" Module version for monitoring CLI pipes (`... | python -m tqdm | ...`). """ import logging import re import sys from ast import literal_eval from textwrap import indent from .std import TqdmKeyError, TqdmTypeError, tqdm from .version import __version__ __all__ = ["main"] log = logging.getLogger(__name__) def ca...
325
11,011
tqdm
tqdm/auto.py
.py
""" Enables multiple commonly used features. Method resolution order: - `tqdm.autonotebook` without import warnings - `tqdm.asyncio` - `tqdm.std` base class Usage: >>> from tqdm.auto import trange, tqdm >>> for i in trange(10): ... ... """ import warnings from .std import TqdmExperimentalWarning with warnings....
41
871
tqdm
tqdm/_tqdm_notebook.py
.py
from warnings import warn from .notebook import * # NOQA from .notebook import __all__ # NOQA from .std import TqdmDeprecationWarning warn("This function will be removed in tqdm==5.0.0\n" "Please use `tqdm.notebook.*` instead of `tqdm._tqdm_notebook.*`", TqdmDeprecationWarning, stacklevel=2)
10
307
tqdm
tqdm/contrib/itertools.py
.py
""" Thin wrappers around `itertools`. """ import itertools import math from ..auto import tqdm as tqdm_auto __author__ = {"github.com/": ["casperdcl"]} __all__ = [ 'chain', 'product', 'permutations', 'combinations', 'combinations_with_replacement', 'batched'] def chain(*iterables, total=None, tqdm_class=tqdm_au...
93
2,949
tqdm
tqdm/contrib/logging.py
.py
""" Helper functionality for interoperability with stdlib `logging`. """ import logging import sys from contextlib import contextmanager try: from typing import Iterator, List, Optional, Type # noqa: F401, pylint: disable=unused-import except ImportError: pass from ..std import tqdm as std_tqdm class _Tqdm...
129
3,902
tqdm
tqdm/contrib/slack.py
.py
""" Sends updates to a Slack app. Usage: >>> from tqdm.contrib.slack import tqdm, trange >>> for i in trange(10, token='{token}', channel='{channel}'): ... ... ![screenshot](https://tqdm.github.io/img/screenshot-slack.png) """ import logging try: from slack_sdk import WebClient except ImportError: raise ...
120
4,049
tqdm
tqdm/contrib/__init__.py
.py
""" Thin wrappers around common functions. Subpackages contain potentially unstable extensions. """ from warnings import warn from ..auto import tqdm as tqdm_auto from ..std import TqdmDeprecationWarning, tqdm from ..utils import ObjectWrapper __author__ = {"github.com/": ["casperdcl"]} __all__ = ['tenumerate', 'tzi...
92
2,479
tqdm
tqdm/contrib/bells.py
.py
""" Even more features than `tqdm.auto` (all the bells & whistles): - `tqdm.auto` - `tqdm.tqdm.pandas` - `tqdm.contrib.slack` + uses `${TQDM_SLACK_TOKEN}` and `${TQDM_SLACK_CHANNEL}` - `tqdm.contrib.telegram` + uses `${TQDM_TELEGRAM_TOKEN}` and `${TQDM_TELEGRAM_CHAT_ID}` - `tqdm.contrib.discord` + uses `${...
29
921
tqdm
tqdm/contrib/concurrent.py
.py
""" Thin wrappers around `concurrent.futures`. """ import sys from contextlib import contextmanager from operator import length_hint from ..auto import tqdm as tqdm_auto from ..std import TqdmWarning __author__ = {"github.com/": ["casperdcl"]} __all__ = ['thread_map', 'process_map', 'interpreter_map'] class _Interp...
260
9,849
tqdm
tqdm/contrib/telegram.py
.py
""" Sends updates to a Telegram bot. Usage: >>> from tqdm.contrib.telegram import tqdm, trange >>> for i in trange(10, token='{token}', chat_id='{chat_id}'): ... ... ![screenshot](https://tqdm.github.io/img/screenshot-telegram.gif) """ from warnings import warn from requests import Session from ..auto import tq...
153
5,081
tqdm
tqdm/contrib/utils_worker.py
.py
""" IO/concurrency helpers for `tqdm.contrib`. """ from collections import deque from concurrent.futures import ThreadPoolExecutor from ..auto import tqdm as tqdm_auto __author__ = {"github.com/": ["casperdcl"]} __all__ = ['MonoWorker'] class MonoWorker: """ Supports one running task and one waiting task. ...
39
1,199
tqdm
tqdm/contrib/discord.py
.py
""" Sends updates to a Discord bot. Usage: >>> from tqdm.contrib.discord import tqdm, trange >>> for i in trange(10, token='{token}', channel_id='{channel_id}'): ... ... ![screenshot](https://tqdm.github.io/img/screenshot-discord.png) """ from warnings import warn from requests import Session from requests.utils...
156
5,337
tqdm
benchmarks/benchmarks.py
.py
# Write the benchmarking functions here. # See "Writing benchmarks" in the asv docs for more information. from functools import partial class Comparison: """Running time of wrapped empty loops""" def __init__(self, length): try: from time import process_time self.time = process...
90
2,380
tqdm
tests/tests_contrib_logging.py
.py
# pylint: disable=missing-module-docstring, missing-class-docstring # pylint: disable=missing-function-docstring, no-self-use import logging import logging.handlers import sys from io import StringIO import pytest from tqdm import tqdm from tqdm.contrib.logging import _get_first_found_console_logging_handler from tqd...
187
7,449
tqdm
tests/tests_tk.py
.py
"""Test `tqdm.tk`.""" from .tests_tqdm import importorskip def test_tk_import(): """Test `tqdm.tk` import""" importorskip('tqdm.tk')
8
143
tqdm
tests/tests_pandas.py
.py
from tqdm import tqdm from .tests_tqdm import StringIO, closing, importorskip, mark, skip pytestmark = mark.slow np = importorskip('numpy') random = importorskip('numpy.random') rand = random.rand randint = random.randint pd = importorskip('pandas') def test_pandas_setup(): """Test tqdm.pandas()""" with cl...
224
8,263
tqdm
tests/tests_itertools.py
.py
""" Tests for `tqdm.contrib.itertools`. """ import itertools as it import pytest from tqdm.contrib import itertools as tit def no_len(iterable): yield from iterable def test_chain(capsys): """Test contrib.itertools.chain""" a = range(9) assert list(tit.chain(a, a)) == list(it.chain(a, a)) asse...
118
3,877
tqdm
tests/tests_asyncio.py
.py
"""Tests `tqdm.asyncio`.""" import asyncio from functools import partial from sys import platform from time import time from tqdm.asyncio import tarange, tqdm_asyncio from .tests_tqdm import StringIO, closing, mark tqdm = partial(tqdm_asyncio, miniters=0, mininterval=0) trange = partial(tarange, miniters=0, mininter...
185
4,713
tqdm
tests/tests_contrib.py
.py
""" Tests for `tqdm.contrib`. """ import pytest from tqdm import tqdm from tqdm.contrib import tenumerate, tmap, tzip from .tests_tqdm import StringIO, closing, importorskip def incr(x): """Dummy function""" return x + 1 @pytest.mark.parametrize("tqdm_kwargs", [{}, {"tqdm_class": tqdm}]) def test_enumerat...
62
1,930
tqdm
tests/tests_concurrent.py
.py
""" Tests for `tqdm.contrib.concurrent`. """ import sys from pytest import warns from tqdm.contrib.concurrent import interpreter_map, process_map, thread_map from .tests_tqdm import StringIO, TqdmWarning, closing, importorskip, mark, skip def incr(x): """Dummy function""" return x + 1 def test_thread_map...
112
3,528
tqdm
tests/tests_notebook.py
.py
from tqdm.notebook import tqdm as tqdm_notebook def test_notebook_disabled_description(): """Test that set_description works for disabled tqdm_notebook""" with tqdm_notebook(1, disable=True) as t: t.set_description("description")
8
248
tqdm
tests/tests_gui.py
.py
"""Test `tqdm.gui`.""" from .tests_tqdm import importorskip def test_gui_import(): """Test `tqdm.gui` import""" importorskip('tqdm.gui')
8
147
tqdm
tests/tests_utils.py
.py
from ast import literal_eval from collections import defaultdict from typing import Union # py<3.10 import pytest from tqdm.utils import envwrap def test_envwrap_deprecated(monkeypatch): """Test @envwrap (basic)""" monkeypatch.setenv('FUNC_A', "42") monkeypatch.setenv('FUNC_TyPe_HiNt', "1337") monk...
69
1,863
tqdm
tests/tests_version.py
.py
"""Test `tqdm.__version__`.""" import re from ast import literal_eval def test_version(): """Test version string""" from tqdm import __version__ version_parts = re.split('[.-]', __version__) if __version__ != "UNKNOWN": assert 3 <= len(version_parts), "must have at least Major.minor.patch" ...
15
467
tqdm
tests/tests_dask.py
.py
from time import sleep from .tests_tqdm import importorskip, mark pytestmark = mark.slow def test_dask(capsys): """Test tqdm.dask.TqdmCallback""" ProgressBar = importorskip('tqdm.dask').TqdmCallback dask = importorskip('dask') schedule = [dask.delayed(sleep)(i / 10) for i in range(5)] with Prog...
19
467
tqdm
tests/tests_perf.py
.py
import sys from contextlib import contextmanager from functools import wraps from time import sleep, time # Use relative/cpu timer to have reliable timings when there is a sudden load try: from time import process_time except ImportError: from time import clock process_time = clock from tqdm import tqdm, ...
316
9,308
tqdm
tests/tests_rlock.py
.py
from .tests_tqdm import StringIO, closing, importorskip, mark, skip @mark.slow def test_rlock_creation(): """Test that importing tqdm does not create multiprocessing objects.""" mp = importorskip('multiprocessing') if not hasattr(mp, 'get_context'): skip("missing multiprocessing.get_context") ...
39
1,520
tqdm
tests/tests_synchronisation.py
.py
import atexit from functools import wraps from threading import Event, RLock, Thread, current_thread from time import sleep, time from tqdm import TMonitor, tqdm, trange from .tests_tqdm import StringIO, closing, importorskip, patch_lock, skip class Time: """Fake time class providing an offset""" offset = 0...
291
10,066
tqdm
tests/tests_main.py
.py
"""Test CLI usage.""" import logging import subprocess # nosec import sys from functools import wraps from os import linesep from tqdm.cli import TqdmKeyError, TqdmTypeError, main from tqdm.utils import IS_WIN from .tests_tqdm import BytesIO, closing, mark, raises def restore_sys(func): """Decorates `func(caps...
245
8,023
tqdm
tests/tests_keras.py
.py
from .tests_tqdm import importorskip, mark pytestmark = mark.slow @mark.filterwarnings("ignore:.*:DeprecationWarning") def test_keras(capsys): """Test tqdm.keras.TqdmCallback""" TqdmCallback = importorskip('tqdm.keras').TqdmCallback np = importorskip('numpy') try: import keras as K except...
92
2,573