(
self, console: Console, options: ConsoleOptions
)
| 154 | yield from segments |
| 155 | |
| 156 | def __rich_console__( |
| 157 | self, console: Console, options: ConsoleOptions |
| 158 | ) -> RenderResult: |
| 159 | width = min(self.width or options.max_width, options.max_width) |
| 160 | ascii = options.legacy_windows or options.ascii_only |
| 161 | should_pulse = self.pulse or self.total is None |
| 162 | if should_pulse: |
| 163 | yield from self._render_pulse(console, width, ascii=ascii) |
| 164 | return |
| 165 | |
| 166 | completed: Optional[float] = ( |
| 167 | min(self.total, max(0, self.completed)) if self.total is not None else None |
| 168 | ) |
| 169 | |
| 170 | bar = "-" if ascii else "━" |
| 171 | half_bar_right = " " if ascii else "╸" |
| 172 | half_bar_left = " " if ascii else "╺" |
| 173 | complete_halves = ( |
| 174 | int(width * 2 * completed / self.total) |
| 175 | if self.total and completed is not None |
| 176 | else width * 2 |
| 177 | ) |
| 178 | bar_count = complete_halves // 2 |
| 179 | half_bar_count = complete_halves % 2 |
| 180 | style = console.get_style(self.style) |
| 181 | is_finished = self.total is None or self.completed >= self.total |
| 182 | complete_style = console.get_style( |
| 183 | self.finished_style if is_finished else self.complete_style |
| 184 | ) |
| 185 | _Segment = Segment |
| 186 | if bar_count: |
| 187 | yield _Segment(bar * bar_count, complete_style) |
| 188 | if half_bar_count: |
| 189 | yield _Segment(half_bar_right * half_bar_count, complete_style) |
| 190 | |
| 191 | if not console.no_color: |
| 192 | remaining_bars = width - bar_count - half_bar_count |
| 193 | if remaining_bars and console.color_system is not None: |
| 194 | if not half_bar_count and bar_count: |
| 195 | yield _Segment(half_bar_left, style) |
| 196 | remaining_bars -= 1 |
| 197 | if remaining_bars: |
| 198 | yield _Segment(bar * remaining_bars, style) |
| 199 | |
| 200 | def __rich_measure__( |
| 201 | self, console: Console, options: ConsoleOptions |
nothing calls this directly
no test coverage detected