MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / __format__

Method __format__

pager_lib/tqdm/std.py:185–210  ·  view source on GitHub ↗
(self, format_spec)

Source from the content-addressed store, hash-verified

183 self._colour = None
184
185 def __format__(self, format_spec):
186 if format_spec:
187 _type = format_spec[-1].lower()
188 try:
189 charset = {'a': self.ASCII, 'u': self.UTF, 'b': self.BLANK}[_type]
190 except KeyError:
191 charset = self.charset
192 else:
193 format_spec = format_spec[:-1]
194 if format_spec:
195 N_BARS = int(format_spec)
196 if N_BARS < 0:
197 N_BARS += self.default_len
198 else:
199 N_BARS = self.default_len
200 else:
201 charset = self.charset
202 N_BARS = self.default_len
203
204 nsyms = len(charset) - 1
205 bar_length, frac_bar_length = divmod(int(self.frac * N_BARS * nsyms), nsyms)
206
207 res = charset[-1] * bar_length
208 if bar_length < N_BARS: # whitespace padding
209 res = res + charset[frac_bar_length] + charset[0] * (N_BARS - bar_length - 1)
210 return self.colour + res + self.COLOUR_RESET if self.colour else res
211
212
213class EMA:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected