CMS 3D CMS Logo

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

Public Member Functions

def __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)
 
def add_subparsers (self, kwargs)
 
def error (self, message)
 
def exit (self, status=0, message=None)
 
def format_help (self)
 
def format_usage (self)
 
def format_version (self)
 
def parse_args (self, args=None, namespace=None)
 
def parse_known_args (self, args=None, namespace=None)
 
def print_help (self, file=None)
 
def print_usage (self, file=None)
 
def print_version (self, file=None)
 
- Public Member Functions inherited from argparse._AttributeHolder
def __repr__ (self)
 
- Public Member Functions inherited from argparse._ActionsContainer
def __init__ (self, description, prefix_chars, argument_default, conflict_handler)
 
def add_argument (self, args, kwargs)
 
def add_argument_group (self, args, kwargs)
 
def add_mutually_exclusive_group (self, kwargs)
 
def register (self, registry_name, value, object)
 
def set_defaults (self, kwargs)
 

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 (self, action)
 
def _check_value (self, action, value)
 
def _get_formatter (self)
 
def _get_kwargs (self)
 
def _get_nargs_pattern (self, action)
 
def _get_option_tuples (self, option_string)
 
def _get_optional_actions (self)
 
def _get_positional_actions (self)
 
def _get_value (self, action, arg_string)
 
def _get_values (self, action, arg_strings)
 
def _match_argument (self, action, arg_strings_pattern)
 
def _match_arguments_partial (self, actions, arg_strings_pattern)
 
def _parse_known_args (self, arg_strings, namespace)
 
def _parse_optional (self, arg_string)
 
def _print_message (self, message, file=None)
 
def _read_args_from_files (self, arg_strings)
 

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

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

Member Function Documentation

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

Definition at line 1634 of file argparse.py.

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

Definition at line 2187 of file argparse.py.

References crabWrapper._, join(), and genParticles_cff.map.

Referenced by argparse.ArgumentParser._get_values().

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

Definition at line 1588 of file argparse.py.

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

Definition at line 2082 of file argparse.py.

References join().

Referenced by argparse.ArgumentParser._match_argument(), and argparse.ArgumentParser._match_arguments_partial().

2082  def _get_nargs_pattern(self, action):
2083  # in all examples below, we have to allow for '--' args
2084  # which are represented as '-' in the pattern
2085  nargs = action.nargs
2086 
2087  # the default (None) is assumed to be a single argument
2088  if nargs is None:
2089  nargs_pattern = '(-*A-*)'
2090 
2091  # allow zero or one arguments
2092  elif nargs == OPTIONAL:
2093  nargs_pattern = '(-*A?-*)'
2094 
2095  # allow zero or more arguments
2096  elif nargs == ZERO_OR_MORE:
2097  nargs_pattern = '(-*[A-]*)'
2098 
2099  # allow one or more arguments
2100  elif nargs == ONE_OR_MORE:
2101  nargs_pattern = '(-*A[A-]*)'
2102 
2103  # allow one argument followed by any number of options or arguments
2104  elif nargs is PARSER:
2105  nargs_pattern = '(-*A[-AO]*)'
2106 
2107  # all others should be integers
2108  else:
2109  nargs_pattern = '(-*%s-*)' % '-*'.join('A' * nargs)
2110 
2111  # if this is an optional action, -- is not allowed
2112  if action.option_strings:
2113  nargs_pattern = nargs_pattern.replace('-*', '')
2114  nargs_pattern = nargs_pattern.replace('-', '')
2115 
2116  # return the pattern
2117  return nargs_pattern
2118 
def _get_nargs_pattern(self, action)
Definition: argparse.py:2082
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 crabWrapper._, argparse._ActionsContainer._option_string_actions, python.rootplot.argparse._ActionsContainer._option_string_actions, python.rootplot.argparse._ArgumentGroup._option_string_actions, TreeStruct.error, MomentumConstraint.error, pat::MHT.error(), BinomialProbability.error(), CSCPairConstraint.error(), count_t.error(), Measurement1DFloat.error(), SiStripLaserRecHit2D.error, Measurement1D.error(), SamplingAnalysis.error(), SaxToDom.error(), pat::LookupTableRecord.error(), FedTimingAnalysis.error(), SaxToDom2.error(), EcalUncalibRecHitRatioMethodAlgo< C >::Ratio.error, ApvTimingAnalysis.error(), EcalUncalibRecHitRatioMethodAlgo< C >::Tmax.error, CSCPairResidualsConstraint.error(), edm::HLTGlobalStatus.error(), edm::HLTPathStatus.error(), edm::TriggerResultsByName.error(), reco::VertexCompositePtrCandidate.error(), stats_t< T >.error(), PTrajectoryStateOnDet.error(), cscdqm::XMLFileErrorHandler.error(), PhysicsTools::Calibration::Histogram< Value_t, Axis_t >.error(), lhef::LHERunInfo::XSec.error(), DDLSAX2Handler.error(), PhysicsTools::Calibration::Histogram2D< Value_t, AxisX_t, AxisY_t >.error(), MuonErrorMatrix.error, SimpleSAXParser::ParserError.error(), PhysicsTools::Calibration::Histogram3D< Value_t, AxisX_t, AxisY_t, AxisZ_t >.error(), funct::GaussIntegrator.error(), TriggerRatesMonitor::HLTRatesPlots.error, reco::Vertex.error(), CSCDCCExaminer.error(), reco::TrackBase.error(), MatacqTBRawEvent.error, dataset.Dataset.error, MatacqRawEvent.error, argparse.ArgumentParser.error(), python.rootplot.argparse.ArgumentParser.error(), argparse._ActionsContainer.prefix_chars, and python.rootplot.argparse._ActionsContainer.prefix_chars.

