Print a single step line in the column format.
(
label: str,
value: str,
color_fn = None,
)
| 1600 | |
| 1601 | |
| 1602 | def _step( |
| 1603 | label: str, |
| 1604 | value: str, |
| 1605 | color_fn = None, |
| 1606 | ) -> None: |
| 1607 | """Print a single step line in the column format.""" |
| 1608 | global _PROGRESS_LINE_ACTIVE |
| 1609 | if color_fn is None: |
| 1610 | color_fn = _green |
| 1611 | padded = label[:_COL] |
| 1612 | plain_prefix_width = _INDENT + _COL |
| 1613 | prefix = f"{' ' * _INDENT}{_dim(padded)}{' ' * (_COL - len(padded))}" |
| 1614 | wrap_width = max( |
| 1615 | 24, |
| 1616 | shutil.get_terminal_size((100, 20)).columns - plain_prefix_width, |
| 1617 | ) |
| 1618 | lines = textwrap.wrap( |
| 1619 | value, |
| 1620 | width = wrap_width, |
| 1621 | break_long_words = False, |
| 1622 | break_on_hyphens = False, |
| 1623 | ) or [""] |
| 1624 | if _PROGRESS_LINE_ACTIVE and not VERBOSE: |
| 1625 | try: |
| 1626 | sys.stdout.write("\n") |
| 1627 | sys.stdout.flush() |
| 1628 | except OSError: |
| 1629 | pass |
| 1630 | _PROGRESS_LINE_ACTIVE = False |
| 1631 | _safe_print(f"{prefix}{color_fn(lines[0])}") |
| 1632 | continuation_prefix = " " * plain_prefix_width |
| 1633 | for line in lines[1:]: |
| 1634 | _safe_print(f"{continuation_prefix}{color_fn(line)}") |
| 1635 | |
| 1636 | |
| 1637 | def _progress(label: str) -> None: |
no test coverage detected
searching dependent graphs…