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

Public Member Functions

def __init__
 
def add_subparsers
 
def error
 
def exit
 
def format_help
 
def format_usage
 
def format_version
 
def parse_args
 
def parse_known_args
 
def print_help
 
def print_usage
 
def print_version
 
- Public Member Functions inherited from argparse._AttributeHolder
def __repr__
 
- Public Member Functions inherited from argparse._ActionsContainer
def __init__
 
def add_argument
 
def add_argument_group
 
def add_mutually_exclusive_group
 
def register
 
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 _check_value
 
def _get_formatter
 
def _get_kwargs
 
def _get_nargs_pattern
 
def _get_option_tuples
 
def _get_optional_actions
 
def _get_positional_actions
 
def _get_value
 
def _get_values
 
def _match_argument
 
def _match_arguments_partial
 
def _parse_known_args
 
def _parse_optional
 
def _print_message
 
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
    - 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.

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

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._check_value (   self,
  action,
  value 
)
private

Definition at line 2187 of file argparse.py.

References join().

Referenced by argparse.ArgumentParser._get_values().

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._get_formatter (   self)
private

Definition at line 2231 of file argparse.py.

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

Referenced by argparse.ArgumentParser.add_subparsers(), argparse.ArgumentParser.format_help(), argparse.ArgumentParser.format_usage(), and argparse.ArgumentParser.format_version().

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

Definition at line 1588 of file argparse.py.

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

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_option_tuples (   self,
  option_string 
)
private

Definition at line 2038 of file argparse.py.

References 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, SaxToDom.error(), Measurement1D.error(), SamplingAnalysis.error(), pat::LookupTableRecord.error(), SaxToDom2.error(), FedTimingAnalysis.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(), 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(), funct::GaussIntegrator.error(), reco::Vertex.error(), TriggerRatesMonitor::HLTRatesPlots.error, CSCDCCExaminer.error(), reco::TrackBase.error(), MatacqTBRawEvent.error, dataset.Dataset.error, MatacqRawEvent.error, TiXmlDocument.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().

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_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  def _get_optional_actions(self):
1643  return [action
1644  for action in self._actions
1645  if action.option_strings]
def argparse.ArgumentParser._get_positional_actions (   self)
private

Definition at line 1646 of file argparse.py.

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

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

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_value (   self,
  action,
  arg_string 
)
private

Definition at line 2167 of file argparse.py.

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

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

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

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._match_argument (   self,
  action,
  arg_strings_pattern 
)
private

Definition at line 1953 of file argparse.py.

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

Referenced by argparse.ArgumentParser._parse_known_args().

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

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._parse_known_args (   self,
  arg_strings,
  namespace 
)
private

Definition at line 1692 of file argparse.py.

References 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(), SaxToDom.error(), SamplingAnalysis.error(), pat::LookupTableRecord.error(), SaxToDom2.error(), FedTimingAnalysis.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(), MuonErrorMatrix.error, PhysicsTools::Calibration::Histogram2D< Value_t, AxisX_t, AxisY_t >.error(), DDLSAX2Handler.error(), SimpleSAXParser::ParserError.error(), PhysicsTools::Calibration::Histogram3D< Value_t, AxisX_t, AxisY_t, AxisZ_t >.error(), funct::GaussIntegrator.error(), reco::Vertex.error(), TriggerRatesMonitor::HLTRatesPlots.error, CSCDCCExaminer.error(), reco::TrackBase.error(), MatacqTBRawEvent.error, dataset.Dataset.error, MatacqRawEvent.error, TiXmlDocument.error, argparse.ArgumentParser.error(), python.rootplot.argparse.ArgumentParser.error(), argparse.ArgumentParser.fromfile_prefix_chars, python.rootplot.argparse.ArgumentParser.fromfile_prefix_chars, join(), bookConverter.max, min(), argparse._ActionsContainer.prefix_chars, python.rootplot.argparse._ActionsContainer.prefix_chars, and ComparisonHelper.zip().