Referenced by argparse.ArgumentParser._parse_optional().

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

Definition at line 1641 of file argparse.py.

References argparse._ActionsContainer._actions, python.rootplot.argparse._ActionsContainer._actions, and python.rootplot.argparse._ArgumentGroup._actions.

1642  return [action
1643  for action in self._actions
1644  if action.option_strings]
1645 
def _get_optional_actions(self)
Definition: argparse.py:1641
def argparse.ArgumentParser._get_positional_actions (   self)
private
def argparse.ArgumentParser._get_value (   self,
  action,
  arg_string 
)
private

Definition at line 2167 of file argparse.py.

References crabWrapper._, argparse._ActionsContainer._registry_get(), and python.rootplot.argparse._ActionsContainer._registry_get().

Referenced by argparse.ArgumentParser._get_values(), and argparse.ArgumentParser.parse_known_args().

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

Definition at line 2122 of file argparse.py.

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

Referenced by argparse.ArgumentParser._parse_known_args().

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

Definition at line 1953 of file argparse.py.

References crabWrapper._, argparse.ArgumentParser._get_nargs_pattern(), and python.rootplot.argparse.ArgumentParser._get_nargs_pattern().

Referenced by argparse.ArgumentParser._parse_known_args().

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

Referenced by argparse.ArgumentParser._parse_known_args().

