Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Private Member Functions
argparse.ArgumentDefaultsHelpFormatter Class Reference
Inheritance diagram for argparse.ArgumentDefaultsHelpFormatter:
Inheritance graph
[legend]
Collaboration diagram for argparse.ArgumentDefaultsHelpFormatter:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def start_section
def end_section
def add_text
def add_usage
def add_argument
def add_arguments
def format_help

Public Attributes

_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Private Member Functions

def _get_help_string

Detailed Description

Help message formatter which adds default values to argument help.

Only the name of this class is considered a public API. All the methods
provided by the class are considered an implementation detail.

Definition at line 649 of file argparse.py.


Member Function Documentation

def argparse.ArgumentDefaultsHelpFormatter._get_help_string (   self,
  action 
) [private]

Reimplemented from argparse.HelpFormatter.

Definition at line 656 of file argparse.py.

00656 
00657     def _get_help_string(self, action):
00658         help = action.help
00659         if '%(default)' not in action.help:
00660             if action.default is not SUPPRESS:
00661                 defaulting_nargs = [OPTIONAL, ZERO_OR_MORE]
00662                 if action.option_strings or action.nargs in defaulting_nargs:
00663                     help += ' (default: %(default)s)'
00664         return help
00665 
00666 
00667 # =====================
00668 # Options and Arguments
00669 # =====================

def argparse.HelpFormatter.add_argument (   self,
  action 
) [inherited]

Definition at line 253 of file argparse.py.

00253 
00254     def add_argument(self, action):
00255         if action.help is not SUPPRESS:
00256 
00257             # find all invocations
00258             get_invocation = self._format_action_invocation
00259             invocations = [get_invocation(action)]
00260             for subaction in self._iter_indented_subactions(action):
00261                 invocations.append(get_invocation(subaction))
00262 
00263             # update the maximum item length
00264             invocation_length = max([len(s) for s in invocations])
00265             action_length = invocation_length + self._current_indent
00266             self._action_max_length = max(self._action_max_length,
00267                                           action_length)
00268 
00269             # add the item to the list
00270             self._add_item(self._format_action, [action])

Here is the call graph for this function:

Here is the caller graph for this function:

def argparse.HelpFormatter.add_arguments (   self,
  actions 
) [inherited]

Definition at line 271 of file argparse.py.

00271 
00272     def add_arguments(self, actions):
00273         for action in actions:
00274             self.add_argument(action)

Here is the call graph for this function:

def argparse.HelpFormatter.add_text (   self,
  text 
) [inherited]

Definition at line 244 of file argparse.py.

00244 
00245     def add_text(self, text):
00246         if text is not SUPPRESS and text is not None:
00247             self._add_item(self._format_text, [text])

Here is the call graph for this function:

def argparse.HelpFormatter.add_usage (   self,
  usage,
  actions,
  groups,
  prefix = None 
) [inherited]

Definition at line 248 of file argparse.py.

00248 
00249     def add_usage(self, usage, actions, groups, prefix=None):
00250         if usage is not SUPPRESS:
00251             args = usage, actions, groups, prefix
00252             self._add_item(self._format_usage, args)

Here is the call graph for this function:

def argparse.HelpFormatter.end_section (   self) [inherited]

Definition at line 240 of file argparse.py.

00240 
00241     def end_section(self):
00242         self._current_section = self._current_section.parent
00243         self._dedent()

Here is the call graph for this function:

def argparse.HelpFormatter.format_help (   self) [inherited]

Definition at line 278 of file argparse.py.

00278 
00279     def format_help(self):
00280         help = self._root_section.format_help()
00281         if help:
00282             help = self._long_break_matcher.sub('\n\n', help)
00283             help = help.strip('\n') + '\n'
00284         return help

Here is the caller graph for this function:

def argparse.HelpFormatter.start_section (   self,
  heading 
) [inherited]

Definition at line 234 of file argparse.py.

00234 
00235     def start_section(self, heading):
00236         self._indent()
00237         section = self._Section(self, self._current_section, heading)
00238         self._add_item(section.format_help, [])
00239         self._current_section = section

Here is the call graph for this function:


Member Data Documentation

Definition at line 107 of file object.h.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 of file object.h.


The documentation for this class was generated from the following file: