def format(self, width=None, elapsed=None):
width = width or self.manager.width<EOL>iterations = abs(self.count - self.start_count)<EOL>fields = {'<STR_LIT:bar>': u'<STR_LIT>',<EOL>'<STR_LIT:count>': self.count,<EOL>'<STR_LIT>': self.desc or u'<STR_LIT>',<EOL>'<STR_LIT>': self.total,<EOL>'<STR_LIT>': self.unit or u'<STR_LIT>',<EOL>'<STR_LIT>': u'<STR_LIT:U+0020>' if self.desc else u'<STR_LIT>',<EOL>'<STR_LIT>': u'<STR_LIT:U+0020>' if self.unit else u'<STR_LIT>'}<EOL>if elapsed is None:<EOL><INDENT>elapsed = self.elapsed<EOL><DEDENT>fields['<STR_LIT>'] = _format_time(elapsed)<EOL>if elapsed:<EOL><INDENT>fields['<STR_LIT>'] = iterations / elapsed<EOL><DEDENT>else:<EOL><INDENT>fields['<STR_LIT>'] = <NUM_LIT:0.0><EOL><DEDENT>if self.total is not None and self.count <= self.total:<EOL><INDENT>fields['<STR_LIT>'] = len(str(self.total))<EOL>if self.total == <NUM_LIT:0>:<EOL><INDENT>percentage = <NUM_LIT:1><EOL>fields['<STR_LIT>'] = u'<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>percentage = self.count / float(self.total)<EOL>if fields['<STR_LIT>']:<EOL><INDENT>fields['<STR_LIT>'] = _format_time((self.total - iterations) / fields['<STR_LIT>'])<EOL><DEDENT>else:<EOL><INDENT>fields['<STR_LIT>'] = u'<STR_LIT:?>'<EOL><DEDENT><DEDENT>fields['<STR_LIT>'] = percentage * <NUM_LIT:100><EOL>subcounters, subFields = self._get_subcounters(elapsed)<EOL>if subcounters:<EOL><INDENT>fields.update(subFields)<EOL>fields['<STR_LIT>'] = self.count - sum(sub[<NUM_LIT:0>].count for sub in subcounters)<EOL>fields['<STR_LIT>'] = (percentage - sum(sub[<NUM_LIT:1>] for sub in subcounters)) * <NUM_LIT:100><EOL><DEDENT>rtn = self.bar_format.format(**fields)<EOL>barWidth = width - len(rtn) + self.offset + <NUM_LIT:3>  <EOL>complete = barWidth * percentage<EOL>barLen = int(complete)<EOL>barText = u'<STR_LIT>'<EOL>subOffset = <NUM_LIT:0><EOL>for subcounter, subPercentage in reversed(subcounters):<EOL><INDENT>subLen = int(barWidth * subPercentage)<EOL>barText += subcounter._colorize(self.series[-<NUM_LIT:1>] * subLen)<EOL>subOffset += subLen<EOL><DEDENT>barText += self.series[-<NUM_LIT:1>] * (barLen - subOffset)<EOL>if barLen < barWidth:<EOL><INDENT>barText += self.series[int(round((complete - barLen) * (len(self.series) - <NUM_LIT:1>)))]<EOL>barText += self.series[<NUM_LIT:0>] * (barWidth - barLen - <NUM_LIT:1>)<EOL><DEDENT>return rtn.format(self._colorize(barText))<EOL><DEDENT>fields['<STR_LIT>'] = u'<STR_LIT>'<EOL>rtn = self.counter_format.format(**fields)<EOL>return rtn.format(u'<STR_LIT:U+0020>' * (width - len(rtn) + self.offset + <NUM_LIT:3>))<EOL>
Args:
    width (int): Width in columns to make progress bar
    elapsed(float): Time since started. Automatically determined if :py:data:`None`

Returns:
    :py:class:`str`: Formatted progress bar or counter

Format progress bar or counter