1972  def _match_arguments_partial(self, actions, arg_strings_pattern):
1973  # progressively shorten the actions list by slicing off the
1974  # final actions until we find a match
1975  result = []
1976  for i in range(len(actions), 0, -1):
1977  actions_slice = actions[:i]
1978  pattern = ''.join([self._get_nargs_pattern(action)
1979  for action in actions_slice])
1980  match = _re.match(pattern, arg_strings_pattern)
1981  if match is not None:
1982  result.extend([len(string) for string in match.groups()])
1983  break
1984 
1985  # return the list of arg string counts
1986  return result
1987 
def _match_arguments_partial(self, actions, arg_strings_pattern)
Definition: argparse.py:1972
def _get_nargs_pattern(self, action)
Definition: argparse.py:2082
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 crabWrapper._, argparse._ActionsContainer._actions, python.rootplot.argparse._ActionsContainer._actions, python.rootplot.argparse._ArgumentGroup._actions, argparse._get_action_name(), argparse.ArgumentParser._get_positional_actions(), python.rootplot.argparse.ArgumentParser._get_positional_actions(), argparse.ArgumentParser._get_values(), python.rootplot.argparse.ArgumentParser._get_values(), argparse.ArgumentParser._match_argument(), python.rootplot.argparse.ArgumentParser._match_argument(), argparse.ArgumentParser._match_arguments_partial(), python.rootplot.argparse.ArgumentParser._match_arguments_partial(), argparse._ActionsContainer._mutually_exclusive_groups, python.rootplot.argparse._ActionsContainer._mutually_exclusive_groups, argparse._ActionsContainer._option_string_actions, python.rootplot.argparse._ActionsContainer._option_string_actions, python.rootplot.argparse._ArgumentGroup._option_string_actions, 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._set, argparse.action, TreeStruct.error, MomentumConstraint.error, pat::MHT.error(), BinomialProbability.error(), count_t.error(), CSCPairConstraint.error(), Measurement1DFloat.error(), SiStripLaserRecHit2D.error, Measurement1D.error(), SamplingAnalysis.error(), pat::LookupTableRecord.error(), SaxToDom.error(), FedTimingAnalysis.error(), SaxToDom2.error(), EcalUncalibRecHitRatioMethodAlgo< C >::Ratio.error, ApvTimingAnalysis.error(), EcalUncalibRecHitRatioMethodAlgo< C >::Tmax.error, CSCPairResidualsConstraint.error(), edm::HLTGlobalStatus.error(), edm::HLTPathStatus.error(), edm::TriggerResultsByName.error(), reco::VertexCompositePtrCandidate.error(), stats_t< T >.error(), PTrajectoryStateOnDet.error(), cscdqm::XMLFileErrorHandler.error(), PhysicsTools::Calibration::Histogram< Value_t, Axis_t >.error(), lhef::LHERunInfo::XSec.error(), DDLSAX2Handler.error(), MuonErrorMatrix.error, PhysicsTools::Calibration::Histogram2D< Value_t, AxisX_t, AxisY_t >.error(), SimpleSAXParser::ParserError.error(), PhysicsTools::Calibration::Histogram3D< Value_t, AxisX_t, AxisY_t, AxisZ_t >.error(), funct::GaussIntegrator.error(), TriggerRatesMonitor::HLTRatesPlots.error, reco::Vertex.error(), CSCDCCExaminer.error(), reco::TrackBase.error(), MatacqTBRawEvent.error, dataset.Dataset.error, MatacqRawEvent.error, argparse.ArgumentParser.error(), python.rootplot.argparse.ArgumentParser.error(), argparse.ArgumentParser.fromfile_prefix_chars, python.rootplot.argparse.ArgumentParser.fromfile_prefix_chars, join(), hpstanc_transforms.max, min(), argparse._ActionsContainer.prefix_chars, python.rootplot.argparse._ActionsContainer.prefix_chars, and ComparisonHelper.zip().

Referenced by argparse.ArgumentParser.parse_known_args().

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

Definition at line 1988 of file argparse.py.

References crabWrapper._, argparse.ArgumentParser._get_option_tuples(), python.rootplot.argparse.ArgumentParser._get_option_tuples(), argparse._ActionsContainer._has_negative_number_optionals, python.rootplot.argparse._ActionsContainer._has_negative_number_optionals, python.rootplot.argparse._ArgumentGroup._has_negative_number_optionals, argparse._ActionsContainer._option_string_actions, python.rootplot.argparse._ActionsContainer._option_string_actions, python.rootplot.argparse._ArgumentGroup._option_string_actions, TreeStruct.error, MomentumConstraint.error, pat::MHT.error(), BinomialProbability.error(), CSCPairConstraint.error(), count_t.error(), Measurement1DFloat.error(), SiStripLaserRecHit2D.error, Measurement1D.error(), SamplingAnalysis.error(), pat::LookupTableRecord.error(), SaxToDom.error(), FedTimingAnalysis.error(), SaxToDom2.error(), EcalUncalibRecHitRatioMethodAlgo< C >::Ratio.error, ApvTimingAnalysis.error(), EcalUncalibRecHitRatioMethodAlgo< C >::Tmax.error, CSCPairResidualsConstraint.error(), edm::HLTGlobalStatus.error(), edm::HLTPathStatus.error(), edm::TriggerResultsByName.error(), reco::VertexCompositePtrCandidate.error(), stats_t< T >.error(), PTrajectoryStateOnDet.error(), cscdqm::XMLFileErrorHandler.error(), PhysicsTools::Calibration::Histogram< Value_t, Axis_t >.error(), lhef::LHERunInfo::XSec.error(), DDLSAX2Handler.error(), MuonErrorMatrix.error, PhysicsTools::Calibration::Histogram2D< Value_t, AxisX_t, AxisY_t >.error(), SimpleSAXParser::ParserError.error(), PhysicsTools::Calibration::Histogram3D< Value_t, AxisX_t, AxisY_t, AxisZ_t >.error(), funct::GaussIntegrator.error(), TriggerRatesMonitor::HLTRatesPlots.error, reco::Vertex.error(), CSCDCCExaminer.error(), reco::TrackBase.error(), MatacqTBRawEvent.error, dataset.Dataset.error, MatacqRawEvent.error, argparse.ArgumentParser.error(), python.rootplot.argparse.ArgumentParser.error(), join(), argparse._ActionsContainer.prefix_chars, and python.rootplot.argparse._ActionsContainer.prefix_chars.

Referenced by argparse.ArgumentParser._parse_known_args().

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

Referenced by argparse.ArgumentParser.print_help(), argparse.ArgumentParser.print_usage(), and argparse.ArgumentParser.print_version().

2246  def _print_message(self, message, file=None):
2247  if message:
2248  if file is None:
2249  file = _sys.stderr
2250  file.write(message)
2251 
def _print_message(self, message, file=None)
Definition: argparse.py:2246
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(), python.rootplot.argparse.ArgumentParser._read_args_from_files(), TreeStruct.error, MomentumConstraint.error, pat::MHT.error(), BinomialProbability.error(), count_t.error(), CSCPairConstraint.error(), Measurement1DFloat.error(), SiStripLaserRecHit2D.error, Measurement1D.error(), SamplingAnalysis.error(), SaxToDom.error(), pat::LookupTableRecord.error(), FedTimingAnalysis.error(), SaxToDom2.error(), EcalUncalibRecHitRatioMethodAlgo< C >::Ratio.error, ApvTimingAnalysis.error(), EcalUncalibRecHitRatioMethodAlgo< C >::Tmax.error, CSCPairResidualsConstraint.error(), edm::HLTGlobalStatus.error(), edm::HLTPathStatus.error(), edm::TriggerResultsByName.error(), reco::VertexCompositePtrCandidate.error(), stats_t< T >.error(), PTrajectoryStateOnDet.error(), cscdqm::XMLFileErrorHandler.error(), PhysicsTools::Calibration::Histogram< Value_t, Axis_t >.error(), lhef::LHERunInfo::XSec.error(), DDLSAX2Handler.error(), PhysicsTools::Calibration::Histogram2D< Value_t, AxisX_t, AxisY_t >.error(), MuonErrorMatrix.error, SimpleSAXParser::ParserError.error(), PhysicsTools::Calibration::Histogram3D< Value_t, AxisX_t, AxisY_t, AxisZ_t >.error(), funct::GaussIntegrator.error(), TriggerRatesMonitor::HLTRatesPlots.error, reco::Vertex.error(), CSCDCCExaminer.error(), reco::TrackBase.error(), MatacqTBRawEvent.error, dataset.Dataset.error, MatacqRawEvent.error, argparse.ArgumentParser.error(), python.rootplot.argparse.ArgumentParser.error(), argparse.ArgumentParser.fromfile_prefix_chars, python.rootplot.argparse.ArgumentParser.fromfile_prefix_chars, and harvestTrackValidationPlots.str.

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

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

Definition at line 1603 of file argparse.py.

