CMS 3D CMS Logo

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

Public Member Functions

def __init__
 
def __init__
 
def add_subparsers
 
def add_subparsers
 
def convert_arg_line_to_args
 
def error
 
def error
 
def exit
 
def exit
 
def format_help
 
def format_help
 
def format_usage
 
def format_usage
 
def format_version
 
def format_version
 
def parse_args
 
def parse_args
 
def parse_known_args
 
def parse_known_args
 
def print_help
 
def print_help
 
def print_usage
 
def print_usage
 
def print_version
 
def print_version
 
- Public Member Functions inherited from argparse._AttributeHolder
def __repr__
 
def __repr__
 
- Public Member Functions inherited from argparse._ActionsContainer
def __init__
 
def __init__
 
def add_argument
 
def add_argument
 
def add_argument_group
 
def add_argument_group
 
def add_mutually_exclusive_group
 
def add_mutually_exclusive_group
 
def get_default
 
def register
 
def register
 
def set_defaults
 
def set_defaults
 

Public Attributes

 add_help
 
 epilog
 
 formatter_class
 
 fromfile_prefix_chars
 
 prog
 
 usage
 
 version
 
- Public Attributes inherited from argparse._ActionsContainer
 argument_default
 
 conflict_handler
 
 description
 
 prefix_chars
 

Private Member Functions

def _add_action
 
def _add_action
 
def _check_value
 
def _check_value
 
def _get_formatter
 
def _get_formatter
 
def _get_kwargs
 
def _get_kwargs
 
def _get_nargs_pattern
 
def _get_nargs_pattern
 
def _get_option_tuples
 
def _get_option_tuples
 
def _get_optional_actions
 
def _get_optional_actions
 
def _get_positional_actions
 
def _get_positional_actions
 
def _get_value
 
def _get_value
 
def _get_values
 
def _get_values
 
def _match_argument
 
def _match_argument
 
def _match_arguments_partial
 
def _match_arguments_partial
 
def _parse_known_args
 
def _parse_known_args
 
def _parse_optional
 
def _parse_optional
 
def _print_message
 
def _print_message
 
def _read_args_from_files
 
def _read_args_from_files
 

Private Attributes

 _optionals
 
 _positionals
 
 _subparsers
 

Detailed Description

Object for parsing command line strings into Python objects.

Keyword Arguments:
    - prog -- The name of the program (default: sys.argv[0])
    - usage -- A usage message (default: auto-generated from arguments)
    - description -- A description of what the program does
    - epilog -- Text following the argument descriptions
    - parents -- Parsers whose arguments should be copied into this one
    - formatter_class -- HelpFormatter class for printing help messages
    - prefix_chars -- Characters that prefix optional arguments
    - fromfile_prefix_chars -- Characters that prefix files containing
        additional arguments
    - argument_default -- The default value for all arguments
    - conflict_handler -- String indicating how to handle conflicts
    - add_help -- Add a -h/-help option
Object for parsing command line strings into Python objects.

Keyword Arguments:
    - prog -- The name of the program (default: sys.argv[0])
    - usage -- A usage message (default: auto-generated from arguments)
    - description -- A description of what the program does
    - epilog -- Text following the argument descriptions
    - version -- Add a -v/--version option with the given version string
    - parents -- Parsers whose arguments should be copied into this one
    - formatter_class -- HelpFormatter class for printing help messages
    - prefix_chars -- Characters that prefix optional arguments
    - fromfile_prefix_chars -- Characters that prefix files containing
        additional arguments
    - argument_default -- The default value for all arguments
    - conflict_handler -- String indicating how to handle conflicts
    - add_help -- Add a -h/-help option

Definition at line 1525 of file argparse.py.

Constructor & Destructor Documentation

def argparse.ArgumentParser.__init__ (   self,
  prog = None,
  usage = None,
  description = None,
  epilog = None,
  version = None,
  parents = [],
  formatter_class = HelpFormatter,
  prefix_chars = '-',
  fromfile_prefix_chars = None,
  argument_default = None,
  conflict_handler = 'error',
  add_help = True 
)

Definition at line 1555 of file argparse.py.

1556  add_help=True):
1557 
1558  if version is not None:
1559  import warnings
1560  warnings.warn(
1561  """The "version" argument to ArgumentParser is deprecated. """
1562  """Please use """
1563  """"add_argument(..., action='version', version="N", ...)" """
1564  """instead""", DeprecationWarning)
1565 
1566  superinit = super(ArgumentParser, self).__init__
1567  superinit(description=description,
1568  prefix_chars=prefix_chars,
1569  argument_default=argument_default,
1570  conflict_handler=conflict_handler)
1571 
1572  # default setting for prog
1573  if prog is None:
1574  prog = _os.path.basename(_sys.argv[0])
1576  self.prog = prog
1577  self.usage = usage
1578  self.epilog = epilog
1579  self.version = version
1580  self.formatter_class = formatter_class
1581  self.fromfile_prefix_chars = fromfile_prefix_chars
1582  self.add_help = add_help
1583 
1584  add_group = self.add_argument_group
1585  self._positionals = add_group(_('positional arguments'))
1586  self._optionals = add_group(_('optional arguments'))
1587  self._subparsers = None
1588 
1589  # register types
1590  def identity(string):
1591  return string
1592  self.register('type', None, identity)
1593 
1594  # add help and version arguments if necessary
1595  # (using explicit default to override global argument_default)
1596  default_prefix = '-' if '-' in prefix_chars else prefix_chars[0]
1597  if self.add_help:
1598  self.add_argument(
1599  default_prefix+'h', default_prefix*2+'help',
1600  action='help', default=SUPPRESS,
1601  help=_('show this help message and exit'))
1602  if self.version:
1603  self.add_argument(
1604  default_prefix+'v', default_prefix*2+'version',
1605  action='version', default=SUPPRESS,
1606  version=self.version,
1607  help=_("show program's version number and exit"))
1608 
1609  # add parent arguments and defaults
1610  for parent in parents:
1611  self._add_container_actions(parent)
1612  try:
1613  defaults = parent._defaults
1614  except AttributeError:
1615  pass
1616  else:
1617  self._defaults.update(defaults)
def argparse.ArgumentParser.__init__ (   self,
  prog = None,
  usage = None,
  description = None,
  epilog = None,
  version = None,
  parents = [],
  formatter_class = HelpFormatter,
  prefix_chars = '-',
  fromfile_prefix_chars = None,
  argument_default = None,
  conflict_handler = 'error',
  add_help = True 
)

Definition at line 1534 of file argparse.py.

References argparse._ActionsContainer._add_container_actions(), argparse.ArgumentParser._optionals, argparse.ArgumentParser._positionals, argparse.ArgumentParser._subparsers, argparse.HelpFormatter.add_argument(), argparse._ActionsContainer.add_argument(), argparse._ActionsContainer.add_argument_group(), argparse.ArgumentParser.add_help, argparse.ArgumentParser.epilog, argparse.ArgumentParser.formatter_class, argparse.ArgumentParser.fromfile_prefix_chars, argparse.ArgumentParser.prog, VarParsing.VarParsing.register(), argparse._ActionsContainer.register(), argparse.ArgumentParser.usage, MatrixInjector.MatrixInjector.version, TrackerInteractionGeometry.version, ora::MappingRawData.version, MatacqTBRawEvent::matacqHeader_t.version, DQMNet::CoreObject.version, XMLProcessor::_DBConfig.version, ScalersEventRecordRaw_v1.version, ScalersEventRecordRaw_v2.version, ScalersEventRecordRaw_v3.version, ScalersEventRecordRaw_v4.version, ScalersEventRecordRaw_v5.version, ScalersEventRecordRaw_v6.version, argparse._VersionAction.version, TiXmlDeclaration.version, and argparse.ArgumentParser.version.

1535  add_help=True):
1536 
1537  superinit = super(ArgumentParser, self).__init__
1538  superinit(description=description,
1539  prefix_chars=prefix_chars,
1540  argument_default=argument_default,
1541  conflict_handler=conflict_handler)
1542 
1543  # default setting for prog
1544  if prog is None:
1545  prog = _os.path.basename(_sys.argv[0])
1546 
1547  self.prog = prog
1548  self.usage = usage
1549  self.epilog = epilog
1550  self.version = version
1551  self.formatter_class = formatter_class
1552  self.fromfile_prefix_chars = fromfile_prefix_chars
1553  self.add_help = add_help
1554 
1555  add_group = self.add_argument_group
1556  self._positionals = add_group(_('positional arguments'))
1557  self._optionals = add_group(_('optional arguments'))
1558  self._subparsers = None
1559 
1560  # register types
1561  def identity(string):
1562  return string
1563  self.register('type', None, identity)
1564 
1565  # add help and version arguments if necessary
1566  # (using explicit default to override global argument_default)
1567  if self.add_help:
1568  self.add_argument(
1569  '-h', '--help', action='help', default=SUPPRESS,
1570  help=_('show this help message and exit'))
1571  if self.version:
1572  self.add_argument(
1573  '-v', '--version', action='version', default=SUPPRESS,
1574  help=_("show program's version number and exit"))
1575 
1576  # add parent arguments and defaults
1577  for parent in parents:
1578  self._add_container_actions(parent)
1579  try:
1580  defaults = parent._defaults
1581  except AttributeError:
1582  pass
1583  else:
1584  self._defaults.update(defaults)

Member Function Documentation

def argparse.ArgumentParser._add_action (   self,
  action 
)
private

Definition at line 1634 of file argparse.py.

References argparse.ArgumentParser._add_action().

1635  def _add_action(self, action):
1636  if action.option_strings:
1637  self._optionals._add_action(action)
1638  else:
1639  self._positionals._add_action(action)
1640  return action
def argparse.ArgumentParser._add_action (   self,
  action 
)
private

Definition at line 1667 of file argparse.py.

Referenced by argparse.ArgumentParser._add_action(), and python.rootplot.argparse._ActionsContainer.add_argument().

1668  def _add_action(self, action):
1669  if action.option_strings:
1670  self._optionals._add_action(action)
1671  else:
1672  self._positionals._add_action(action)
1673  return action
def argparse.ArgumentParser._check_value (   self,
  action,
  value 
)
private

Definition at line 2187 of file argparse.py.

References argparse.ArgumentParser._check_value(), join(), and python.multivaluedict.map().

2188  def _check_value(self, action, value):
2189  # converted value must be one of the choices (if specified)
2190  if action.choices is not None and value not in action.choices:
2191  tup = value, ', '.join(map(repr, action.choices))
2192  msg = _('invalid choice: %r (choose from %s)') % tup
2193  raise ArgumentError(action, msg)
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def argparse.ArgumentParser._check_value (   self,
  action,
  value 
)
private

Definition at line 2250 of file argparse.py.

References join(), and python.multivaluedict.map().

Referenced by argparse.ArgumentParser._check_value(), argparse.ArgumentParser._get_values(), and python.rootplot.argparse.ArgumentParser._get_values().

2251  def _check_value(self, action, value):
2252  # converted value must be one of the choices (if specified)
2253  if action.choices is not None and value not in action.choices:
2254  tup = value, ', '.join(map(repr, action.choices))
2255  msg = _('invalid choice: %r (choose from %s)') % tup
2256  raise ArgumentError(action, msg)
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def argparse.ArgumentParser._get_formatter (   self)
private

Definition at line 2231 of file argparse.py.

References argparse.ArgumentParser._get_formatter(), argparse.ArgumentParser.formatter_class, and argparse.ArgumentParser.prog.

Referenced by argparse._ActionsContainer.add_argument().

2232  def _get_formatter(self):
2233  return self.formatter_class(prog=self.prog)
def argparse.ArgumentParser._get_formatter (   self)
private

Definition at line 2299 of file argparse.py.

References argparse.ArgumentParser.formatter_class, and argparse.ArgumentParser.prog.

Referenced by argparse.ArgumentParser._get_formatter(), argparse._ActionsContainer.add_argument(), argparse.ArgumentParser.add_subparsers(), python.rootplot.argparse.ArgumentParser.add_subparsers(), argparse.ArgumentParser.format_help(), python.rootplot.argparse.ArgumentParser.format_help(), argparse.ArgumentParser.format_usage(), python.rootplot.argparse.ArgumentParser.format_usage(), argparse.ArgumentParser.format_version(), and python.rootplot.argparse.ArgumentParser.format_version().

2300  def _get_formatter(self):
2301  return self.formatter_class(prog=self.prog)
def argparse.ArgumentParser._get_kwargs (   self)
private

Definition at line 1588 of file argparse.py.

References argparse.ArgumentParser._get_kwargs().

1589  def _get_kwargs(self):
1590  names = [
1591  'prog',
1592  'usage',
1593  'description',
1594  'version',
1595  'formatter_class',
1596  'conflict_handler',
1597  'add_help',
1598  ]
1599  return [(name, getattr(self, name)) for name in names]
def argparse.ArgumentParser._get_kwargs (   self)
private

Definition at line 1621 of file argparse.py.

Referenced by python.rootplot.argparse._AttributeHolder.__repr__(), and argparse.ArgumentParser._get_kwargs().

