LSST Applications  22.0.1,22.0.1+01bcf6a671,22.0.1+046ee49490,22.0.1+05c7de27da,22.0.1+0c6914dbf6,22.0.1+1220d50b50,22.0.1+12fd109e95,22.0.1+1a1dd69893,22.0.1+1c910dc348,22.0.1+1ef34551f5,22.0.1+30170c3d08,22.0.1+39153823fd,22.0.1+611137eacc,22.0.1+771eb1e3e8,22.0.1+94e66cc9ed,22.0.1+9a075d06e2,22.0.1+a5ff6e246e,22.0.1+a7db719c1a,22.0.1+ba0d97e778,22.0.1+bfe1ee9056,22.0.1+c4e1e0358a,22.0.1+cc34b8281e,22.0.1+d640e2c0fa,22.0.1+d72a2e677a,22.0.1+d9a6b571bd,22.0.1+e485e9761b,22.0.1+ebe8d3385e
LSST Data Management Base Package
Public Member Functions | List of all members
lsst.pipe.base.argumentParser.ConfigValueAction Class Reference
Inheritance diagram for lsst.pipe.base.argumentParser.ConfigValueAction:

Public Member Functions

def __call__ (self, parser, namespace, values, option_string)
 

Detailed Description

argparse action callback to override config parameters using
name=value pairs from the command-line.

Definition at line 1107 of file argumentParser.py.

Member Function Documentation

◆ __call__()

def lsst.pipe.base.argumentParser.ConfigValueAction.__call__ (   self,
  parser,
  namespace,
  values,
  option_string 
)
Override one or more config name value pairs.

Parameters
----------
parser : `argparse.ArgumentParser`
    Argument parser.
namespace : `argparse.Namespace`
    Parsed command. The ``namespace.config`` attribute is updated.
values : `list`
    A list of ``configItemName=value`` pairs.
option_string : `str`
    Option value specified by the user.

Definition at line 1112 of file argumentParser.py.

1112  def __call__(self, parser, namespace, values, option_string):
1113  """Override one or more config name value pairs.
1114 
1115  Parameters
1116  ----------
1117  parser : `argparse.ArgumentParser`
1118  Argument parser.
1119  namespace : `argparse.Namespace`
1120  Parsed command. The ``namespace.config`` attribute is updated.
1121  values : `list`
1122  A list of ``configItemName=value`` pairs.
1123  option_string : `str`
1124  Option value specified by the user.
1125  """
1126  if namespace.config is None:
1127  return
1128  for nameValue in values:
1129  name, sep, valueStr = nameValue.partition("=")
1130  if not valueStr:
1131  parser.error(f"{option_string} value {nameValue} must be in form name=value")
1132 
1133  # see if setting the string value works; if not, try eval
1134  try:
1135  setDottedAttr(namespace.config, name, valueStr)
1136  except AttributeError:
1137  parser.error(f"no config field: {name}")
1138  except Exception:
1139  try:
1140  value = eval(valueStr, {})
1141  except Exception:
1142  parser.error(f"cannot parse {valueStr!r} as a value for {name}")
1143  try:
1144  setDottedAttr(namespace.config, name, value)
1145  except Exception as e:
1146  parser.error(f"cannot set config.{name}={value!r}: {e}")
1147 
1148 
def setDottedAttr(item, name, value)

The documentation for this class was generated from the following file: