Show task progress as a percentage. Args: text_format (str, optional): Format for percentage display. Defaults to "[progress.percentage]{task.percentage:>3.0f}%". text_format_no_percentage (str, optional): Format if percentage is unknown. Defaults to "". style (StyleType
| 698 | |
| 699 | |
| 700 | class TaskProgressColumn(TextColumn): |
| 701 | """Show task progress as a percentage. |
| 702 | |
| 703 | Args: |
| 704 | text_format (str, optional): Format for percentage display. Defaults to "[progress.percentage]{task.percentage:>3.0f}%". |
| 705 | text_format_no_percentage (str, optional): Format if percentage is unknown. Defaults to "". |
| 706 | style (StyleType, optional): Style of output. Defaults to "none". |
| 707 | justify (JustifyMethod, optional): Text justification. Defaults to "left". |
| 708 | markup (bool, optional): Enable markup. Defaults to True. |
| 709 | highlighter (Optional[Highlighter], optional): Highlighter to apply to output. Defaults to None. |
| 710 | table_column (Optional[Column], optional): Table Column to use. Defaults to None. |
| 711 | show_speed (bool, optional): Show speed if total is unknown. Defaults to False. |
| 712 | """ |
| 713 | |
| 714 | def __init__( |
| 715 | self, |
| 716 | text_format: str = "[progress.percentage]{task.percentage:>3.0f}%", |
| 717 | text_format_no_percentage: str = "", |
| 718 | style: StyleType = "none", |
| 719 | justify: JustifyMethod = "left", |
| 720 | markup: bool = True, |
| 721 | highlighter: Optional[Highlighter] = None, |
| 722 | table_column: Optional[Column] = None, |
| 723 | show_speed: bool = False, |
| 724 | ) -> None: |
| 725 | self.text_format_no_percentage = text_format_no_percentage |
| 726 | self.show_speed = show_speed |
| 727 | super().__init__( |
| 728 | text_format=text_format, |
| 729 | style=style, |
| 730 | justify=justify, |
| 731 | markup=markup, |
| 732 | highlighter=highlighter, |
| 733 | table_column=table_column, |
| 734 | ) |
| 735 | |
| 736 | @classmethod |
| 737 | def render_speed(cls, speed: Optional[float]) -> Text: |
| 738 | """Render the speed in iterations per second. |
| 739 | |
| 740 | Args: |
| 741 | task (Task): A Task object. |
| 742 | |
| 743 | Returns: |
| 744 | Text: Text object containing the task speed. |
| 745 | """ |
| 746 | if speed is None: |
| 747 | return Text("", style="progress.percentage") |
| 748 | unit, suffix = filesize.pick_unit_and_suffix( |
| 749 | int(speed), |
| 750 | ["", "×10³", "×10⁶", "×10⁹", "×10¹²"], |
| 751 | 1000, |
| 752 | ) |
| 753 | data_speed = speed / unit |
| 754 | return Text(f"{data_speed:.1f}{suffix} it/s", style="progress.percentage") |
| 755 | |
| 756 | def render(self, task: "Task") -> Text: |
| 757 | if task.total is None and self.show_speed: |
no outgoing calls
no test coverage detected