1622  def _get_kwargs(self):
1623  names = [
1624  'prog',
1625  'usage',
1626  'description',
1627  'version',
1628  'formatter_class',
1629  'conflict_handler',
1630  'add_help',
1631  ]
1632  return [(name, getattr(self, name)) for name in names]
def argparse.ArgumentParser._get_nargs_pattern (   self,
  action 
)
private

Definition at line 2082 of file argparse.py.

References argparse.ArgumentParser._get_nargs_pattern(), and join().

2083  def _get_nargs_pattern(self, action):
2084  # in all examples below, we have to allow for '--' args
2085  # which are represented as '-' in the pattern
2086  nargs = action.nargs
2087 
2088  # the default (None) is assumed to be a single argument
2089  if nargs is None:
2090  nargs_pattern = '(-*A-*)'
2091 
2092  # allow zero or one arguments
2093  elif nargs == OPTIONAL:
2094  nargs_pattern = '(-*A?-*)'
2095 
2096  # allow zero or more arguments
2097  elif nargs == ZERO_OR_MORE:
2098  nargs_pattern = '(-*[A-]*)'
2099 
2100  # allow one or more arguments
2101  elif nargs == ONE_OR_MORE:
2102  nargs_pattern = '(-*A[A-]*)'
2103 
2104  # allow one argument followed by any number of options or arguments
2105  elif nargs is PARSER:
2106  nargs_pattern = '(-*A[-AO]*)'
2107 
2108  # all others should be integers
2109  else:
2110  nargs_pattern = '(-*%s-*)' % '-*'.join('A' * nargs)
2111 
2112  # if this is an optional action, -- is not allowed
2113  if action.option_strings:
2114  nargs_pattern = nargs_pattern.replace('-*', '')
2115  nargs_pattern = nargs_pattern.replace('-', '')
2116 
2117  # return the pattern
2118  return nargs_pattern
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def argparse.ArgumentParser._get_nargs_pattern (   self,
  action 
)
private

Definition at line 2132 of file argparse.py.

References join().

Referenced by argparse.ArgumentParser._get_nargs_pattern(), argparse.ArgumentParser._match_argument(), python.rootplot.argparse.ArgumentParser._match_argument(), argparse.ArgumentParser._match_arguments_partial(), and python.rootplot.argparse.ArgumentParser._match_arguments_partial().

2133  def _get_nargs_pattern(self, action):
2134  # in all examples below, we have to allow for '--' args
2135  # which are represented as '-' in the pattern
2136  nargs = action.nargs
2137 
2138  # the default (None) is assumed to be a single argument
2139  if nargs is None:
2140  nargs_pattern = '(-*A-*)'
2141 
2142  # allow zero or one arguments
2143  elif nargs == OPTIONAL:
2144  nargs_pattern = '(-*A?-*)'
2145 
2146  # allow zero or more arguments
2147  elif nargs == ZERO_OR_MORE:
2148  nargs_pattern = '(-*[A-]*)'
2149 
2150  # allow one or more arguments
2151  elif nargs == ONE_OR_MORE:
2152  nargs_pattern = '(-*A[A-]*)'
2153 
2154  # allow any number of options or arguments
2155  elif nargs == REMAINDER:
2156  nargs_pattern = '([-AO]*)'
2157 
2158  # allow one argument followed by any number of options or arguments
2159  elif nargs == PARSER:
2160  nargs_pattern = '(-*A[-AO]*)'
2161 
2162  # all others should be integers
2163  else:
2164  nargs_pattern = '(-*%s-*)' % '-*'.join('A' * nargs)
2165 
2166  # if this is an optional action, -- is not allowed
2167  if action.option_strings:
2168  nargs_pattern = nargs_pattern.replace('-*', '')
2169  nargs_pattern = nargs_pattern.replace('-', '')
2170 
2171  # return the pattern
2172  return nargs_pattern
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def argparse.ArgumentParser._get_option_tuples (   self,
  option_string 
)
private

Definition at line 2038 of file argparse.py.

References argparse.ArgumentParser._get_option_tuples(), argparse._ActionsContainer._option_string_actions, TreeStruct.error, MomentumConstraint.error, pat::MHT.error(), BinomialProbability.error(), EcalUncalibRecHitRatioMethodAlgo< C >::Ratio.error, CSCPairConstraint.error(), Measurement1DFloat.error(), SiStripLaserRecHit2D.error, EcalUncalibRecHitRatioMethodAlgo< C >::Tmax.error, SaxToDom.error(), Measurement1D.error(), SamplingAnalysis.error(), pat::LookupTableRecord.error(), SaxToDom2.error(), FedTimingAnalysis.error(), ApvTimingAnalysis.error(), CSCPairResidualsConstraint.error(), edm::HLTGlobalStatus.error(), edm::HLTPathStatus.error(), edm::TriggerResultsByName.error(), PTrajectoryStateOnDet.error(), PhysicsTools::Calibration::Histogram< Value_t, Axis_t >.error(), cscdqm::XMLFileErrorHandler.error(), lhef::LHERunInfo::XSec.error, PhysicsTools::Calibration::Histogram2D< Value_t, AxisX_t, AxisY_t >.error(), MuonErrorMatrix.error, DDLSAX2Handler.error(), SimpleSAXParser::ParserError.error(), PhysicsTools::Calibration::Histogram3D< Value_t, AxisX_t, AxisY_t, AxisZ_t >.error(), reco::Vertex.error(), CSCDCCExaminer.error(), reco::TrackBase.error(), MatacqTBRawEvent.error, jetTools.AddJetCollection.error, MatacqRawEvent.error, TiXmlDocument.error, argparse.ArgumentParser.error(), and argparse._ActionsContainer.prefix_chars.

2039  def _get_option_tuples(self, option_string):
2040  result = []
2041 
2042  # option strings starting with two prefix characters are only
2043  # split at the '='
2044  chars = self.prefix_chars
2045  if option_string[0] in chars and option_string[1] in chars:
2046  if '=' in option_string:
2047  option_prefix, explicit_arg = option_string.split('=', 1)
2048  else:
2049  option_prefix = option_string
2050  explicit_arg = None
2051  for option_string in self._option_string_actions:
2052  if option_string.startswith(option_prefix):
2053  action = self._option_string_actions[option_string]
2054  tup = action, option_string, explicit_arg
2055  result.append(tup)
2056 
2057  # single character options can be concatenated with their arguments
2058  # but multiple character options always have to have their argument
2059  # separate
2060  elif option_string[0] in chars and option_string[1] not in chars:
2061  option_prefix = option_string
2062  explicit_arg = None
2063  short_option_prefix = option_string[:2]
2064  short_explicit_arg = option_string[2:]
2065 
2066  for option_string in self._option_string_actions:
2067  if option_string == short_option_prefix:
2068  action = self._option_string_actions[option_string]
2069  tup = action, option_string, short_explicit_arg
2070  result.append(tup)
2071  elif option_string.startswith(option_prefix):
2072  action = self._option_string_actions[option_string]
2073  tup = action, option_string, explicit_arg
2074  result.append(tup)
2075 
2076  # shouldn't ever get here
2077  else:
2078  self.error(_('unexpected option string: %s') % option_string)
2079 
2080  # return the collected option tuples
2081  return result
def argparse.ArgumentParser._get_option_tuples (   self,
  option_string 
)
private

Definition at line 2088 of file argparse.py.

References argparse._ActionsContainer._option_string_actions, TreeStruct.error, MomentumConstraint.error, pat::MHT.error(), BinomialProbability.error(), EcalUncalibRecHitRatioMethodAlgo< C >::Ratio.error, CSCPairConstraint.error(), Measurement1DFloat.error(), SiStripLaserRecHit2D.error, EcalUncalibRecHitRatioMethodAlgo< C >::Tmax.error, SaxToDom.error(), Measurement1D.error(), SamplingAnalysis.error(), pat::LookupTableRecord.error(), SaxToDom2.error(), FedTimingAnalysis.error(), ApvTimingAnalysis.error(), CSCPairResidualsConstraint.error(), edm::HLTGlobalStatus.error(), edm::HLTPathStatus.error(), edm::TriggerResultsByName.error(), PTrajectoryStateOnDet.error(), PhysicsTools::Calibration::Histogram< Value_t, Axis_t >.error(), cscdqm::XMLFileErrorHandler.error(), lhef::LHERunInfo::XSec.error, PhysicsTools::Calibration::Histogram2D< Value_t, AxisX_t, AxisY_t >.error(), MuonErrorMatrix.error, DDLSAX2Handler.error(), SimpleSAXParser::ParserError.error(), PhysicsTools::Calibration::Histogram3D< Value_t, AxisX_t, AxisY_t, AxisZ_t >.error(), reco::Vertex.error(), CSCDCCExaminer.error(), reco::TrackBase.error(), MatacqTBRawEvent.error, jetTools.AddJetCollection.error, MatacqRawEvent.error, TiXmlDocument.error, argparse.ArgumentParser.error(), and argparse._ActionsContainer.prefix_chars.

Referenced by argparse.ArgumentParser._get_option_tuples(), argparse.ArgumentParser._parse_optional(), and python.rootplot.argparse.ArgumentParser._parse_optional().

2089  def _get_option_tuples(self, option_string):
2090  result = []
2091 
2092  # option strings starting with two prefix characters are only
2093  # split at the '='
2094  chars = self.prefix_chars
2095  if option_string[0] in chars and option_string[1] in chars:
2096  if '=' in option_string:
2097  option_prefix, explicit_arg = option_string.split('=', 1)
2098  else:
2099  option_prefix = option_string
2100  explicit_arg = None
2101  for option_string in self._option_string_actions:
2102  if option_string.startswith(option_prefix):
2103  action = self._option_string_actions[option_string]
2104  tup = action, option_string, explicit_arg
2105  result.append(tup)
2106 
2107  # single character options can be concatenated with their arguments
2108  # but multiple character options always have to have their argument
2109  # separate
2110  elif option_string[0] in chars and option_string[1] not in chars:
2111  option_prefix = option_string
2112  explicit_arg = None
2113  short_option_prefix = option_string[:2]
2114  short_explicit_arg = option_string[2:]
2115 
2116  for option_string in self._option_string_actions:
2117  if option_string == short_option_prefix:
2118  action = self._option_string_actions[option_string]
2119  tup = action, option_string, short_explicit_arg
2120  result.append(tup)
2121  elif option_string.startswith(option_prefix):
2122  action = self._option_string_actions[option_string]
2123  tup = action, option_string, explicit_arg
2124  result.append(tup)
2125 
2126  # shouldn't ever get here
2127  else:
2128  self.error(_('unexpected option string: %s') % option_string)
2129 
2130  # return the collected option tuples
2131  return result
def argparse.ArgumentParser._get_optional_actions (   self)
private

Definition at line 1641 of file argparse.py.

References argparse._ActionsContainer._actions, and argparse.ArgumentParser._get_optional_actions().

1642  def _get_optional_actions(self):
1643  return [action
1644  for action in self._actions
1645  if action.option_strings]
def argparse.ArgumentParser._get_optional_actions (   self)
private

Definition at line 1674 of file argparse.py.

References argparse._ActionsContainer._actions.

Referenced by argparse.ArgumentParser._get_optional_actions().

1675  def _get_optional_actions(self):
1676  return [action
1677  for action in self._actions
1678  if action.option_strings]
def argparse.ArgumentParser._get_positional_actions (   self)
private

Definition at line 1646 of file argparse.py.

References argparse._ActionsContainer._actions, and argparse.ArgumentParser._get_positional_actions().

1647  def _get_positional_actions(self):
1648  return [action
1649  for action in self._actions
1650  if not action.option_strings]
def argparse.ArgumentParser._get_positional_actions (   self)
private

Definition at line 1679 of file argparse.py.

References argparse._ActionsContainer._actions.

Referenced by argparse.ArgumentParser._get_positional_actions(), argparse.ArgumentParser._parse_known_args(), python.rootplot.argparse.ArgumentParser._parse_known_args(), argparse.ArgumentParser.add_subparsers(), and python.rootplot.argparse.ArgumentParser.add_subparsers().

1680  def _get_positional_actions(self):
1681  return [action
1682  for action in self._actions
1683  if not action.option_strings]
def argparse.ArgumentParser._get_value (   self,
  action,
  arg_string 
)
private

Definition at line 2167 of file argparse.py.

References argparse.ArgumentParser._get_value(), and argparse._ActionsContainer._registry_get().

2168  def _get_value(self, action, arg_string):
2169  type_func = self._registry_get('type', action.type, action.type)
2170  if not hasattr(type_func, '__call__'):
2171  if not hasattr(type_func, '__bases__'): # classic classes
2172  msg = _('%r is not callable')
2173  raise ArgumentError(action, msg % type_func)
2174 
2175  # convert the value to the appropriate type
2176  try:
2177  result = type_func(arg_string)
2178 
2179  # TypeErrors or ValueErrors indicate errors
2180  except (TypeError, ValueError):
2181  name = getattr(action.type, '__name__', repr(action.type))
2182  msg = _('invalid %s value: %r')
2183  raise ArgumentError(action, msg % (name, arg_string))
2184 
2185  # return the converted value
2186  return result
def argparse.ArgumentParser._get_value (   self,
  action,
  arg_string 
)
private

Definition at line 2225 of file argparse.py.

References argparse._callable(), and argparse._ActionsContainer._registry_get().

Referenced by argparse.ArgumentParser._get_value(), argparse.ArgumentParser._get_values(), python.rootplot.argparse.ArgumentParser._get_values(), argparse.ArgumentParser.parse_known_args(), and python.rootplot.argparse.ArgumentParser.parse_known_args().

2226  def _get_value(self, action, arg_string):
2227  type_func = self._registry_get('type', action.type, action.type)
2228  if not _callable(type_func):
2229  msg = _('%r is not callable')
2230  raise ArgumentError(action, msg % type_func)
2231 
2232  # convert the value to the appropriate type
2233  try:
2234  result = type_func(arg_string)
2235 
2236  # ArgumentTypeErrors indicate errors
2237  except ArgumentTypeError:
2238  name = getattr(action.type, '__name__', repr(action.type))
2239  msg = str(_sys.exc_info()[1])
2240  raise ArgumentError(action, msg)
2241 
2242  # TypeErrors or ValueErrors also indicate errors
2243  except (TypeError, ValueError):
2244  name = getattr(action.type, '__name__', repr(action.type))
2245  msg = _('invalid %s value: %r')
2246  raise ArgumentError(action, msg % (name, arg_string))
2247 
2248  # return the converted value
2249  return result
def _callable
Definition: argparse.py:95
def argparse.ArgumentParser._get_values (   self,
  action,
  arg_strings 
)
private

Definition at line 2122 of file argparse.py.

References argparse.ArgumentParser._check_value(), argparse.ArgumentParser._get_value(), and argparse.ArgumentParser._get_values().

2123  def _get_values(self, action, arg_strings):
2124  # for everything but PARSER args, strip out '--'
2125  if action.nargs is not PARSER:
2126  arg_strings = [s for s in arg_strings if s != '--']
2127 
2128  # optional argument produces a default when not present
2129  if not arg_strings and action.nargs == OPTIONAL:
2130  if action.option_strings:
2131  value = action.const
2132  else:
2133  value = action.default
2134  if isinstance(value, _basestring):
2135  value = self._get_value(action, value)
2136  self._check_value(action, value)
2137 
2138  # when nargs='*' on a positional, if there were no command-line
2139  # args, use the default if it is anything other than None
2140  elif (not arg_strings and action.nargs == ZERO_OR_MORE and
2141  not action.option_strings):
2142  if action.default is not None:
2143  value = action.default
2144  else:
2145  value = arg_strings
2146  self._check_value(action, value)
2147 
2148  # single argument or optional argument produces a single value
2149  elif len(arg_strings) == 1 and action.nargs in [None, OPTIONAL]:
2150  arg_string, = arg_strings
2151  value = self._get_value(action, arg_string)
2152  self._check_value(action, value)
2153 
2154  # PARSER arguments convert all values, but check only the first
2155  elif action.nargs is PARSER:
2156  value = [self._get_value(action, v) for v in arg_strings]
2157  self._check_value(action, value[0])
2158 
2159  # all other types of nargs produce a list
2160  else:
2161  value = [self._get_value(action, v) for v in arg_strings]
2162  for v in value:
2163  self._check_value(action, v)
2164 
2165  # return the converted value
2166  return value
def argparse.ArgumentParser._get_values (   self,
  action,
  arg_strings 
)
private

Definition at line 2176 of file argparse.py.

References argparse.ArgumentParser._check_value(), and argparse.ArgumentParser._get_value().

Referenced by argparse.ArgumentParser._get_values(), argparse.ArgumentParser._parse_known_args(), and python.rootplot.argparse.ArgumentParser._parse_known_args().

2177  def _get_values(self, action, arg_strings):
2178  # for everything but PARSER args, strip out '--'
2179  if action.nargs not in [PARSER, REMAINDER]:
2180  arg_strings = [s for s in arg_strings if s != '--']
2181 
2182  # optional argument produces a default when not present
2183  if not arg_strings and action.nargs == OPTIONAL:
2184  if action.option_strings:
2185  value = action.const
2186  else:
2187  value = action.default
2188  if isinstance(value, basestring):
2189  value = self._get_value(action, value)
2190  self._check_value(action, value)
2191 
2192  # when nargs='*' on a positional, if there were no command-line
2193  # args, use the default if it is anything other than None
2194  elif (not arg_strings and action.nargs == ZERO_OR_MORE and
2195  not action.option_strings):
2196  if action.default is not None:
2197  value = action.default
2198  else:
2199  value = arg_strings
2200  self._check_value(action, value)
2201 
2202  # single argument or optional argument produces a single value
2203  elif len(arg_strings) == 1 and action.nargs in [None, OPTIONAL]:
2204  arg_string, = arg_strings
2205  value = self._get_value(action, arg_string)
2206  self._check_value(action, value)
2207 
2208  # REMAINDER arguments convert all values, checking none
2209  elif action.nargs == REMAINDER:
2210  value = [self._get_value(action, v) for v in arg_strings]
2211 
2212  # PARSER arguments convert all values, but check only the first
2213  elif action.nargs == PARSER:
2214  value = [self._get_value(action, v) for v in arg_strings]
2215  self._check_value(action, value[0])
2216 
2217  # all other types of nargs produce a list
2218  else:
2219  value = [self._get_value(action, v) for v in arg_strings]
2220  for v in value:
2221  self._check_value(action, v)
2222 
2223  # return the converted value
2224  return value
def argparse.ArgumentParser._match_argument (   self,
  action,
  arg_strings_pattern 
)
private

Definition at line 1953 of file argparse.py.

References argparse.ArgumentParser._get_nargs_pattern(), and argparse.ArgumentParser._match_argument().

1954  def _match_argument(self, action, arg_strings_pattern):
1955  # match the pattern for this action to the arg strings
1956  nargs_pattern = self._get_nargs_pattern(action)
1957  match = _re.match(nargs_pattern, arg_strings_pattern)
1958 
1959  # raise an exception if we weren't able to find a match
1960  if match is None:
1961  nargs_errors = {
1962  None: _('expected one argument'),
1963  OPTIONAL: _('expected at most one argument'),
1964  ONE_OR_MORE: _('expected at least one argument'),
1965  }
1966  default = _('expected %s argument(s)') % action.nargs
1967  msg = nargs_errors.get(action.nargs, default)
1968  raise ArgumentError(action, msg)
1969 
1970  # return the number of arguments matched
1971  return len(match.group(1))
def argparse.ArgumentParser._match_argument (   self,
  action,
  arg_strings_pattern 
)
private

Definition at line 1996 of file argparse.py.

References argparse.ArgumentParser._get_nargs_pattern().

Referenced by argparse.ArgumentParser._match_argument(), argparse.ArgumentParser._parse_known_args(), and python.rootplot.argparse.ArgumentParser._parse_known_args().

1997  def _match_argument(self, action, arg_strings_pattern):
1998  # match the pattern for this action to the arg strings
1999  nargs_pattern = self._get_nargs_pattern(action)
2000  match = _re.match(nargs_pattern, arg_strings_pattern)
2001 
2002  # raise an exception if we weren't able to find a match
2003  if match is None:
2004  nargs_errors = {
2005  None: _('expected one argument'),
2006  OPTIONAL: _('expected at most one argument'),
2007  ONE_OR_MORE: _('expected at least one argument'),
2008  }
2009  default = _('expected %s argument(s)') % action.nargs
2010  msg = nargs_errors.get(action.nargs, default)
2011  raise ArgumentError(action, msg)
2012 
2013  # return the number of arguments matched
2014  return len(match.group(1))
def argparse.ArgumentParser._match_arguments_partial (   self,
  actions,
  arg_strings_pattern 
)
private

Definition at line 1972 of file argparse.py.

References argparse.ArgumentParser._get_nargs_pattern(), argparse.ArgumentParser._match_arguments_partial(), and join().

1973  def _match_arguments_partial(self, actions, arg_strings_pattern):
1974  # progressively shorten the actions list by slicing off the
1975  # final actions until we find a match
1976  result = []
1977  for i in range(len(actions), 0, -1):
1978  actions_slice = actions[:i]
1979  pattern = ''.join([self._get_nargs_pattern(action)
1980  for action in actions_slice])
1981  match = _re.match(pattern, arg_strings_pattern)
1982  if match is not None:
1983  result.extend([len(string) for string in match.groups()])
1984  break
1985 
1986  # return the list of arg string counts
1987  return result
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def argparse.ArgumentParser._match_arguments_partial (   self,
  actions,
  arg_strings_pattern 
)
private

Definition at line 2015 of file argparse.py.

References argparse.ArgumentParser._get_nargs_pattern(), and join().

Referenced by argparse.ArgumentParser._match_arguments_partial(), argparse.ArgumentParser._parse_known_args(), and python.rootplot.argparse.ArgumentParser._parse_known_args().

2016  def _match_arguments_partial(self, actions, arg_strings_pattern):
2017  # progressively shorten the actions list by slicing off the
2018  # final actions until we find a match
2019  result = []
2020  for i in range(len(actions), 0, -1):
2021  actions_slice = actions[:i]
2022  pattern = ''.join([self._get_nargs_pattern(action)
2023  for action in actions_slice])
2024  match = _re.match(pattern, arg_strings_pattern)
2025  if match is not None:
2026  result.extend([len(string) for string in match.groups()])
2027  break
2028 
2029  # return the list of arg string counts
2030  return result
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def argparse.ArgumentParser._parse_known_args (   self,
  arg_strings,
  namespace 
)
private

Definition at line 1692 of file argparse.py.

References argparse._ActionsContainer._actions, argparse._get_action_name(), argparse.ArgumentParser._get_positional_actions(), argparse.ArgumentParser._get_values(), argparse.ArgumentParser._match_argument(), argparse.ArgumentParser._match_arguments_partial(), argparse._ActionsContainer._mutually_exclusive_groups, argparse._ActionsContainer._option_string_actions, argparse.ArgumentParser._parse_known_args(), argparse.ArgumentParser._parse_optional(), argparse.ArgumentParser._read_args_from_files(), argparse._set, argparse.action, TreeStruct.error, MomentumConstraint.error, pat::MHT.error(), BinomialProbability.error(), EcalUncalibRecHitRatioMethodAlgo< C >::Ratio.error, CSCPairConstraint.error(), Measurement1DFloat.error(), SiStripLaserRecHit2D.error, EcalUncalibRecHitRatioMethodAlgo< C >::Tmax.error, Measurement1D.error(), SaxToDom.error(), SamplingAnalysis.error(), pat::LookupTableRecord.error(), SaxToDom2.error(), FedTimingAnalysis.error(), ApvTimingAnalysis.error(), CSCPairResidualsConstraint.error(), edm::HLTGlobalStatus.error(), edm::HLTPathStatus.error(), edm::TriggerResultsByName.error(), PTrajectoryStateOnDet.error(), PhysicsTools::Calibration::Histogram< Value_t, Axis_t >.error(), cscdqm::XMLFileErrorHandler.error(), lhef::LHERunInfo::XSec.error, PhysicsTools::Calibration::Histogram2D< Value_t, AxisX_t, AxisY_t >.error(), MuonErrorMatrix.error, DDLSAX2Handler.error(), SimpleSAXParser::ParserError.error(), PhysicsTools::Calibration::Histogram3D< Value_t, AxisX_t, AxisY_t, AxisZ_t >.error(), reco::Vertex.error(), CSCDCCExaminer.error(), reco::TrackBase.error(), MatacqTBRawEvent.error, jetTools.AddJetCollection.error, MatacqRawEvent.error, TiXmlDocument.error, argparse.ArgumentParser.error(), argparse.ArgumentParser.fromfile_prefix_chars, join(), max(), bookConverter.min, and argparse._ActionsContainer.prefix_chars.

1693  def _parse_known_args(self, arg_strings, namespace):
1694  # replace arg strings that are file references
1695  if self.fromfile_prefix_chars is not None:
1696  arg_strings = self._read_args_from_files(arg_strings)
1697 
1698  # map all mutually exclusive arguments to the other arguments
1699  # they can't occur with
1700  action_conflicts = {}
1701  for mutex_group in self._mutually_exclusive_groups:
1702  group_actions = mutex_group._group_actions
1703  for i, mutex_action in enumerate(mutex_group._group_actions):
1704  conflicts = action_conflicts.setdefault(mutex_action, [])
1705  conflicts.extend(group_actions[:i])
1706  conflicts.extend(group_actions[i + 1:])
1707 
1708  # find all option indices, and determine the arg_string_pattern
1709  # which has an 'O' if there is an option at an index,
1710  # an 'A' if there is an argument, or a '-' if there is a '--'
1711  option_string_indices = {}
1712  arg_string_pattern_parts = []
1713  arg_strings_iter = iter(arg_strings)
1714  for i, arg_string in enumerate(arg_strings_iter):
1715 
1716  # all args after -- are non-options
1717  if arg_string == '--':
1718  arg_string_pattern_parts.append('-')
1719  for arg_string in arg_strings_iter:
1720  arg_string_pattern_parts.append('A')
1721 
1722  # otherwise, add the arg to the arg strings
1723  # and note the index if it was an option
1724  else:
1725  option_tuple = self._parse_optional(arg_string)
1726  if option_tuple is None:
1727  pattern = 'A'
1728  else:
1729  option_string_indices[i] = option_tuple
1730  pattern = 'O'
1731  arg_string_pattern_parts.append(pattern)
1732 
1733  # join the pieces together to form the pattern
1734  arg_strings_pattern = ''.join(arg_string_pattern_parts)
1735 
1736  # converts arg strings to the appropriate and then takes the action
1737  seen_actions = _set()
1738  seen_non_default_actions = _set()
1739 
1740  def take_action(action, argument_strings, option_string=None):
1741  seen_actions.add(action)
1742  argument_values = self._get_values(action, argument_strings)
1743 
1744  # error if this argument is not allowed with other previously
1745  # seen arguments, assuming that actions that use the default
1746  # value don't really count as "present"
1747  if argument_values is not action.default:
1748  seen_non_default_actions.add(action)
1749  for conflict_action in action_conflicts.get(action, []):
1750  if conflict_action in seen_non_default_actions:
1751  msg = _('not allowed with argument %s')
1752  action_name = _get_action_name(conflict_action)
1753  raise ArgumentError(action, msg % action_name)
1754 
1755  # take the action if we didn't receive a SUPPRESS value
1756  # (e.g. from a default)
1757  if argument_values is not SUPPRESS:
1758  action(self, namespace, argument_values, option_string)
1759 
1760  # function to convert arg_strings into an optional action
1761  def consume_optional(start_index):
1762 
1763  # get the optional identified at this index
1764  option_tuple = option_string_indices[start_index]
1765  action, option_string, explicit_arg = option_tuple
1766 
1767  # identify additional optionals in the same arg string
1768  # (e.g. -xyz is the same as -x -y -z if no args are required)
1769  match_argument = self._match_argument
1770  action_tuples = []
1771  while True:
1772 
1773  # if we found no optional action, skip it
1774  if action is None:
1775  extras.append(arg_strings[start_index])
1776  return start_index + 1
1777 
1778  # if there is an explicit argument, try to match the
1779  # optional's string arguments to only this
1780  if explicit_arg is not None:
1781  arg_count = match_argument(action, 'A')
1782 
1783  # if the action is a single-dash option and takes no
1784  # arguments, try to parse more single-dash options out
1785  # of the tail of the option string
1786  chars = self.prefix_chars
1787  if arg_count == 0 and option_string[1] not in chars:
1788  action_tuples.append((action, [], option_string))
1789  for char in self.prefix_chars:
1790  option_string = char + explicit_arg[0]
1791  explicit_arg = explicit_arg[1:] or None
1792  optionals_map = self._option_string_actions
1793  if option_string in optionals_map:
1794  action = optionals_map[option_string]
1795  break
1796  else:
1797  msg = _('ignored explicit argument %r')
1798  raise ArgumentError(action, msg % explicit_arg)
1799 
1800  # if the action expect exactly one argument, we've
1801  # successfully matched the option; exit the loop
1802  elif arg_count == 1:
1803  stop = start_index + 1
1804  args = [explicit_arg]
1805  action_tuples.append((action, args, option_string))
1806  break
1807 
1808  # error if a double-dash option did not use the
1809  # explicit argument
1810  else:
1811  msg = _('ignored explicit argument %r')
1812  raise ArgumentError(action, msg % explicit_arg)
1813 
1814  # if there is no explicit argument, try to match the
1815  # optional's string arguments with the following strings
1816  # if successful, exit the loop
1817  else:
1818  start = start_index + 1
1819  selected_patterns = arg_strings_pattern[start:]
1820  arg_count = match_argument(action, selected_patterns)
1821  stop = start + arg_count
1822  args = arg_strings[start:stop]
1823  action_tuples.append((action, args, option_string))
1824  break
1825 
1826  # add the Optional to the list and return the index at which
1827  # the Optional's string args stopped
1828  assert action_tuples
1829  for action, args, option_string in action_tuples:
1830  take_action(action, args, option_string)
1831  return stop
1832 
1833  # the list of Positionals left to be parsed; this is modified
1834  # by consume_positionals()
1835  positionals = self._get_positional_actions()
1836 
1837  # function to convert arg_strings into positional actions
1838  def consume_positionals(start_index):
1839  # match as many Positionals as possible
1840  match_partial = self._match_arguments_partial
1841  selected_pattern = arg_strings_pattern[start_index:]
1842  arg_counts = match_partial(positionals, selected_pattern)
1843 
1844  # slice off the appropriate arg strings for each Positional
1845  # and add the Positional and its args to the list
1846  for action, arg_count in zip(positionals, arg_counts):
1847  args = arg_strings[start_index: start_index + arg_count]
1848  start_index += arg_count
1849  take_action(action, args)
1850 
1851  # slice off the Positionals that we just parsed and return the
1852  # index at which the Positionals' string args stopped
1853  positionals[:] = positionals[len(arg_counts):]
1854  return start_index
1855 
1856  # consume Positionals and Optionals alternately, until we have
1857  # passed the last option string
1858  extras = []
1859  start_index = 0
1860  if option_string_indices:
1861  max_option_string_index = max(option_string_indices)
1862  else:
1863  max_option_string_index = -1
1864  while start_index <= max_option_string_index:
1865 
1866  # consume any Positionals preceding the next option
1867  next_option_string_index = min([
1868  index
1869  for index in option_string_indices
1870  if index >= start_index])
1871  if start_index != next_option_string_index:
1872  positionals_end_index = consume_positionals(start_index)
1873 
1874  # only try to parse the next optional if we didn't consume
1875  # the option string during the positionals parsing
1876  if positionals_end_index > start_index:
1877  start_index = positionals_end_index
1878  continue
1879  else:
1880  start_index = positionals_end_index
1881 
1882  # if we consumed all the positionals we could and we're not
1883  # at the index of an option string, there were extra arguments
1884  if start_index not in option_string_indices:
1885  strings = arg_strings[start_index:next_option_string_index]
1886  extras.extend(strings)
1887  start_index = next_option_string_index
1888 
1889  # consume the next optional and any arguments for it
1890  start_index = consume_optional(start_index)
1891 
1892  # consume any positionals following the last Optional
1893  stop_index = consume_positionals(start_index)
1894 
1895  # if we didn't consume all the argument strings, there were extras
1896  extras.extend(arg_strings[stop_index:])
1897 
1898  # if we didn't use all the Positional objects, there were too few
1899  # arg strings supplied.
1900  if positionals:
1901  self.error(_('too few arguments'))
1902 
1903  # make sure all required actions were present
1904  for action in self._actions:
1905  if action.required:
1906  if action not in seen_actions:
1907  name = _get_action_name(action)
1908  self.error(_('argument %s is required') % name)
1909 
1910  # make sure all required groups had one option present
1911  for group in self._mutually_exclusive_groups:
1912  if group.required:
1913  for action in group._group_actions:
1914  if action in seen_non_default_actions:
1915  break
1916 
1917  # if no actions were used, report the error
1918  else:
1919  names = [_get_action_name(action)
1920  for action in group._group_actions
1921  if action.help is not SUPPRESS]
1922  msg = _('one of the arguments %s is required')
1923  self.error(msg % ' '.join(names))
1924 
1925  # return the updated namespace and the extra arguments
1926  return namespace, extras
const T & max(const T &a, const T &b)
string action
Definition: argparse.py:125
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def _get_action_name
Definition: argparse.py:670
def argparse.ArgumentParser._parse_known_args (   self,
  arg_strings,
  namespace 
)
private

Definition at line 1729 of file argparse.py.

References argparse._ActionsContainer._actions, argparse._get_action_name(), argparse.ArgumentParser._get_positional_actions(), argparse.ArgumentParser._get_values(), argparse.ArgumentParser._match_argument(), argparse.ArgumentParser._match_arguments_partial(), argparse._ActionsContainer._mutually_exclusive_groups, argparse._ActionsContainer._option_string_actions, argparse.ArgumentParser._parse_optional(), argparse.ArgumentParser._read_args_from_files(), argparse.action, TreeStruct.error, MomentumConstraint.error, pat::MHT.error(), BinomialProbability.error(), EcalUncalibRecHitRatioMethodAlgo< C >::Ratio.error, CSCPairConstraint.error(), Measurement1DFloat.error(), SiStripLaserRecHit2D.error, EcalUncalibRecHitRatioMethodAlgo< C >::Tmax.error, Measurement1D.error(), SaxToDom.error(), SamplingAnalysis.error(), pat::LookupTableRecord.error(), SaxToDom2.error(), FedTimingAnalysis.error(), ApvTimingAnalysis.error(), CSCPairResidualsConstraint.error(), edm::HLTGlobalStatus.error(), edm::HLTPathStatus.error(), edm::TriggerResultsByName.error(), PTrajectoryStateOnDet.error(), PhysicsTools::Calibration::Histogram< Value_t, Axis_t >.error(), cscdqm::XMLFileErrorHandler.error(), lhef::LHERunInfo::XSec.error, PhysicsTools::Calibration::Histogram2D< Value_t, AxisX_t, AxisY_t >.error(), MuonErrorMatrix.error, DDLSAX2Handler.error(), SimpleSAXParser::ParserError.error(), PhysicsTools::Calibration::Histogram3D< Value_t, AxisX_t, AxisY_t, AxisZ_t >.error(), reco::Vertex.error(), CSCDCCExaminer.error(), reco::TrackBase.error(), MatacqTBRawEvent.error, jetTools.AddJetCollection.error, MatacqRawEvent.error, TiXmlDocument.error, argparse.ArgumentParser.error(), argparse.ArgumentParser.fromfile_prefix_chars, join(), max(), bookConverter.min, and argparse._ActionsContainer.prefix_chars.

Referenced by argparse.ArgumentParser._parse_known_args(), argparse.ArgumentParser.parse_known_args(), and python.rootplot.argparse.ArgumentParser.parse_known_args().

1730  def _parse_known_args(self, arg_strings, namespace):
1731  # replace arg strings that are file references
1732  if self.fromfile_prefix_chars is not None:
1733  arg_strings = self._read_args_from_files(arg_strings)
1734 
1735  # map all mutually exclusive arguments to the other arguments
1736  # they can't occur with
1737  action_conflicts = {}
1738  for mutex_group in self._mutually_exclusive_groups:
1739  group_actions = mutex_group._group_actions
1740  for i, mutex_action in enumerate(mutex_group._group_actions):
1741  conflicts = action_conflicts.setdefault(mutex_action, [])
1742  conflicts.extend(group_actions[:i])
1743  conflicts.extend(group_actions[i + 1:])
1744 
1745  # find all option indices, and determine the arg_string_pattern
1746  # which has an 'O' if there is an option at an index,
1747  # an 'A' if there is an argument, or a '-' if there is a '--'
1748  option_string_indices = {}
1749  arg_string_pattern_parts = []
1750  arg_strings_iter = iter(arg_strings)
1751  for i, arg_string in enumerate(arg_strings_iter):
1752 
1753  # all args after -- are non-options
1754  if arg_string == '--':
1755  arg_string_pattern_parts.append('-')
1756  for arg_string in arg_strings_iter:
1757  arg_string_pattern_parts.append('A')
1758 
1759  # otherwise, add the arg to the arg strings
1760  # and note the index if it was an option
1761  else:
1762  option_tuple = self._parse_optional(arg_string)
1763  if option_tuple is None:
1764  pattern = 'A'
1765  else:
1766  option_string_indices[i] = option_tuple
1767  pattern = 'O'
1768  arg_string_pattern_parts.append(pattern)
1769 
1770  # join the pieces together to form the pattern
1771  arg_strings_pattern = ''.join(arg_string_pattern_parts)
1772 
1773  # converts arg strings to the appropriate and then takes the action
1774  seen_actions = set()
1775  seen_non_default_actions = set()
1776 
1777  def take_action(action, argument_strings, option_string=None):
1778  seen_actions.add(action)
1779  argument_values = self._get_values(action, argument_strings)
1780 
1781  # error if this argument is not allowed with other previously
1782  # seen arguments, assuming that actions that use the default
1783  # value don't really count as "present"
1784  if argument_values is not action.default:
1785  seen_non_default_actions.add(action)
1786  for conflict_action in action_conflicts.get(action, []):
1787  if conflict_action in seen_non_default_actions:
1788  msg = _('not allowed with argument %s')
1789  action_name = _get_action_name(conflict_action)
1790  raise ArgumentError(action, msg % action_name)
1791 
1792  # take the action if we didn't receive a SUPPRESS value
1793  # (e.g. from a default)
1794  if argument_values is not SUPPRESS:
1795  action(self, namespace, argument_values, option_string)
1796 
1797  # function to convert arg_strings into an optional action
1798  def consume_optional(start_index):
1799 
1800  # get the optional identified at this index
1801  option_tuple = option_string_indices[start_index]
1802  action, option_string, explicit_arg = option_tuple
1803 
1804  # identify additional optionals in the same arg string
1805  # (e.g. -xyz is the same as -x -y -z if no args are required)
1806  match_argument = self._match_argument
1807  action_tuples = []
1808  while True:
1809 
1810  # if we found no optional action, skip it
1811  if action is None:
1812  extras.append(arg_strings[start_index])
1813  return start_index + 1
1814 
1815  # if there is an explicit argument, try to match the
1816  # optional's string arguments to only this
1817  if explicit_arg is not None:
1818  arg_count = match_argument(action, 'A')
1819 
1820  # if the action is a single-dash option and takes no
1821  # arguments, try to parse more single-dash options out
1822  # of the tail of the option string
1823  chars = self.prefix_chars
1824  if arg_count == 0 and option_string[1] not in chars:
1825  action_tuples.append((action, [], option_string))
1826  char = option_string[0]
1827  option_string = char + explicit_arg[0]
1828  new_explicit_arg = explicit_arg[1:] or None
1829  optionals_map = self._option_string_actions
1830  if option_string in optionals_map:
1831  action = optionals_map[option_string]
1832  explicit_arg = new_explicit_arg
1833  else:
1834  msg = _('ignored explicit argument %r')
1835  raise ArgumentError(action, msg % explicit_arg)
1836 
1837  # if the action expect exactly one argument, we've
1838  # successfully matched the option; exit the loop
1839  elif arg_count == 1:
1840  stop = start_index + 1
1841  args = [explicit_arg]
1842  action_tuples.append((action, args, option_string))
1843  break
1844 
1845  # error if a double-dash option did not use the
1846  # explicit argument
1847  else:
1848  msg = _('ignored explicit argument %r')
1849  raise ArgumentError(action, msg % explicit_arg)
1850 
1851  # if there is no explicit argument, try to match the
1852  # optional's string arguments with the following strings
1853  # if successful, exit the loop
1854  else:
1855  start = start_index + 1
1856  selected_patterns = arg_strings_pattern[start:]
1857  arg_count = match_argument(action, selected_patterns)
1858  stop = start + arg_count
1859  args = arg_strings[start:stop]
1860  action_tuples.append((action, args, option_string))
1861  break
1862 
1863  # add the Optional to the list and return the index at which
1864  # the Optional's string args stopped
1865  assert action_tuples
1866  for action, args, option_string in action_tuples:
1867  take_action(action, args, option_string)
1868  return stop
1869 
1870  # the list of Positionals left to be parsed; this is modified
1871  # by consume_positionals()
1872  positionals = self._get_positional_actions()
1873 
1874  # function to convert arg_strings into positional actions
1875  def consume_positionals(start_index):
1876  # match as many Positionals as possible
1877  match_partial = self._match_arguments_partial
1878  selected_pattern = arg_strings_pattern[start_index:]
1879  arg_counts = match_partial(positionals, selected_pattern)
1880 
1881  # slice off the appropriate arg strings for each Positional
1882  # and add the Positional and its args to the list
1883  for action, arg_count in zip(positionals, arg_counts):
1884  args = arg_strings[start_index: start_index + arg_count]
1885  start_index += arg_count
1886  take_action(action, args)
1887 
1888  # slice off the Positionals that we just parsed and return the
1889  # index at which the Positionals' string args stopped
1890  positionals[:] = positionals[len(arg_counts):]
1891  return start_index
1892 
1893  # consume Positionals and Optionals alternately, until we have
1894  # passed the last option string
1895  extras = []
1896  start_index = 0
1897  if option_string_indices:
1898  max_option_string_index = max(option_string_indices)
1899  else:
1900  max_option_string_index = -1
1901  while start_index <= max_option_string_index:
1902 
1903  # consume any Positionals preceding the next option
1904  next_option_string_index = min([
1905  index
1906  for index in option_string_indices
1907  if index >= start_index])
1908  if start_index != next_option_string_index:
1909  positionals_end_index = consume_positionals(start_index)
1910 
1911  # only try to parse the next optional if we didn't consume
1912  # the option string during the positionals parsing
1913  if positionals_end_index > start_index:
1914  start_index = positionals_end_index
1915  continue
1916  else:
1917  start_index = positionals_end_index
1918 
1919  # if we consumed all the positionals we could and we're not
1920  # at the index of an option string, there were extra arguments
1921  if start_index not in option_string_indices:
1922  strings = arg_strings[start_index:next_option_string_index]
1923  extras.extend(strings)
1924  start_index = next_option_string_index
1925 
1926  # consume the next optional and any arguments for it
1927  start_index = consume_optional(start_index)
1928 
1929  # consume any positionals following the last Optional
1930  stop_index = consume_positionals(start_index)
1931 
1932  # if we didn't consume all the argument strings, there were extras
1933  extras.extend(arg_strings[stop_index:])
1934 
1935  # if we didn't use all the Positional objects, there were too few
1936  # arg strings supplied.
1937  if positionals:
1938  self.error(_('too few arguments'))
1939 
1940  # make sure all required actions were present
1941  for action in self._actions:
1942  if action.required:
1943  if action not in seen_actions:
1944  name = _get_action_name(action)
1945  self.error(_('argument %s is required') % name)
1946 
1947  # make sure all required groups had one option present
1948  for group in self._mutually_exclusive_groups:
1949  if group.required:
1950  for action in group._group_actions:
1951  if action in seen_non_default_actions:
1952  break
1953 
1954  # if no actions were used, report the error
1955  else:
1956  names = [_get_action_name(action)
1957  for action in group._group_actions
1958  if action.help is not SUPPRESS]
1959  msg = _('one of the arguments %s is required')
1960  self.error(msg % ' '.join(names))
1961 
1962  # return the updated namespace and the extra arguments
1963  return namespace, extras
const T & max(const T &a, const T &b)
string action
Definition: argparse.py:125
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def _get_action_name
Definition: argparse.py:670
def argparse.ArgumentParser._parse_optional (   self,
  arg_string 
)
private

Definition at line 1988 of file argparse.py.

References argparse.ArgumentParser._get_option_tuples(), argparse._ActionsContainer._has_negative_number_optionals, argparse._ActionsContainer._option_string_actions, argparse.ArgumentParser._parse_optional(), TreeStruct.error, MomentumConstraint.error, pat::MHT.error(), BinomialProbability.error(), CSCPairConstraint.error(), EcalUncalibRecHitRatioMethodAlgo< C >::Ratio.error, Measurement1DFloat.error(), SiStripLaserRecHit2D.error, EcalUncalibRecHitRatioMethodAlgo< C >::Tmax.error, SaxToDom.error(), Measurement1D.error(), SamplingAnalysis.error(), pat::LookupTableRecord.error(), SaxToDom2.error(), FedTimingAnalysis.error(), ApvTimingAnalysis.error(), CSCPairResidualsConstraint.error(), edm::HLTGlobalStatus.error(), edm::HLTPathStatus.error(), edm::TriggerResultsByName.error(), PTrajectoryStateOnDet.error(), PhysicsTools::Calibration::Histogram< Value_t, Axis_t >.error(), cscdqm::XMLFileErrorHandler.error(), lhef::LHERunInfo::XSec.error, PhysicsTools::Calibration::Histogram2D< Value_t, AxisX_t, AxisY_t >.error(), MuonErrorMatrix.error, DDLSAX2Handler.error(), SimpleSAXParser::ParserError.error(), PhysicsTools::Calibration::Histogram3D< Value_t, AxisX_t, AxisY_t, AxisZ_t >.error(), reco::Vertex.error(), CSCDCCExaminer.error(), reco::TrackBase.error(), MatacqTBRawEvent.error, jetTools.AddJetCollection.error, MatacqRawEvent.error, TiXmlDocument.error, argparse.ArgumentParser.error(), join(), and argparse._ActionsContainer.prefix_chars.

1989  def _parse_optional(self, arg_string):
1990  # if it's an empty string, it was meant to be a positional
1991  if not arg_string:
1992  return None
1993 
1994  # if it doesn't start with a prefix, it was meant to be positional
1995  if not arg_string[0] in self.prefix_chars:
1996  return None
1997 
1998  # if it's just dashes, it was meant to be positional
1999  if not arg_string.strip('-'):
2000  return None
2001 
2002  # if the option string is present in the parser, return the action
2003  if arg_string in self._option_string_actions:
2004  action = self._option_string_actions[arg_string]
2005  return action, arg_string, None
2006 
2007  # search through all possible prefixes of the option string
2008  # and all actions in the parser for possible interpretations
2009  option_tuples = self._get_option_tuples(arg_string)
2010 
2011  # if multiple actions match, the option string was ambiguous
2012  if len(option_tuples) > 1:
2013  options = ', '.join([option_string
2014  for action, option_string, explicit_arg in option_tuples])
2015  tup = arg_string, options
2016  self.error(_('ambiguous option: %s could match %s') % tup)
2017 
2018  # if exactly one action matched, this segmentation is good,
2019  # so return the parsed action
2020  elif len(option_tuples) == 1:
2021  option_tuple, = option_tuples
2022  return option_tuple
2023 
2024  # if it was not found as an option, but it looks like a negative
2025  # number, it was meant to be positional
2026  # unless there are negative-number-like options
2027  if self._negative_number_matcher.match(arg_string):
2028  if not self._has_negative_number_optionals:
2029  return None
2030 
2031  # if it contains a space, it was meant to be a positional
2032  if ' ' in arg_string:
2033  return None
2034 
2035  # it was meant to be an optional but there is no such option
2036  # in this parser (though it might be a valid option in a subparser)
2037  return None, arg_string, None
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def argparse.ArgumentParser._parse_optional (   self,
  arg_string 
)
private

Definition at line 2031 of file argparse.py.

References argparse.ArgumentParser._get_option_tuples(), argparse._ActionsContainer._has_negative_number_optionals, argparse._ActionsContainer._option_string_actions, TreeStruct.error, MomentumConstraint.error, pat::MHT.error(), BinomialProbability.error(), CSCPairConstraint.error(), EcalUncalibRecHitRatioMethodAlgo< C >::Ratio.error, Measurement1DFloat.error(), SiStripLaserRecHit2D.error, EcalUncalibRecHitRatioMethodAlgo< C >::Tmax.error, SaxToDom.error(), Measurement1D.error(), SamplingAnalysis.error(), pat::LookupTableRecord.error(), SaxToDom2.error(), FedTimingAnalysis.error(), ApvTimingAnalysis.error(), CSCPairResidualsConstraint.error(), edm::HLTGlobalStatus.error(), edm::HLTPathStatus.error(), edm::TriggerResultsByName.error(), PTrajectoryStateOnDet.error(), PhysicsTools::Calibration::Histogram< Value_t, Axis_t >.error(), cscdqm::XMLFileErrorHandler.error(), lhef::LHERunInfo::XSec.error, PhysicsTools::Calibration::Histogram2D< Value_t, AxisX_t, AxisY_t >.error(), MuonErrorMatrix.error, DDLSAX2Handler.error(), SimpleSAXParser::ParserError.error(), PhysicsTools::Calibration::Histogram3D< Value_t, AxisX_t, AxisY_t, AxisZ_t >.error(), reco::Vertex.error(), CSCDCCExaminer.error(), reco::TrackBase.error(), MatacqTBRawEvent.error, jetTools.AddJetCollection.error, MatacqRawEvent.error, TiXmlDocument.error, argparse.ArgumentParser.error(), join(), and argparse._ActionsContainer.prefix_chars.

Referenced by argparse.ArgumentParser._parse_known_args(), python.rootplot.argparse.ArgumentParser._parse_known_args(), and argparse.ArgumentParser._parse_optional().

2032  def _parse_optional(self, arg_string):
2033  # if it's an empty string, it was meant to be a positional
2034  if not arg_string:
2035  return None
2036 
2037  # if it doesn't start with a prefix, it was meant to be positional
2038  if not arg_string[0] in self.prefix_chars:
2039  return None
2040 
2041  # if the option string is present in the parser, return the action
2042  if arg_string in self._option_string_actions:
2043  action = self._option_string_actions[arg_string]
2044  return action, arg_string, None
2045 
2046  # if it's just a single character, it was meant to be positional
2047  if len(arg_string) == 1:
2048  return None
2049 
2050  # if the option string before the "=" is present, return the action
2051  if '=' in arg_string:
2052  option_string, explicit_arg = arg_string.split('=', 1)
2053  if option_string in self._option_string_actions:
2054  action = self._option_string_actions[option_string]
2055  return action, option_string, explicit_arg
2056 
2057  # search through all possible prefixes of the option string
2058  # and all actions in the parser for possible interpretations
2059  option_tuples = self._get_option_tuples(arg_string)
2060 
2061  # if multiple actions match, the option string was ambiguous
2062  if len(option_tuples) > 1:
2063  options = ', '.join([option_string
2064  for action, option_string, explicit_arg in option_tuples])
2065  tup = arg_string, options
2066  self.error(_('ambiguous option: %s could match %s') % tup)
2067 
2068  # if exactly one action matched, this segmentation is good,
2069  # so return the parsed action
2070  elif len(option_tuples) == 1:
2071  option_tuple, = option_tuples
2072  return option_tuple
2073 
2074  # if it was not found as an option, but it looks like a negative
2075  # number, it was meant to be positional
2076  # unless there are negative-number-like options
2077  if self._negative_number_matcher.match(arg_string):
2078  if not self._has_negative_number_optionals:
2079  return None
2080 
2081  # if it contains a space, it was meant to be a positional
2082  if ' ' in arg_string:
2083  return None
2084 
2085  # it was meant to be an optional but there is no such option
2086  # in this parser (though it might be a valid option in a subparser)
2087  return None, arg_string, None
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def argparse.ArgumentParser._print_message (   self,
  message,
  file = None 
)
private

