MCPcopy
hub / github.com/sphinx-doc/sphinx / status_iterator

Function status_iterator

sphinx/util/display.py:26–55  ·  view source on GitHub ↗
(
    iterable: Iterable[T],
    summary: str,
    color: str = 'darkgreen',
    length: int = 0,
    verbosity: int = 0,
    stringify_func: Callable[[Any], str] = display_chunk,
)

Source from the content-addressed store, hash-verified

24
25
26def status_iterator[T](
27 iterable: Iterable[T],
28 summary: str,
29 color: str = 'darkgreen',
30 length: int = 0,
31 verbosity: int = 0,
32 stringify_func: Callable[[Any], str] = display_chunk,
33) -> Iterator[T]:
34 # printing on a single line requires ANSI control sequences
35 single_line = verbosity < 1 and terminal_supports_colour()
36 bold_summary = bold(summary)
37 if length == 0:
38 logger.info(bold_summary, nonl=True)
39 for item in iterable:
40 logger.info('%s ', stringify_func(item), nonl=True, color=color)
41 yield item
42 else:
43 for i, item in enumerate(iterable, start=1):
44 if single_line:
45 # clear the entire line ('Erase in Line')
46 logger.info('\x1b[2K', nonl=True)
47 logger.info(f'{bold_summary}[{i / length: >4.0%}] ', nonl=True) # NoQA: G004
48 # Emit the string representation of ``item``
49 logger.info(stringify_func(item), nonl=True, color=color)
50 # If in single-line mode, emit a carriage return to move the cursor
51 # to the start of the line.
52 # If not, emit a newline to move the cursor to the next line.
53 logger.info('\r' * single_line, nonl=single_line)
54 yield item
55 logger.info('')
56
57
58class SkipProgressMessage(Exception):

Callers 15

finishMethod · 0.90
compile_catalogsMethod · 0.90
_read_serialMethod · 0.90
_read_parallelMethod · 0.90
_write_serialMethod · 0.90
_write_parallelMethod · 0.90
copy_image_files_pilMethod · 0.90
copy_image_filesMethod · 0.90
copy_image_filesMethod · 0.90
copy_image_filesMethod · 0.90
copy_download_filesMethod · 0.90

Calls 1

terminal_supports_colourFunction · 0.90

Used in the wild real call sites across dependent graphs

searching dependent graphs…