Skip to content
Myr

Merge pull request #414 from flying-sheep/patch-1

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

Extract bar formatting to own method

authored by Dan Sully · committed by GitHub · parents 341e471, a41415c · 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
156 unmodified lines
157158 def format_pct(self):159 return ('% 4d%%' % int(self.pct * 100))[1:]160161 def format_progress_line(self):162 show_percent = self.show_percent163164 info_bits = []161 def format_bar(self):162 if self.length_known:163 bar_length = int(self.pct * self.width)164 bar = self.fill_char * bar_length165 bar += self.empty_char * (self.width - bar_length)169 if show_percent is None:170 show_percent = not self.show_pos166 elif self.finished:167 bar = self.fill_char * self.width168 else:172 if self.finished:173 bar = self.fill_char * self.width174 else:175 bar = list(self.empty_char * (self.width or 1))176 if self.time_per_iteration != 0:177 bar[int((math.cos(self.pos * self.time_per_iteration)178 / 2.0 + 0.5) * self.width)] = self.fill_char179 bar = ''.join(bar)169 bar = list(self.empty_char * (self.width or 1))170 if self.time_per_iteration != 0:171 bar[int((math.cos(self.pos * self.time_per_iteration)172 / 2.0 + 0.5) * self.width)] = self.fill_char173 bar = ''.join(bar)174 return bar175176 def format_progress_line(self):177 show_percent = self.show_percent178179 info_bits = []180 if self.length_known and show_percent is None:181 show_percent = not self.show_pos182183 if self.show_pos:184 info_bits.append(self.format_pos())185 if show_percent:186 info_bits.append(self.format_pct())
5 unmodified lines
192 info_bits.append(item_info)193194 return (self.bar_template % {195 'label': self.label,194 'bar': bar,196 'bar': self.format_bar(),197 'info': self.info_sep.join(info_bits)198 }).rstrip()199200 def render_progress(self):
377 unmodified lines