Definition at line 2246 of file argparse.py.

References argparse.ArgumentParser._print_message().

2247  def _print_message(self, message, file=None):
2248  if message:
2249  if file is None:
2250  file = _sys.stderr
2251  file.write(message)
def argparse.ArgumentParser._print_message (   self,
  message,
  file = None 
)
private

Definition at line 2323 of file argparse.py.

Referenced by argparse.ArgumentParser._print_message(), argparse.ArgumentParser.exit(), python.rootplot.argparse.ArgumentParser.exit(), argparse.ArgumentParser.print_help(), python.rootplot.argparse.ArgumentParser.print_help(), argparse.ArgumentParser.print_usage(), python.rootplot.argparse.ArgumentParser.print_usage(), argparse.ArgumentParser.print_version(), and python.rootplot.argparse.ArgumentParser.print_version().

2324  def _print_message(self, message, file=None):
2325  if message:
2326  if file is None:
2327  file = _sys.stderr
2328  file.write(message)
def argparse.ArgumentParser._read_args_from_files (   self,
  arg_strings 
)
private

Definition at line 1927 of file argparse.py.

References argparse.ArgumentParser._read_args_from_files(), TreeStruct.error, MomentumConstraint.error, pat::MHT.error(), BinomialProbability.error(), EcalUncalibRecHitRatioMethodAlgo< C >::Ratio.error, CSCPairConstraint.error(), Measurement1DFloat.error(), SiStripLaserRecHit2D.error, EcalUncalibRecHitRatioMethodAlgo< C >::Tmax.error, SaxToDom.error(), Measurement1D.error(), SamplingAnalysis.error(), pat::LookupTableRecord.error(), SaxToDom2.error(), FedTimingAnalysis.error(), ApvTimingAnalysis.error(), CSCPairResidualsConstraint.error(), edm::HLTGlobalStatus.error(), edm::HLTPathStatus.error(), edm::TriggerResultsByName.error(), PTrajectoryStateOnDet.error(), PhysicsTools::Calibration::Histogram< Value_t, Axis_t >.error(), cscdqm::XMLFileErrorHandler.error(), lhef::LHERunInfo::XSec.error, PhysicsTools::Calibration::Histogram2D< Value_t, AxisX_t, AxisY_t >.error(), MuonErrorMatrix.error, DDLSAX2Handler.error(), SimpleSAXParser::ParserError.error(), PhysicsTools::Calibration::Histogram3D< Value_t, AxisX_t, AxisY_t, AxisZ_t >.error(), reco::Vertex.error(), CSCDCCExaminer.error(), reco::TrackBase.error(), MatacqTBRawEvent.error, jetTools.AddJetCollection.error, MatacqRawEvent.error, TiXmlDocument.error, argparse.ArgumentParser.error(), and argparse.ArgumentParser.fromfile_prefix_chars.

1928  def _read_args_from_files(self, arg_strings):
1929  # expand arguments referencing files
1930  new_arg_strings = []
1931  for arg_string in arg_strings:
1932 
1933  # for regular arguments, just add them back into the list
1934  if arg_string[0] not in self.fromfile_prefix_chars:
1935  new_arg_strings.append(arg_string)
1936 
1937  # replace arguments referencing files with the file content
1938  else:
1939  try:
1940  args_file = open(arg_string[1:])
1941  try:
1942  arg_strings = args_file.read().splitlines()
1943  arg_strings = self._read_args_from_files(arg_strings)
1944  new_arg_strings.extend(arg_strings)
1945  finally:
1946  args_file.close()
1947  except IOError:
1948  err = _sys.exc_info()[1]
1949  self.error(str(err))
1950 
1951  # return the modified argument list
1952  return new_arg_strings
def argparse.ArgumentParser._read_args_from_files (   self,
  arg_strings 
)
private

Definition at line 1964 of file argparse.py.

References argparse.ArgumentParser._read_args_from_files(), argparse.ArgumentParser.convert_arg_line_to_args(), TreeStruct.error, MomentumConstraint.error, pat::MHT.error(), BinomialProbability.error(), EcalUncalibRecHitRatioMethodAlgo< C >::Ratio.error, CSCPairConstraint.error(), Measurement1DFloat.error(), SiStripLaserRecHit2D.error, EcalUncalibRecHitRatioMethodAlgo< C >::Tmax.error, SaxToDom.error(), Measurement1D.error(), SamplingAnalysis.error(), pat::LookupTableRecord.error(), SaxToDom2.error(), FedTimingAnalysis.error(), ApvTimingAnalysis.error(), CSCPairResidualsConstraint.error(), edm::HLTGlobalStatus.error(), edm::HLTPathStatus.error(), edm::TriggerResultsByName.error(), PTrajectoryStateOnDet.error(), PhysicsTools::Calibration::Histogram< Value_t, Axis_t >.error(), cscdqm::XMLFileErrorHandler.error(), lhef::LHERunInfo::XSec.error, PhysicsTools::Calibration::Histogram2D< Value_t, AxisX_t, AxisY_t >.error(), MuonErrorMatrix.error, DDLSAX2Handler.error(), SimpleSAXParser::ParserError.error(), PhysicsTools::Calibration::Histogram3D< Value_t, AxisX_t, AxisY_t, AxisZ_t >.error(), reco::Vertex.error(), CSCDCCExaminer.error(), reco::TrackBase.error(), MatacqTBRawEvent.error, jetTools.AddJetCollection.error, MatacqRawEvent.error, TiXmlDocument.error, argparse.ArgumentParser.error(), and argparse.ArgumentParser.fromfile_prefix_chars.

Referenced by argparse.ArgumentParser._parse_known_args(), python.rootplot.argparse.ArgumentParser._parse_known_args(), argparse.ArgumentParser._read_args_from_files(), and python.rootplot.argparse.ArgumentParser._read_args_from_files().

1965  def _read_args_from_files(self, arg_strings):
1966  # expand arguments referencing files
1967  new_arg_strings = []
1968  for arg_string in arg_strings:
1969 
1970  # for regular arguments, just add them back into the list
1971  if arg_string[0] not in self.fromfile_prefix_chars:
1972  new_arg_strings.append(arg_string)
1973 
1974  # replace arguments referencing files with the file content
1975  else:
1976  try:
1977  args_file = open(arg_string[1:])
1978  try:
1979  arg_strings = []
1980  for arg_line in args_file.read().splitlines():
1981  for arg in self.convert_arg_line_to_args(arg_line):
1982  arg_strings.append(arg)
1983  arg_strings = self._read_args_from_files(arg_strings)
1984  new_arg_strings.extend(arg_strings)
1985  finally:
1986  args_file.close()
1987  except IOError:
1988  err = _sys.exc_info()[1]
1989  self.error(str(err))
1990 
1991  # return the modified argument list
1992  return new_arg_strings
def argparse.ArgumentParser.add_subparsers (   self,
  kwargs 
)

Definition at line 1603 of file argparse.py.

References argparse.ArgumentParser._get_formatter(), argparse.ArgumentParser._get_positional_actions(), argparse._ActionsContainer._mutually_exclusive_groups, argparse._ActionsContainer._pop_action_class(), argparse.ArgumentParser._positionals, argparse.ArgumentParser._subparsers, argparse._ActionsContainer.add_argument_group(), argparse.ArgumentParser.add_subparsers(), TreeStruct.error, MomentumConstraint.error, pat::MHT.error(), BinomialProbability.error(), EcalUncalibRecHitRatioMethodAlgo< C >::Ratio.error, CSCPairConstraint.error(), Measurement1DFloat.error(), SiStripLaserRecHit2D.error, EcalUncalibRecHitRatioMethodAlgo< C >::Tmax.error, SaxToDom.error(), Measurement1D.error(), SamplingAnalysis.error(), pat::LookupTableRecord.error(), SaxToDom2.error(), FedTimingAnalysis.error(), ApvTimingAnalysis.error(), CSCPairResidualsConstraint.error(), edm::HLTGlobalStatus.error(), edm::HLTPathStatus.error(), edm::TriggerResultsByName.error(), PTrajectoryStateOnDet.error(), PhysicsTools::Calibration::Histogram< Value_t, Axis_t >.error(), cscdqm::XMLFileErrorHandler.error(), lhef::LHERunInfo::XSec.error, PhysicsTools::Calibration::Histogram2D< Value_t, AxisX_t, AxisY_t >.error(), MuonErrorMatrix.error, DDLSAX2Handler.error(), SimpleSAXParser::ParserError.error(), PhysicsTools::Calibration::Histogram3D< Value_t, AxisX_t, AxisY_t, AxisZ_t >.error(), reco::Vertex.error(), CSCDCCExaminer.error(), reco::TrackBase.error(), MatacqTBRawEvent.error, jetTools.AddJetCollection.error, MatacqRawEvent.error, TiXmlDocument.error, argparse.ArgumentParser.error(), and argparse.ArgumentParser.usage.

1604  def add_subparsers(self, **kwargs):
1605  if self._subparsers is not None:
1606  self.error(_('cannot have multiple subparser arguments'))
1607 
1608  # add the parser class to the arguments if it's not present
1609  kwargs.setdefault('parser_class', type(self))
1610 
1611  if 'title' in kwargs or 'description' in kwargs:
1612  title = _(kwargs.pop('title', 'subcommands'))
1613  description = _(kwargs.pop('description', None))
1614  self._subparsers = self.add_argument_group(title, description)
1615  else:
1616  self._subparsers = self._positionals
1617 
1618  # prog defaults to the usage message of this parser, skipping
1619  # optional arguments and with no "usage:" prefix
1620  if kwargs.get('prog') is None:
1621  formatter = self._get_formatter()
1622  positionals = self._get_positional_actions()
1623  groups = self._mutually_exclusive_groups
1624  formatter.add_usage(self.usage, positionals, groups, '')
1625  kwargs['prog'] = formatter.format_help().strip()
1626 
1627  # create the parsers action and add it to the positionals list
1628  parsers_class = self._pop_action_class(kwargs, 'parsers')
1629  action = parsers_class(option_strings=[], **kwargs)
1630  self._subparsers._add_action(action)
1631 
1632  # return the created parsers action
1633  return action
def argparse.ArgumentParser.add_subparsers (   self,
  kwargs 
)

Definition at line 1636 of file argparse.py.

References argparse.ArgumentParser._get_formatter(), argparse.ArgumentParser._get_positional_actions(), argparse._ActionsContainer._mutually_exclusive_groups, argparse._ActionsContainer._pop_action_class(), argparse.ArgumentParser._positionals, argparse.ArgumentParser._subparsers, argparse._ActionsContainer.add_argument_group(), TreeStruct.error, MomentumConstraint.error, pat::MHT.error(), BinomialProbability.error(), EcalUncalibRecHitRatioMethodAlgo< C >::Ratio.error, CSCPairConstraint.error(), Measurement1DFloat.error(), EcalUncalibRecHitRatioMethodAlgo< C >::Tmax.error, SiStripLaserRecHit2D.error, SaxToDom.error(), Measurement1D.error(), SamplingAnalysis.error(), pat::LookupTableRecord.error(), SaxToDom2.error(), FedTimingAnalysis.error(), ApvTimingAnalysis.error(), CSCPairResidualsConstraint.error(), edm::HLTGlobalStatus.error(), edm::HLTPathStatus.error(), edm::TriggerResultsByName.error(), PTrajectoryStateOnDet.error(), PhysicsTools::Calibration::Histogram< Value_t, Axis_t >.error(), cscdqm::XMLFileErrorHandler.error(), lhef::LHERunInfo::XSec.error, PhysicsTools::Calibration::Histogram2D< Value_t, AxisX_t, AxisY_t >.error(), MuonErrorMatrix.error, DDLSAX2Handler.error(), SimpleSAXParser::ParserError.error(), PhysicsTools::Calibration::Histogram3D< Value_t, AxisX_t, AxisY_t, AxisZ_t >.error(), reco::Vertex.error(), CSCDCCExaminer.error(), reco::TrackBase.error(), MatacqTBRawEvent.error, jetTools.AddJetCollection.error, MatacqRawEvent.error, TiXmlDocument.error, argparse.ArgumentParser.error(), and argparse.ArgumentParser.usage.

Referenced by argparse.ArgumentParser.add_subparsers().