References crabWrapper._, argparse.ArgumentParser._get_formatter(), python.rootplot.argparse.ArgumentParser._get_formatter(), argparse.ArgumentParser._get_positional_actions(), python.rootplot.argparse.ArgumentParser._get_positional_actions(), argparse._ActionsContainer._mutually_exclusive_groups, python.rootplot.argparse._ActionsContainer._mutually_exclusive_groups, argparse._ActionsContainer._pop_action_class(), python.rootplot.argparse._ActionsContainer._pop_action_class(), argparse.ArgumentParser._positionals, python.rootplot.argparse.ArgumentParser._positionals, argparse.ArgumentParser._subparsers, python.rootplot.argparse.ArgumentParser._subparsers, argparse._ActionsContainer.add_argument_group(), python.rootplot.argparse._ActionsContainer.add_argument_group(), TreeStruct.error, MomentumConstraint.error, pat::MHT.error(), BinomialProbability.error(), count_t.error(), CSCPairConstraint.error(), Measurement1DFloat.error(), SiStripLaserRecHit2D.error, Measurement1D.error(), SamplingAnalysis.error(), SaxToDom.error(), pat::LookupTableRecord.error(), FedTimingAnalysis.error(), SaxToDom2.error(), EcalUncalibRecHitRatioMethodAlgo< C >::Ratio.error, ApvTimingAnalysis.error(), EcalUncalibRecHitRatioMethodAlgo< C >::Tmax.error, CSCPairResidualsConstraint.error(), edm::HLTGlobalStatus.error(), edm::HLTPathStatus.error(), edm::TriggerResultsByName.error(), reco::VertexCompositePtrCandidate.error(), stats_t< T >.error(), PTrajectoryStateOnDet.error(), cscdqm::XMLFileErrorHandler.error(), PhysicsTools::Calibration::Histogram< Value_t, Axis_t >.error(), lhef::LHERunInfo::XSec.error(), DDLSAX2Handler.error(), PhysicsTools::Calibration::Histogram2D< Value_t, AxisX_t, AxisY_t >.error(), MuonErrorMatrix.error, SimpleSAXParser::ParserError.error(), PhysicsTools::Calibration::Histogram3D< Value_t, AxisX_t, AxisY_t, AxisZ_t >.error(), funct::GaussIntegrator.error(), TriggerRatesMonitor::HLTRatesPlots.error, reco::Vertex.error(), CSCDCCExaminer.error(), reco::TrackBase.error(), MatacqTBRawEvent.error, dataset.Dataset.error, MatacqRawEvent.error, argparse.ArgumentParser.error(), python.rootplot.argparse.ArgumentParser.error(), digi_MixPreMix_cfi.strip, argparse.ArgumentParser.usage, and python.rootplot.argparse.ArgumentParser.usage.

1603  def add_subparsers(self, **kwargs):
1604  if self._subparsers is not None:
1605  self.error(_('cannot have multiple subparser arguments'))
1606 
1607  # add the parser class to the arguments if it's not present
1608  kwargs.setdefault('parser_class', type(self))
1609 
1610  if 'title' in kwargs or 'description' in kwargs:
1611  title = _(kwargs.pop('title', 'subcommands'))
1612  description = _(kwargs.pop('description', None))
1613  self._subparsers = self.add_argument_group(title, description)
1614  else:
1615  self._subparsers = self._positionals
1616 
1617  # prog defaults to the usage message of this parser, skipping
1618  # optional arguments and with no "usage:" prefix
1619  if kwargs.get('prog') is None:
1620  formatter = self._get_formatter()
1621  positionals = self._get_positional_actions()
1622  groups = self._mutually_exclusive_groups
1623  formatter.add_usage(self.usage, positionals, groups, '')
1624  kwargs['prog'] = formatter.format_help().strip()
1625 
1626  # create the parsers action and add it to the positionals list
1627  parsers_class = self._pop_action_class(kwargs, 'parsers')
1628  action = parsers_class(option_strings=[], **kwargs)
1629  self._subparsers._add_action(action)
1630 
1631  # return the created parsers action
1632  return action
1633 
def _get_positional_actions(self)
Definition: argparse.py:1646
def add_subparsers(self, kwargs)
Definition: argparse.py:1603
def error(self, message)
Definition: argparse.py:2260
def _pop_action_class(self, kwargs, default=None)
Definition: argparse.py:1401
def add_argument_group(self, args, kwargs)
Definition: argparse.py:1267
def _get_formatter(self)
Definition: argparse.py:2231
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 crabWrapper._, CaloSegment.exit(), statemachine::HandleFiles.exit(), statemachine::HandleRuns.exit(), statemachine::HandleLumis.exit(), Vispa.Main.Application.Application.exit(), argparse.ArgumentParser.exit(), python.rootplot.argparse.ArgumentParser.exit(), argparse.ArgumentParser.print_usage(), python.rootplot.argparse.ArgumentParser.print_usage(), argparse.ArgumentParser.prog, and python.rootplot.argparse.ArgumentParser.prog.

