Skip progressbar rendering when `is_hidden` is True
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by George Y. Kussumoto · committed by George Y. Kussumoto · parent b471d34 · Browse files · 1 file·+25 added−28 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+25 added−28 removed
- other:+25 added−28 removed
Provenance
- Commit
61abbef- Tree
d2291c5- Author
George Y. Kussumoto <georgeyk.dev@gmail.com>- Committer
George Y. Kussumoto <georgeyk.dev@gmail.com>- Parent
b471d34
1 file changed+25 added−28 removed
modified:click/_termui_impl.py+25 added-28 removed
190 unmodified lines191 }).rstrip()192 193 def render_progress(self):194 from .termui import get_terminal_size195- nl = False195 196 if self.is_hidden:198- buf = [self.label]199- nl = True200- else:201- buf = []202- # Update width in case the terminal has been resized203- if self.autowidth:204- old_width = self.width205- self.width = 0206- clutter_length = term_len(self.format_progress_line())207- new_width = max(0, get_terminal_size()[0] - clutter_length)208- if new_width < old_width:209- buf.append(BEFORE_BAR)210- buf.append(' ' * self.max_width)211- self.max_width = new_width212- self.width = new_width197+ return198 214- clear_width = self.width215- if self.max_width is not None:216- clear_width = self.max_width199+ buf = []200+ # Update width in case the terminal has been resized201+ if self.autowidth:202+ old_width = self.width203+ self.width = 0204+ clutter_length = term_len(self.format_progress_line())205+ new_width = max(0, get_terminal_size()[0] - clutter_length)206+ if new_width < old_width:207+ buf.append(BEFORE_BAR)208+ buf.append(' ' * self.max_width)209+ self.max_width = new_width210+ self.width = new_width211 218- buf.append(BEFORE_BAR)219- line = self.format_progress_line()220- line_len = term_len(line)221- if self.max_width is None or self.max_width < line_len:222- self.max_width = line_len223- buf.append(line)212+ clear_width = self.width213+ if self.max_width is not None:214+ clear_width = self.max_width215 225- buf.append(' ' * (clear_width - line_len))226- line = ''.join(buf)216+ buf.append(BEFORE_BAR)217+ line = self.format_progress_line()218+ line_len = term_len(line)219+ if self.max_width is None or self.max_width < line_len:220+ self.max_width = line_len221 222+ buf.append(line)223+ buf.append(' ' * (clear_width - line_len))224+ line = ''.join(buf)225 # Render the line only if it changed.226 if line != self._last_line:227 self._last_line = line231- echo(line, file=self.file, color=self.color, nl=nl)228+ echo(line, file=self.file, color=self.color, nl=True)229 self.file.flush()230 231 def make_step(self, n_steps):232 self.pos += n_steps321 unmodified lines