1637  def add_subparsers(self, **kwargs):
1638  if self._subparsers is not None:
1639  self.error(_('cannot have multiple subparser arguments'))
1640 
1641  # add the parser class to the arguments if it's not present
1642  kwargs.setdefault('parser_class', type(self))
1643 
1644  if 'title' in kwargs or 'description' in kwargs:
1645  title = _(kwargs.pop('title', 'subcommands'))
1646  description = _(kwargs.pop('description', None))
1647  self._subparsers = self.add_argument_group(title, description)
1648  else:
1649  self._subparsers = self._positionals
1650 
1651  # prog defaults to the usage message of this parser, skipping
1652  # optional arguments and with no "usage:" prefix
1653  if kwargs.get('prog') is None:
1654  formatter = self._get_formatter()
1655  positionals = self._get_positional_actions()
1656  groups = self._mutually_exclusive_groups
1657  formatter.add_usage(self.usage, positionals, groups, '')
1658  kwargs['prog'] = formatter.format_help().strip()
1659 
1660  # create the parsers action and add it to the positionals list
1661  parsers_class = self._pop_action_class(kwargs, 'parsers')
1662  action = parsers_class(option_strings=[], **kwargs)
1663  self._subparsers._add_action(action)
1664 
1665  # return the created parsers action
1666  return action
def argparse.ArgumentParser.convert_arg_line_to_args (   self,
  arg_line 
)

Definition at line 1993 of file argparse.py.

Referenced by argparse.ArgumentParser._read_args_from_files(), and python.rootplot.argparse.ArgumentParser._read_args_from_files().

1994  def convert_arg_line_to_args(self, arg_line):
1995  return [arg_line]
def argparse.ArgumentParser.error (   self,
  message 
)
error(message: string)

Prints a usage message incorporating the message to stderr and
exits.

If you override this in a subclass, it should not return -- it
should either exit or raise an exception.

Definition at line 2260 of file argparse.py.

References argparse.ArgumentParser.error(), CaloSegment.exit(), statemachine::HandleFiles.exit(), statemachine::HandleRuns.exit(), statemachine::HandleLumis.exit(), Vispa.Main.Application.Application.exit(), argparse.ArgumentParser.exit(), argparse.ArgumentParser.print_usage(), and argparse.ArgumentParser.prog.

2261  def error(self, message):
2262  """error(message: string)
2263 
2264  Prints a usage message incorporating the message to stderr and
2265  exits.
2266 
2267  If you override this in a subclass, it should not return -- it
2268  should either exit or raise an exception.
2269  """
2270  self.print_usage(_sys.stderr)
2271  self.exit(2, _('%s: error: %s\n') % (self.prog, message))
def argparse.ArgumentParser.error (   self,
  message 
)
error(message: string)

Prints a usage message incorporating the message to stderr and
exits.

If you override this in a subclass, it should not return -- it
should either exit or raise an exception.

Definition at line 2337 of file argparse.py.

References CaloSegment.exit(), statemachine::HandleFiles.exit(), statemachine::HandleRuns.exit(), statemachine::HandleLumis.exit(), Vispa.Main.Application.Application.exit(), argparse.ArgumentParser.exit(), argparse.ArgumentParser.print_usage(), and argparse.ArgumentParser.prog.

Referenced by argparse.ArgumentParser._get_option_tuples(), python.rootplot.argparse.ArgumentParser._get_option_tuples(), argparse.ArgumentParser._parse_known_args(), python.rootplot.argparse.ArgumentParser._parse_known_args(), argparse.ArgumentParser._parse_optional(), python.rootplot.argparse.ArgumentParser._parse_optional(), argparse.ArgumentParser._read_args_from_files(), python.rootplot.argparse.ArgumentParser._read_args_from_files(), argparse.ArgumentParser.add_subparsers(), python.rootplot.argparse.ArgumentParser.add_subparsers(), argparse.ArgumentParser.error(), argparse.ArgumentParser.parse_args(), python.rootplot.argparse.ArgumentParser.parse_args(), argparse.ArgumentParser.parse_known_args(), and python.rootplot.argparse.ArgumentParser.parse_known_args().

2338  def error(self, message):
2339  """error(message: string)
2340 
2341  Prints a usage message incorporating the message to stderr and
2342  exits.
2343 
2344  If you override this in a subclass, it should not return -- it
2345  should either exit or raise an exception.
2346  """
2347  self.print_usage(_sys.stderr)
2348  self.exit(2, _('%s: error: %s\n') % (self.prog, message))
def argparse.ArgumentParser.exit (   self,
  status = 0,
  message = None 
)

Definition at line 2255 of file argparse.py.

References argparse.ArgumentParser.exit().

2256  def exit(self, status=0, message=None):
2257  if message:
2258  _sys.stderr.write(message)
2259  _sys.exit(status)
def argparse.ArgumentParser.exit (   self,
  status = 0,
  message = None 
)

Definition at line 2332 of file argparse.py.

References argparse.ArgumentParser._print_message().

Referenced by argparse.ArgumentParser.error(), python.rootplot.argparse.ArgumentParser.error(), and argparse.ArgumentParser.exit().

2333  def exit(self, status=0, message=None):
2334  if message:
2335  self._print_message(message, _sys.stderr)
2336  _sys.exit(status)
def argparse.ArgumentParser.format_help (   self)

Definition at line 2203 of file argparse.py.

References argparse._ActionsContainer._action_groups, argparse._ActionsContainer._actions, argparse.ArgumentParser._get_formatter(), argparse._ActionsContainer._mutually_exclusive_groups, cond::persistency::GTEditorData.description, cond::persistency::IOVEditorData.description, ExpressionHisto< T >.description, cond::TagMetadata_t.description, argparse._ActionsContainer.description, argparse.ArgumentParser.epilog, argparse.ArgumentParser.format_help(), and argparse.ArgumentParser.usage.