Referenced by argparse.ArgumentParser._get_option_tuples(), argparse.ArgumentParser._parse_known_args(), argparse.ArgumentParser._parse_optional(), argparse.ArgumentParser._read_args_from_files(), argparse.ArgumentParser.add_subparsers(), Page1Parser.Page1Parser.check_for_whole_start_tag(), argparse.ArgumentParser.parse_args(), and argparse.ArgumentParser.parse_known_args().

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

Definition at line 2255 of file argparse.py.

Referenced by argparse.ArgumentParser.error().

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

Definition at line 2203 of file argparse.py.

References argparse._ActionsContainer._action_groups, python.rootplot.argparse._ActionsContainer._action_groups, argparse._ActionsContainer._actions, python.rootplot.argparse._ActionsContainer._actions, python.rootplot.argparse._ArgumentGroup._actions, argparse.ArgumentParser._get_formatter(), python.rootplot.argparse.ArgumentParser._get_formatter(), argparse._ActionsContainer._mutually_exclusive_groups, python.rootplot.argparse._ActionsContainer._mutually_exclusive_groups, cond::persistency::GTEditorData.description, cond::persistency::IOVEditorData.description, Entry< T >.description, ExpressionHisto< T >.description, ProcTMVA::Method.description, cond::TagMetadata_t.description, cond::GTMetadata_t.description, argparse._ActionsContainer.description, python.rootplot.argparse._ActionsContainer.description, argparse.ArgumentParser.epilog, python.rootplot.argparse.ArgumentParser.epilog, argparse.ArgumentParser.usage, and python.rootplot.argparse.ArgumentParser.usage.

Referenced by argparse.ArgumentParser.print_help().

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

Definition at line 1654 of file argparse.py.

References crabWrapper._, TreeStruct.error, MomentumConstraint.error, pat::MHT.error(), BinomialProbability.error(), count_t.error(), CSCPairConstraint.error(), Measurement1DFloat.error(), SiStripLaserRecHit2D.error, Measurement1D.error(), SamplingAnalysis.error(), SaxToDom.error(), pat::LookupTableRecord.error(), FedTimingAnalysis.error(), SaxToDom2.error(), EcalUncalibRecHitRatioMethodAlgo< C >::Ratio.error, ApvTimingAnalysis.error(), EcalUncalibRecHitRatioMethodAlgo< C >::Tmax.error, CSCPairResidualsConstraint.error(), edm::HLTGlobalStatus.error(), edm::HLTPathStatus.error(), edm::TriggerResultsByName.error(), reco::VertexCompositePtrCandidate.error(), stats_t< T >.error(), PTrajectoryStateOnDet.error(), cscdqm::XMLFileErrorHandler.error(), PhysicsTools::Calibration::Histogram< Value_t, Axis_t >.error(), lhef::LHERunInfo::XSec.error(), DDLSAX2Handler.error(), PhysicsTools::Calibration::Histogram2D< Value_t, AxisX_t, AxisY_t >.error(), MuonErrorMatrix.error, SimpleSAXParser::ParserError.error(), PhysicsTools::Calibration::Histogram3D< Value_t, AxisX_t, AxisY_t, AxisZ_t >.error(), funct::GaussIntegrator.error(), TriggerRatesMonitor::HLTRatesPlots.error, reco::Vertex.error(), CSCDCCExaminer.error(), reco::TrackBase.error(), MatacqTBRawEvent.error, dataset.Dataset.error, MatacqRawEvent.error, argparse.ArgumentParser.error(), python.rootplot.argparse.ArgumentParser.error(), join(), argparse.ArgumentParser.parse_known_args(), and python.rootplot.argparse.ArgumentParser.parse_known_args().

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

