Skip to content
Myr

Extracted bar formatting to own method

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Philipp A. · committed by Philipp A. · parent da080dd · Browse files · 1 file+17 added−15 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+17 added−15 removed

  • other:+17 added−15 removed

1 file+17 added−15 removed

modified:click/_termui_impl.py+17 added-15 removed
138 unmodified lines
139140 def format_pct(self):141 return ('% 4d%%' % int(self.pct * 100))[1:]142143 def format_progress_line(self):144 show_percent = self.show_percent145146 info_bits = []143 def format_bar(self):144 if self.length_known:145 bar_length = int(self.pct * self.width)146 bar = self.fill_char * bar_length147 bar += self.empty_char * (self.width - bar_length)151 if show_percent is None:152 show_percent = not self.show_pos148 elif self.finished:149 bar = self.fill_char * self.width150 else:154 if self.finished:155 bar = self.fill_char * self.width156 else:157 bar = list(self.empty_char * (self.width or 1))158 if self.time_per_iteration != 0:159 bar[int((math.cos(self.pos * self.time_per_iteration)160 / 2.0 + 0.5) * self.width)] = self.fill_char161 bar = ''.join(bar)151 bar = list(self.empty_char * (self.width or 1))152 if self.time_per_iteration != 0:153 bar[int((math.cos(self.pos * self.time_per_iteration)154 / 2.0 + 0.5) * self.width)] = self.fill_char155 bar = ''.join(bar)156 return bar157158 def format_progress_line(self):159 show_percent = self.show_percent160161 info_bits = []162 if self.length_known and show_percent is None:163 show_percent = not self.show_pos164165 if self.show_pos:166 info_bits.append(self.format_pos())167 if show_percent:168 info_bits.append(self.format_pct())
5 unmodified lines
174 info_bits.append(item_info)175176 return (self.bar_template % {177 'label': self.label,176 'bar': bar,178 'bar': self.format_bar(),179 'info': self.info_sep.join(info_bits)180 }).rstrip()181182 def render_progress(self):
348 unmodified lines