2204  def format_help(self):
2205  formatter = self._get_formatter()
2206 
2207  # usage
2208  formatter.add_usage(self.usage, self._actions,
2210 
2211  # description
2212  formatter.add_text(self.description)
2213 
2214  # positionals, optionals and user-defined groups
2215  for action_group in self._action_groups:
2216  formatter.start_section(action_group.title)
2217  formatter.add_text(action_group.description)
2218  formatter.add_arguments(action_group._group_actions)
2219  formatter.end_section()
2220 
2221  # epilog
2222  formatter.add_text(self.epilog)
2223 
2224  # determine help from format above
2225  return formatter.format_help()
def argparse.ArgumentParser.format_help (   self)

Definition at line 2266 of file argparse.py.

References argparse._ActionsContainer._action_groups, argparse._ActionsContainer._actions, argparse.ArgumentParser._get_formatter(), argparse._ActionsContainer._mutually_exclusive_groups, cond::persistency::GTEditorData.description, cond::persistency::IOVEditorData.description, ExpressionHisto< T >.description, cond::TagMetadata_t.description, argparse._ActionsContainer.description, argparse.ArgumentParser.epilog, and argparse.ArgumentParser.usage.

Referenced by argparse.ArgumentParser.format_help(), argparse.ArgumentParser.print_help(), and python.rootplot.argparse.ArgumentParser.print_help().

2267  def format_help(self):
2268  formatter = self._get_formatter()
2269 
2270  # usage
2271  formatter.add_usage(self.usage, self._actions,
2273 
2274  # description
2275  formatter.add_text(self.description)
2276 
2277  # positionals, optionals and user-defined groups
2278  for action_group in self._action_groups:
2279  formatter.start_section(action_group.title)
2280  formatter.add_text(action_group.description)
2281  formatter.add_arguments(action_group._group_actions)
2282  formatter.end_section()
2283 
2284  # epilog
2285  formatter.add_text(self.epilog)
2286 
2287  # determine help from format above
2288  return formatter.format_help()
def argparse.ArgumentParser.format_usage (   self)

Definition at line 2197 of file argparse.py.

References argparse._ActionsContainer._actions, argparse.ArgumentParser._get_formatter(), argparse._ActionsContainer._mutually_exclusive_groups, argparse.ArgumentParser.format_usage(), and argparse.ArgumentParser.usage.

2198  def format_usage(self):
2199  formatter = self._get_formatter()
2200  formatter.add_usage(self.usage, self._actions,
2202  return formatter.format_help()
def argparse.ArgumentParser.format_usage (   self)

Definition at line 2260 of file argparse.py.

References argparse._ActionsContainer._actions, argparse.ArgumentParser._get_formatter(), argparse._ActionsContainer._mutually_exclusive_groups, and argparse.ArgumentParser.usage.

Referenced by argparse.ArgumentParser.format_usage(), argparse.ArgumentParser.print_usage(), and python.rootplot.argparse.ArgumentParser.print_usage().

2261  def format_usage(self):
2262  formatter = self._get_formatter()
2263  formatter.add_usage(self.usage, self._actions,
2265  return formatter.format_help()
def argparse.ArgumentParser.format_version (   self)

Definition at line 2226 of file argparse.py.

References argparse.ArgumentParser._get_formatter(), argparse.ArgumentParser.format_version(), MatrixInjector.MatrixInjector.version, TrackerInteractionGeometry.version, ora::MappingRawData.version, MatacqTBRawEvent::matacqHeader_t.version, DQMNet::CoreObject.version, XMLProcessor::_DBConfig.version, ScalersEventRecordRaw_v1.version, ScalersEventRecordRaw_v2.version, ScalersEventRecordRaw_v3.version, ScalersEventRecordRaw_v4.version, ScalersEventRecordRaw_v5.version, ScalersEventRecordRaw_v6.version, argparse._VersionAction.version, TiXmlDeclaration.version, and argparse.ArgumentParser.version.

2227  def format_version(self):
2228  formatter = self._get_formatter()
2229  formatter.add_text(self.version)
2230  return formatter.format_help()
def argparse.ArgumentParser.format_version (   self)

Definition at line 2289 of file argparse.py.

References argparse.ArgumentParser._get_formatter(), MatrixInjector.MatrixInjector.version, TrackerInteractionGeometry.version, ora::MappingRawData.version, MatacqTBRawEvent::matacqHeader_t.version, DQMNet::CoreObject.version, XMLProcessor::_DBConfig.version, ScalersEventRecordRaw_v1.version, ScalersEventRecordRaw_v2.version, ScalersEventRecordRaw_v3.version, ScalersEventRecordRaw_v4.version, ScalersEventRecordRaw_v5.version, ScalersEventRecordRaw_v6.version, argparse._VersionAction.version, TiXmlDeclaration.version, and argparse.ArgumentParser.version.

Referenced by argparse.ArgumentParser.format_version(), argparse.ArgumentParser.print_version(), and python.rootplot.argparse.ArgumentParser.print_version().

2290  def format_version(self):
2291  import warnings
2292  warnings.warn(
2293  'The format_version method is deprecated -- the "version" '
2294  'argument to ArgumentParser is no longer supported.',
2295  DeprecationWarning)
2296  formatter = self._get_formatter()
2297  formatter.add_text(self.version)
2298  return formatter.format_help()
def argparse.ArgumentParser.parse_args (   self,
  args = None,
  namespace = None 
)

Definition at line 1654 of file argparse.py.

References TreeStruct.error, MomentumConstraint.error, pat::MHT.error(), BinomialProbability.error(), EcalUncalibRecHitRatioMethodAlgo< C >::Ratio.error, CSCPairConstraint.error(), Measurement1DFloat.error(), SiStripLaserRecHit2D.error, EcalUncalibRecHitRatioMethodAlgo< C >::Tmax.error, SaxToDom.error(), Measurement1D.error(), SamplingAnalysis.error(), pat::LookupTableRecord.error(), SaxToDom2.error(), FedTimingAnalysis.error(), ApvTimingAnalysis.error(), CSCPairResidualsConstraint.error(), edm::HLTGlobalStatus.error(), edm::HLTPathStatus.error(), edm::TriggerResultsByName.error(), PTrajectoryStateOnDet.error(), PhysicsTools::Calibration::Histogram< Value_t, Axis_t >.error(), cscdqm::XMLFileErrorHandler.error(), lhef::LHERunInfo::XSec.error, PhysicsTools::Calibration::Histogram2D< Value_t, AxisX_t, AxisY_t >.error(), MuonErrorMatrix.error, DDLSAX2Handler.error(), SimpleSAXParser::ParserError.error(), PhysicsTools::Calibration::Histogram3D< Value_t, AxisX_t, AxisY_t, AxisZ_t >.error(), reco::Vertex.error(), CSCDCCExaminer.error(), reco::TrackBase.error(), MatacqTBRawEvent.error, jetTools.AddJetCollection.error, MatacqRawEvent.error, TiXmlDocument.error, argparse.ArgumentParser.error(), join(), argparse.ArgumentParser.parse_args(), and argparse.ArgumentParser.parse_known_args().

1655  def parse_args(self, args=None, namespace=None):
1656  args, argv = self.parse_known_args(args, namespace)
1657  if argv:
1658  msg = _('unrecognized arguments: %s')
1659  self.error(msg % ' '.join(argv))
1660  return args
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def argparse.ArgumentParser.parse_args (   self,
  args = None,
  namespace = None 
)

Definition at line 1687 of file argparse.py.

References TreeStruct.error, MomentumConstraint.error, pat::MHT.error(), BinomialProbability.error(), EcalUncalibRecHitRatioMethodAlgo< C >::Ratio.error, CSCPairConstraint.error(), Measurement1DFloat.error(), EcalUncalibRecHitRatioMethodAlgo< C >::Tmax.error, SiStripLaserRecHit2D.error, SaxToDom.error(), Measurement1D.error(), SamplingAnalysis.error(), pat::LookupTableRecord.error(), SaxToDom2.error(), FedTimingAnalysis.error(), ApvTimingAnalysis.error(), CSCPairResidualsConstraint.error(), edm::HLTGlobalStatus.error(), edm::HLTPathStatus.error(), edm::TriggerResultsByName.error(), PTrajectoryStateOnDet.error(), PhysicsTools::Calibration::Histogram< Value_t, Axis_t >.error(), cscdqm::XMLFileErrorHandler.error(), lhef::LHERunInfo::XSec.error, PhysicsTools::Calibration::Histogram2D< Value_t, AxisX_t, AxisY_t >.error(), MuonErrorMatrix.error, DDLSAX2Handler.error(), SimpleSAXParser::ParserError.error(), PhysicsTools::Calibration::Histogram3D< Value_t, AxisX_t, AxisY_t, AxisZ_t >.error(), reco::Vertex.error(), CSCDCCExaminer.error(), reco::TrackBase.error(), MatacqTBRawEvent.error, jetTools.AddJetCollection.error, MatacqRawEvent.error, TiXmlDocument.error, argparse.ArgumentParser.error(), join(), and argparse.ArgumentParser.parse_known_args().

Referenced by argparse.ArgumentParser.parse_args().

1688  def parse_args(self, args=None, namespace=None):
1689  args, argv = self.parse_known_args(args, namespace)
1690  if argv:
1691  msg = _('unrecognized arguments: %s')
1692  self.error(msg % ' '.join(argv))
1693  return args
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def argparse.ArgumentParser.parse_known_args (   self,
  args = None,
  namespace = None 
)

Definition at line 1661 of file argparse.py.

References argparse._ActionsContainer._actions, argparse._ActionsContainer._defaults, argparse.ArgumentParser._get_value(), argparse.ArgumentParser._parse_known_args(), TreeStruct.error, MomentumConstraint.error, pat::MHT.error(), BinomialProbability.error(), CSCPairConstraint.error(), EcalUncalibRecHitRatioMethodAlgo< C >::Ratio.error, Measurement1DFloat.error(), SiStripLaserRecHit2D.error, EcalUncalibRecHitRatioMethodAlgo< C >::Tmax.error, SaxToDom.error(), Measurement1D.error(), SamplingAnalysis.error(), pat::LookupTableRecord.error(), SaxToDom2.error(), FedTimingAnalysis.error(), ApvTimingAnalysis.error(), CSCPairResidualsConstraint.error(), edm::HLTGlobalStatus.error(), edm::HLTPathStatus.error(), edm::TriggerResultsByName.error(), PTrajectoryStateOnDet.error(), PhysicsTools::Calibration::Histogram< Value_t, Axis_t >.error(), cscdqm::XMLFileErrorHandler.error(), lhef::LHERunInfo::XSec.error, PhysicsTools::Calibration::Histogram2D< Value_t, AxisX_t, AxisY_t >.error(), MuonErrorMatrix.error, DDLSAX2Handler.error(), SimpleSAXParser::ParserError.error(), PhysicsTools::Calibration::Histogram3D< Value_t, AxisX_t, AxisY_t, AxisZ_t >.error(), reco::Vertex.error(), CSCDCCExaminer.error(), reco::TrackBase.error(), MatacqTBRawEvent.error, jetTools.AddJetCollection.error, MatacqRawEvent.error, TiXmlDocument.error, argparse.ArgumentParser.error(), and argparse.ArgumentParser.parse_known_args().

1662  def parse_known_args(self, args=None, namespace=None):
1663  # args default to the system args
1664  if args is None:
1665  args = _sys.argv[1:]
1666 
1667  # default Namespace built from parser defaults
1668  if namespace is None:
1669  namespace = Namespace()
1670 
1671  # add any action defaults that aren't present
1672  for action in self._actions:
1673  if action.dest is not SUPPRESS:
1674  if not hasattr(namespace, action.dest):
1675  if action.default is not SUPPRESS:
1676  default = action.default
1677  if isinstance(action.default, _basestring):
1678  default = self._get_value(action, default)
1679  setattr(namespace, action.dest, default)
1680 
1681  # add any parser defaults that aren't present
1682  for dest in self._defaults:
1683  if not hasattr(namespace, dest):
1684  setattr(namespace, dest, self._defaults[dest])
1685 
1686  # parse the arguments and exit if there are any errors
1687  try:
1688  return self._parse_known_args(args, namespace)
1689  except ArgumentError:
1690  err = _sys.exc_info()[1]
1691  self.error(str(err))
def argparse.ArgumentParser.parse_known_args (   self,
  args = None,
  namespace = None 
)

Definition at line 1694 of file argparse.py.

References argparse._ActionsContainer._actions, argparse._ActionsContainer._defaults, argparse.ArgumentParser._get_value(), argparse.ArgumentParser._parse_known_args(), TreeStruct.error, MomentumConstraint.error, pat::MHT.error(), BinomialProbability.error(), CSCPairConstraint.error(), EcalUncalibRecHitRatioMethodAlgo< C >::Ratio.error, Measurement1DFloat.error(), SiStripLaserRecHit2D.error, EcalUncalibRecHitRatioMethodAlgo< C >::Tmax.error, SaxToDom.error(), Measurement1D.error(), SamplingAnalysis.error(), pat::LookupTableRecord.error(), SaxToDom2.error(), FedTimingAnalysis.error(), ApvTimingAnalysis.error(), CSCPairResidualsConstraint.error(), edm::HLTGlobalStatus.error(), edm::HLTPathStatus.error(), edm::TriggerResultsByName.error(), PTrajectoryStateOnDet.error(), PhysicsTools::Calibration::Histogram< Value_t, Axis_t >.error(), cscdqm::XMLFileErrorHandler.error(), lhef::LHERunInfo::XSec.error, PhysicsTools::Calibration::Histogram2D< Value_t, AxisX_t, AxisY_t >.error(), MuonErrorMatrix.error, DDLSAX2Handler.error(), SimpleSAXParser::ParserError.error(), PhysicsTools::Calibration::Histogram3D< Value_t, AxisX_t, AxisY_t, AxisZ_t >.error(), reco::Vertex.error(), CSCDCCExaminer.error(), reco::TrackBase.error(), MatacqTBRawEvent.error, jetTools.AddJetCollection.error, MatacqRawEvent.error, TiXmlDocument.error, and argparse.ArgumentParser.error().

Referenced by argparse.ArgumentParser.parse_args(), python.rootplot.argparse.ArgumentParser.parse_args(), and argparse.ArgumentParser.parse_known_args().

1695  def parse_known_args(self, args=None, namespace=None):
1696  # args default to the system args
1697  if args is None:
1698  args = _sys.argv[1:]
1699 
1700  # default Namespace built from parser defaults
1701  if namespace is None:
1702  namespace = Namespace()
1703 
1704  # add any action defaults that aren't present
1705  for action in self._actions:
1706  if action.dest is not SUPPRESS:
1707  if not hasattr(namespace, action.dest):
1708  if action.default is not SUPPRESS:
1709  default = action.default
1710  if isinstance(action.default, basestring):
1711  default = self._get_value(action, default)
1712  setattr(namespace, action.dest, default)
1713 
1714  # add any parser defaults that aren't present
1715  for dest in self._defaults:
1716  if not hasattr(namespace, dest):
1717  setattr(namespace, dest, self._defaults[dest])
1718 
1719  # parse the arguments and exit if there are any errors
1720  try:
1721  namespace, args = self._parse_known_args(args, namespace)
1722  if hasattr(namespace, _UNRECOGNIZED_ARGS_ATTR):
1723  args.extend(getattr(namespace, _UNRECOGNIZED_ARGS_ATTR))
1724  delattr(namespace, _UNRECOGNIZED_ARGS_ATTR)
1725  return namespace, args
1726  except ArgumentError:
1727  err = _sys.exc_info()[1]
1728  self.error(str(err))
def argparse.ArgumentParser.print_help (   self,
  file = None 
)

Definition at line 2240 of file argparse.py.

References argparse.ArgumentParser._print_message(), argparse.HelpFormatter._Section.format_help(), argparse.HelpFormatter.format_help(), argparse.ArgumentParser.format_help(), and argparse.ArgumentParser.print_help().

2241  def print_help(self, file=None):
2242  self._print_message(self.format_help(), file)
def argparse.ArgumentParser.print_help (   self,
  file = None 
)

Definition at line 2310 of file argparse.py.

References argparse.ArgumentParser._print_message(), argparse.HelpFormatter._Section.format_help(), argparse.HelpFormatter.format_help(), and argparse.ArgumentParser.format_help().

Referenced by argparse.ArgumentParser.print_help().

2311  def print_help(self, file=None):
2312  if file is None:
2313  file = _sys.stdout
2314  self._print_message(self.format_help(), file)
def argparse.ArgumentParser.print_usage (   self,
  file = None 
)

Definition at line 2237 of file argparse.py.

References argparse.ArgumentParser._print_message(), argparse.ArgumentParser.format_usage(), and argparse.ArgumentParser.print_usage().

2238  def print_usage(self, file=None):
2239  self._print_message(self.format_usage(), file)
def argparse.ArgumentParser.print_usage (   self,
  file = None 
)

Definition at line 2305 of file argparse.py.

References argparse.ArgumentParser._print_message(), and argparse.ArgumentParser.format_usage().

Referenced by argparse.ArgumentParser.error(), python.rootplot.argparse.ArgumentParser.error(), and argparse.ArgumentParser.print_usage().

2306  def print_usage(self, file=None):
2307  if file is None:
2308  file = _sys.stdout
2309  self._print_message(self.format_usage(), file)
def argparse.ArgumentParser.print_version (   self,
  file = None 
)

Definition at line 2243 of file argparse.py.

References argparse.ArgumentParser._print_message(), CSCDDUHeader.format_version(), CSCSPHeader.format_version(), argparse.ArgumentParser.format_version(), and argparse.ArgumentParser.print_version().

2244  def print_version(self, file=None):
2245  self._print_message(self.format_version(), file)
def argparse.ArgumentParser.print_version (   self,
  file = None 
)

Definition at line 2315 of file argparse.py.

References argparse.ArgumentParser._print_message(), CSCDDUHeader.format_version(), CSCSPHeader.format_version(), and argparse.ArgumentParser.format_version().

Referenced by argparse.ArgumentParser.print_version().

2316  def print_version(self, file=None):
2317  import warnings
2318  warnings.warn(
2319  'The print_version method is deprecated -- the "version" '
2320  'argument to ArgumentParser is no longer supported.',
2321  DeprecationWarning)
2322  self._print_message(self.format_version(), file)

Member Data Documentation

argparse.ArgumentParser._optionals
private

Definition at line 1585 of file argparse.py.

Referenced by argparse.ArgumentParser.__init__().

argparse.ArgumentParser._positionals
private

Definition at line 1584 of file argparse.py.

Referenced by argparse.ArgumentParser.__init__(), argparse.ArgumentParser.add_subparsers(), and python.rootplot.argparse.ArgumentParser.add_subparsers().

argparse.ArgumentParser._subparsers
private

Definition at line 1586 of file argparse.py.

Referenced by argparse.ArgumentParser.__init__(), argparse.ArgumentParser.add_subparsers(), and python.rootplot.argparse.ArgumentParser.add_subparsers().

argparse.ArgumentParser.add_help

Definition at line 1581 of file argparse.py.

Referenced by argparse.ArgumentParser.__init__().

argparse.ArgumentParser.epilog

Definition at line 1577 of file argparse.py.

Referenced by argparse.ArgumentParser.__init__(), argparse.ArgumentParser.format_help(), and python.rootplot.argparse.ArgumentParser.format_help().

argparse.ArgumentParser.formatter_class

Definition at line 1579 of file argparse.py.

Referenced by argparse.ArgumentParser.__init__(), argparse.ArgumentParser._get_formatter(), and python.rootplot.argparse.ArgumentParser._get_formatter().

argparse.ArgumentParser.fromfile_prefix_chars

Definition at line 1580 of file argparse.py.

Referenced by argparse.ArgumentParser.__init__(), argparse.ArgumentParser._parse_known_args(), python.rootplot.argparse.ArgumentParser._parse_known_args(), argparse.ArgumentParser._read_args_from_files(), and python.rootplot.argparse.ArgumentParser._read_args_from_files().

argparse.ArgumentParser.prog

Definition at line 1575 of file argparse.py.

Referenced by argparse.ArgumentParser.__init__(), argparse.ArgumentParser._get_formatter(), python.rootplot.argparse.ArgumentParser._get_formatter(), argparse.ArgumentParser.error(), and python.rootplot.argparse.ArgumentParser.error().

argparse.ArgumentParser.usage

Definition at line 1576 of file argparse.py.

Referenced by argparse.ArgumentParser.__init__(), argparse.ArgumentParser.add_subparsers(), python.rootplot.argparse.ArgumentParser.add_subparsers(), argparse.ArgumentParser.format_help(), python.rootplot.argparse.ArgumentParser.format_help(), argparse.ArgumentParser.format_usage(), and python.rootplot.argparse.ArgumentParser.format_usage().

argparse.ArgumentParser.version

Definition at line 1578 of file argparse.py.

Referenced by python.rootplot.argparse._VersionAction.__call__(), argparse.ArgumentParser.__init__(), argparse.ArgumentParser.format_version(), and python.rootplot.argparse.ArgumentParser.format_version().