Definition at line 1661 of file argparse.py.

References argparse._ActionsContainer._actions, python.rootplot.argparse._ActionsContainer._actions, python.rootplot.argparse._ArgumentGroup._actions, argparse._ActionsContainer._defaults, python.rootplot.argparse._ActionsContainer._defaults, python.rootplot.argparse._ArgumentGroup._defaults, argparse.ArgumentParser._get_value(), python.rootplot.argparse.ArgumentParser._get_value(), argparse.ArgumentParser._parse_known_args(), python.rootplot.argparse.ArgumentParser._parse_known_args(), TreeStruct.error, MomentumConstraint.error, pat::MHT.error(), BinomialProbability.error(), CSCPairConstraint.error(), count_t.error(), Measurement1DFloat.error(), SiStripLaserRecHit2D.error, Measurement1D.error(), SamplingAnalysis.error(), pat::LookupTableRecord.error(), SaxToDom.error(), FedTimingAnalysis.error(), SaxToDom2.error(), EcalUncalibRecHitRatioMethodAlgo< C >::Ratio.error, ApvTimingAnalysis.error(), EcalUncalibRecHitRatioMethodAlgo< C >::Tmax.error, CSCPairResidualsConstraint.error(), edm::HLTGlobalStatus.error(), edm::HLTPathStatus.error(), edm::TriggerResultsByName.error(), reco::VertexCompositePtrCandidate.error(), stats_t< T >.error(), PTrajectoryStateOnDet.error(), cscdqm::XMLFileErrorHandler.error(), PhysicsTools::Calibration::Histogram< Value_t, Axis_t >.error(), lhef::LHERunInfo::XSec.error(), DDLSAX2Handler.error(), MuonErrorMatrix.error, PhysicsTools::Calibration::Histogram2D< Value_t, AxisX_t, AxisY_t >.error(), SimpleSAXParser::ParserError.error(), PhysicsTools::Calibration::Histogram3D< Value_t, AxisX_t, AxisY_t, AxisZ_t >.error(), funct::GaussIntegrator.error(), TriggerRatesMonitor::HLTRatesPlots.error, reco::Vertex.error(), CSCDCCExaminer.error(), reco::TrackBase.error(), MatacqTBRawEvent.error, dataset.Dataset.error, MatacqRawEvent.error, argparse.ArgumentParser.error(), python.rootplot.argparse.ArgumentParser.error(), and harvestTrackValidationPlots.str.

Referenced by argparse.ArgumentParser.parse_args().

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

Member Data Documentation

argparse.ArgumentParser._optionals
private

Definition at line 1556 of file argparse.py.

argparse.ArgumentParser._positionals
private

Definition at line 1555 of file argparse.py.

Referenced by argparse.ArgumentParser.add_subparsers().

argparse.ArgumentParser._subparsers
private

Definition at line 1557 of file argparse.py.

Referenced by argparse.ArgumentParser.add_subparsers().

argparse.ArgumentParser.add_help

Definition at line 1552 of file argparse.py.

argparse.ArgumentParser.epilog

Definition at line 1548 of file argparse.py.

Referenced by argparse.ArgumentParser.format_help().

argparse.ArgumentParser.formatter_class

Definition at line 1550 of file argparse.py.

Referenced by argparse.ArgumentParser._get_formatter().

argparse.ArgumentParser.fromfile_prefix_chars
argparse.ArgumentParser.prog
argparse.ArgumentParser.version