Referenced by argparse.ArgumentParser.parse_known_args().

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
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
T min(T a, T b)
Definition: MathUtil.h:58
string action
Definition: argparse.py:125
def _get_action_name
Definition: argparse.py:687
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def argparse.ArgumentParser._parse_optional (   self,
  arg_string 
)
private

Definition at line 1988 of file argparse.py.

References 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(), SaxToDom.error(), SamplingAnalysis.error(), pat::LookupTableRecord.error(), SaxToDom2.error(), FedTimingAnalysis.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(), MuonErrorMatrix.error, PhysicsTools::Calibration::Histogram2D< Value_t, AxisX_t, AxisY_t >.error(), DDLSAX2Handler.error(), SimpleSAXParser::ParserError.error(), PhysicsTools::Calibration::Histogram3D< Value_t, AxisX_t, AxisY_t, AxisZ_t >.error(), funct::GaussIntegrator.error(), reco::Vertex.error(), TriggerRatesMonitor::HLTRatesPlots.error, CSCDCCExaminer.error(), reco::TrackBase.error(), MatacqTBRawEvent.error, dataset.Dataset.error, MatacqRawEvent.error, TiXmlDocument.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().

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

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._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(), CSCPairConstraint.error(), count_t.error(), Measurement1DFloat.error(), SiStripLaserRecHit2D.error, SaxToDom.error(), Measurement1D.error(), SamplingAnalysis.error(), pat::LookupTableRecord.error(), SaxToDom2.error(), FedTimingAnalysis.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(), 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(), funct::GaussIntegrator.error(), reco::Vertex.error(), TriggerRatesMonitor::HLTRatesPlots.error, CSCDCCExaminer.error(), reco::TrackBase.error(), MatacqTBRawEvent.error, dataset.Dataset.error, MatacqRawEvent.error, TiXmlDocument.error, argparse.ArgumentParser.error(), python.rootplot.argparse.ArgumentParser.error(), argparse.ArgumentParser.fromfile_prefix_chars, and python.rootplot.argparse.ArgumentParser.fromfile_prefix_chars.

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

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.add_subparsers (   self,
  kwargs 
)

Definition at line 1603 of file argparse.py.

References 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, SaxToDom.error(), Measurement1D.error(), SamplingAnalysis.error(), pat::LookupTableRecord.error(), SaxToDom2.error(), FedTimingAnalysis.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(), 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(), funct::GaussIntegrator.error(), reco::Vertex.error(), TriggerRatesMonitor::HLTRatesPlots.error, CSCDCCExaminer.error(), reco::TrackBase.error(), MatacqTBRawEvent.error, dataset.Dataset.error, MatacqRawEvent.error, TiXmlDocument.error, argparse.ArgumentParser.error(), python.rootplot.argparse.ArgumentParser.error(), argparse.ArgumentParser.usage, and python.rootplot.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.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 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(), argparse.ArgumentParser.parse_args(), and argparse.ArgumentParser.parse_known_args().

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.exit (   self,
  status = 0,
  message = None 
)

Definition at line 2255 of file argparse.py.

Referenced by argparse.ArgumentParser.error().

2256  def exit(self, status=0, message=None):
2257  if message:
2258  _sys.stderr.write(message)
2259  _sys.exit(status)
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().

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_usage (   self)

Definition at line 2197 of file argparse.py.

References 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, argparse.ArgumentParser.usage, and python.rootplot.argparse.ArgumentParser.usage.

Referenced by argparse.ArgumentParser.print_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_version (   self)

Definition at line 2226 of file argparse.py.

