CMS 3D CMS Logo

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__ (self, parser, namespace, values, option_string=None)
 
def __init__ (self, option_strings, prog, parser_class, dest=SUPPRESS, help=None, metavar=None)
 
def add_parser (self, name, kwargs)
 
- Public Member Functions inherited from argparse.Action
def __call__ (self, parser, namespace, values, option_string=None)
 
def __init__ (self, option_strings, dest, nargs=None, const =None, default=None, type=None, choices=None, required=False, help=None, metavar=None)
 
- Public Member Functions inherited from argparse._AttributeHolder
def __repr__ (self)
 

Private Member Functions

def _get_subactions (self)
 

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.

1042  metavar=None):
1043 
1044  self._prog_prefix = prog
1045  self._parser_class = parser_class
1048 
1049  super(_SubParsersAction, self).__init__(
1050  option_strings=option_strings,
1051  dest=dest,
1052  nargs=PARSER,
1053  choices=self._name_parser_map,
1054  help=help,
1055  metavar=metavar)
1056 
def __init__(self, option_strings, prog, parser_class, dest=SUPPRESS, help=None, metavar=None)
Definition: argparse.py:1042

Member Function Documentation

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

Definition at line 1076 of file argparse.py.

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

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

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

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
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().