MCPcopy Index your code
hub / github.com/python/cpython / format_help

Method format_help

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

Source from the content-addressed store, hash-verified

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