MCPcopy Index your code
hub / github.com/RustPython/RustPython / format_help

Method format_help

Lib/argparse.py:226–252  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

224 self.items = []
225
226 def format_help(self):
227 # format the indented section
228 if self.parent is not None:
229 self.formatter._indent()
230 join = self.formatter._join_parts
231 item_help = join([func(*args) for func, args in self.items])
232 if self.parent is not None:
233 self.formatter._dedent()
234
235 # return nothing if the section was empty
236 if not item_help:
237 return ''
238
239 # add the heading if the section was non-empty
240 if self.heading is not SUPPRESS and self.heading is not None:
241 current_indent = self.formatter._current_indent
242 heading_text = _('%(heading)s:') % dict(heading=self.heading)
243 t = self.formatter._theme
244 heading = (
245 f'{" " * current_indent}'
246 f'{t.heading}{heading_text}{t.reset}\n'
247 )
248 else:
249 heading = ''
250
251 # join the section-initial newline, the heading and the help
252 return join(['\n', heading, item_help, '\n'])
253
254 def _add_item(self, func, args):
255 self._current_section.items.append((func, args))

Callers

nothing calls this directly

Calls 5

_indentMethod · 0.80
_dedentMethod · 0.80
joinFunction · 0.70
funcFunction · 0.50
_Function · 0.50

Tested by

no test coverage detected