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.Action argparse._AttributeHolder argparse._AttributeHolder argparse._AttributeHolder argparse._AttributeHolder

Classes

class  _ChoicesPseudoAction
 

Public Member Functions

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

Private Member Functions

def _get_subactions
 
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 1023 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 1037 of file argparse.py.

Referenced by argparse._SubParsersAction.__init__().

1038  metavar=None):
1040  self._prog_prefix = prog
1041  self._parser_class = parser_class
1042  self._name_parser_map = _collections.OrderedDict()
1043  self._choices_actions = []
1044 
1045  super(_SubParsersAction, self).__init__(
1046  option_strings=option_strings,
1047  dest=dest,
1048  nargs=PARSER,
1049  choices=self._name_parser_map,
1050  help=help,
1051  metavar=metavar)
def argparse._SubParsersAction.__init__ (   self,
  option_strings,
  prog,
  parser_class,
  dest = SUPPRESS,
  help = None,
  metavar = None 
)

Definition at line 1042 of file argparse.py.

References argparse._SubParsersAction.__init__(), argparse._SubParsersAction._choices_actions, argparse._SubParsersAction._name_parser_map, argparse._SubParsersAction._parser_class, and argparse._SubParsersAction._prog_prefix.

1043  metavar=None):
1044 
1045  self._prog_prefix = prog
1046  self._parser_class = parser_class
1047  self._name_parser_map = {}
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 1071 of file argparse.py.

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

Referenced by argparse._SubParsersAction.__call__().

1072  def __call__(self, parser, namespace, values, option_string=None):
1073  parser_name = values[0]
1074  arg_strings = values[1:]
1075 
1076  # set the parser name if requested
1077  if self.dest is not SUPPRESS:
1078  setattr(namespace, self.dest, parser_name)
1079 
1080  # select the parser
1081  try:
1082  parser = self._name_parser_map[parser_name]
1083  except KeyError:
1084  tup = parser_name, ', '.join(self._name_parser_map)
1085  msg = _('unknown parser %r (choices: %s)') % tup
1086  raise ArgumentError(self, msg)
1087 
1088  # parse all the remaining options into the namespace
1089  # store any unrecognized options on the object, so that the top
1090  # level parser can decide what to do with them
1091  namespace, arg_strings = parser.parse_known_args(arg_strings, namespace)
1092  if arg_strings:
1093  vars(namespace).setdefault(_UNRECOGNIZED_ARGS_ATTR, [])
1094  getattr(namespace, _UNRECOGNIZED_ARGS_ATTR).extend(arg_strings)
1095 
1096 
1097 # ==============
1098 # Type classes
1099 # ==============
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def argparse._SubParsersAction.__call__ (   self,
  parser,
  namespace,
  values,
  option_string = None 
)

Definition at line 1076 of file argparse.py.

References argparse._SubParsersAction.__call__(), argparse._SubParsersAction._name_parser_map, argparse.Action.dest, join(), and dbtoconf.object.

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 1068 of file argparse.py.

References argparse._SubParsersAction._choices_actions.

Referenced by argparse._SubParsersAction._get_subactions().

1069  def _get_subactions(self):
1070  return self._choices_actions
def argparse._SubParsersAction._get_subactions (   self)
private

Definition at line 1073 of file argparse.py.

References argparse._SubParsersAction._choices_actions, and argparse._SubParsersAction._get_subactions().

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

Definition at line 1052 of file argparse.py.

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

Referenced by argparse._SubParsersAction.add_parser().

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

Definition at line 1057 of file argparse.py.

References argparse._SubParsersAction._name_parser_map, argparse._SubParsersAction._parser_class, argparse._SubParsersAction._prog_prefix, and argparse._SubParsersAction.add_parser().

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 1042 of file argparse.py.

Referenced by argparse._SubParsersAction.__init__(), argparse._SubParsersAction._get_subactions(), and python.rootplot.argparse._SubParsersAction._get_subactions().

argparse._SubParsersAction._name_parser_map
private

Definition at line 1041 of file argparse.py.

Referenced by argparse._SubParsersAction.__call__(), python.rootplot.argparse._SubParsersAction.__call__(), argparse._SubParsersAction.__init__(), argparse._SubParsersAction.add_parser(), and python.rootplot.argparse._SubParsersAction.add_parser().

argparse._SubParsersAction._parser_class
private

Definition at line 1040 of file argparse.py.

Referenced by argparse._SubParsersAction.__init__(), argparse._SubParsersAction.add_parser(), and python.rootplot.argparse._SubParsersAction.add_parser().

argparse._SubParsersAction._prog_prefix
private

Definition at line 1039 of file argparse.py.

Referenced by argparse._SubParsersAction.__init__(), argparse._SubParsersAction.add_parser(), and python.rootplot.argparse._SubParsersAction.add_parser().