References argparse.ArgumentParser._get_formatter(), python.rootplot.argparse.ArgumentParser._get_formatter(), MagFieldConfig.version, L1TUtmCutValue.version, MatrixInjector.MatrixInjector.version, confdbOfflineConverter.OfflineConverter.version, options.ConnectionHLTMenu.version, L1TUtmBin.version, TrackerInteractionGeometry.version, L1TUtmCondition.version, ora::MappingRawData.version, L1TUtmAlgorithm.version, L1TUtmScale.version, MatacqTBRawEvent::matacqHeader_t.version, DQMNet::CoreObject.version, L1TUtmObject.version, L1TUtmCut.version, XMLProcessor::_DBConfig.version, L1TUtmTriggerMenu.version, ScalersEventRecordRaw_v1.version, ScalersEventRecordRaw_v2.version, ScalersEventRecordRaw_v3.version, ScalersEventRecordRaw_v4.version, ScalersEventRecordRaw_v5.version, ScalersEventRecordRaw_v6.version, cmsHarvester.CMSHarvester.version, python.rootplot.argparse._VersionAction.version, TiXmlDeclaration.version, argparse.ArgumentParser.version, and python.rootplot.argparse.ArgumentParser.version.

Referenced by argparse.ArgumentParser.print_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.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(), count_t.error(), CSCPairConstraint.error(), Measurement1DFloat.error(), SiStripLaserRecHit2D.error, SaxToDom.error(), Measurement1D.error(), SamplingAnalysis.error(), pat::LookupTableRecord.error(), SaxToDom2.error(), FedTimingAnalysis.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(), 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(), funct::GaussIntegrator.error(), reco::Vertex.error(), TriggerRatesMonitor::HLTRatesPlots.error, CSCDCCExaminer.error(), reco::TrackBase.error(), MatacqTBRawEvent.error, dataset.Dataset.error, MatacqRawEvent.error, TiXmlDocument.error, argparse.ArgumentParser.error(), python.rootplot.argparse.ArgumentParser.error(), join(), argparse.ArgumentParser.parse_known_args(), and python.rootplot.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_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(), SaxToDom.error(), SamplingAnalysis.error(), pat::LookupTableRecord.error(), SaxToDom2.error(), FedTimingAnalysis.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(), 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(), funct::GaussIntegrator.error(), reco::Vertex.error(), TriggerRatesMonitor::HLTRatesPlots.error, CSCDCCExaminer.error(), reco::TrackBase.error(), MatacqTBRawEvent.error, dataset.Dataset.error, MatacqRawEvent.error, TiXmlDocument.error, argparse.ArgumentParser.error(), and python.rootplot.argparse.ArgumentParser.error().

Referenced by argparse.ArgumentParser.parse_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.print_help (   self,
  file = None 
)

Definition at line 2240 of file argparse.py.

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

2241  def print_help(self, file=None):
2242  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(), python.rootplot.argparse.ArgumentParser._print_message(), cmsHarvester.CMSHarvesterHelpFormatter.format_usage(), argparse.ArgumentParser.format_usage(), and python.rootplot.argparse.ArgumentParser.format_usage().

Referenced by argparse.ArgumentParser.error().

2238  def print_usage(self, file=None):
2239  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(), python.rootplot.argparse.ArgumentParser._print_message(), CSCDDUHeader.format_version(), CSCVDMBHeaderFormat.format_version(), CSCDMBHeader2005.format_version(), CSCDMBHeader.format_version(), CSCDMBHeader2013.format_version(), CSCSPHeader.format_version(), argparse.ArgumentParser.format_version(), and python.rootplot.argparse.ArgumentParser.format_version().

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

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

Definition at line 1551 of file argparse.py.

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

argparse.ArgumentParser.prog

Definition at line 1546 of file argparse.py.

Referenced by argparse.ArgumentParser._get_formatter(), and argparse.ArgumentParser.error().

argparse.ArgumentParser.usage

Definition at line 1547 of file argparse.py.

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

argparse.ArgumentParser.version

Definition at line 1549 of file argparse.py.

Referenced by validation.Sample.datasetpattern(), validation.Sample.filename(), and argparse.ArgumentParser.format_version().