test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
argparse._SubParsersAction Class Reference
Inheritance diagram for argparse._SubParsersAction:
argparse.Action argparse._AttributeHolder

Classes

class  _ChoicesPseudoAction
 

Public Member Functions

def __call__
 
def __init__
 
def add_parser
 
- Public Member Functions inherited from argparse.Action
def __call__
 
def __init__
 
- Public Member Functions inherited from argparse._AttributeHolder
def __repr__
 

Private Member Functions

def _get_subactions
 

Private Attributes

 _choices_actions
 
 _name_parser_map
 
 _parser_class
 
 _prog_prefix
 

Additional Inherited Members

- Public Attributes inherited from argparse.Action
 choices
 
 const
 
 default
 
 dest
 
 help
 
 metavar
 
 nargs
 
 option_strings
 
 required
 
 type
 

Detailed Description

Definition at line 1028 of file argparse.py.

Constructor & Destructor Documentation

def argparse._SubParsersAction.__init__ (   self,
  option_strings,
  prog,
  parser_class,
  dest = SUPPRESS,
  help = None,
  metavar = None 
)

Definition at line 1042 of file argparse.py.

1043  metavar=None):
1045  self._prog_prefix = prog
1046  self._parser_class = parser_class
1048  self._choices_actions = []
1049 
1050  super(_SubParsersAction, self).__init__(
1051  option_strings=option_strings,
1052  dest=dest,
1053  nargs=PARSER,
1054  choices=self._name_parser_map,
1055  help=help,
1056  metavar=metavar)

Member Function Documentation

def argparse._SubParsersAction.__call__ (   self,
  parser,
  namespace,
  values,
  option_string = None 
)

Definition at line 1076 of file argparse.py.

References argparse._SubParsersAction._name_parser_map, python.rootplot.argparse._SubParsersAction._name_parser_map, argparse.Action.dest, python.rootplot.argparse.Action.dest, and join().

1077  def __call__(self, parser, namespace, values, option_string=None):
1078  parser_name = values[0]
1079  arg_strings = values[1:]
1080 
1081  # set the parser name if requested
1082  if self.dest is not SUPPRESS:
1083  setattr(namespace, self.dest, parser_name)
1084 
1085  # select the parser
1086  try:
1087  parser = self._name_parser_map[parser_name]
1088  except KeyError:
1089  tup = parser_name, ', '.join(self._name_parser_map)
1090  msg = _('unknown parser %r (choices: %s)' % tup)
1091  raise ArgumentError(self, msg)
1092 
1093  # parse all the remaining options into the namespace
1094  parser.parse_args(arg_strings, namespace)
1095 
1096 
1097 # ==============
1098 # Type classes
1099 # ==============
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def argparse._SubParsersAction._get_subactions (   self)
private

Definition at line 1073 of file argparse.py.

References argparse._SubParsersAction._choices_actions, and python.rootplot.argparse._SubParsersAction._choices_actions.

1074  def _get_subactions(self):
1075  return self._choices_actions
def argparse._SubParsersAction.add_parser (   self,
  name,
  kwargs 
)

Definition at line 1057 of file argparse.py.

References argparse._SubParsersAction._name_parser_map, python.rootplot.argparse._SubParsersAction._name_parser_map, argparse._SubParsersAction._parser_class, python.rootplot.argparse._SubParsersAction._parser_class, argparse._SubParsersAction._prog_prefix, and python.rootplot.argparse._SubParsersAction._prog_prefix.

1058  def add_parser(self, name, **kwargs):
1059  # set prog from the existing prefix
1060  if kwargs.get('prog') is None:
1061  kwargs['prog'] = '%s %s' % (self._prog_prefix, name)
1062 
1063  # create a pseudo-action to hold the choice help
1064  if 'help' in kwargs:
1065  help = kwargs.pop('help')
1066  choice_action = self._ChoicesPseudoAction(name, help)
1067  self._choices_actions.append(choice_action)
1068 
1069  # create the parser and add it to the map
1070  parser = self._parser_class(**kwargs)
1071  self._name_parser_map[name] = parser
1072  return parser

Member Data Documentation

argparse._SubParsersAction._choices_actions
private

Definition at line 1047 of file argparse.py.

Referenced by argparse._SubParsersAction._get_subactions().

argparse._SubParsersAction._name_parser_map
private

Definition at line 1046 of file argparse.py.

Referenced by argparse._SubParsersAction.__call__(), and argparse._SubParsersAction.add_parser().

argparse._SubParsersAction._parser_class
private

Definition at line 1045 of file argparse.py.

Referenced by argparse._SubParsersAction.add_parser().

argparse._SubParsersAction._prog_prefix
private

Definition at line 1044 of file argparse.py.

Referenced by argparse._SubParsersAction.add_parser().