lsst.pipe.base  14.0-6-ge2c9487+13
Public Member Functions | List of all members
lsst.pipe.base.argumentParser.IdValueAction Class Reference
Inheritance diagram for lsst.pipe.base.argumentParser.IdValueAction:

Public Member Functions

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

Detailed Description

argparse action callback to process a data ID into a dict.

Definition at line 1065 of file argumentParser.py.

Member Function Documentation

◆ __call__()

def lsst.pipe.base.argumentParser.IdValueAction.__call__ (   self,
  parser,
  namespace,
  values,
  option_string 
)
Parse ``--id`` data and append results to ``namespace.<argument>.idList``.

Parameters
----------
parser : `ArgumentParser`
    Argument parser.
namespace : `argparse.Namespace`
    Parsed command (an instance of argparse.Namespace). The following attributes are updated:

    - ``<idName>.idList``, where ``<idName>`` is the name of the ID argument, for instance ``"id"``
      for ID argument ``--id``.
values : `list`
    A list of data IDs; see Notes below.
option_string : `str`
    Option value specified by the user.

Notes
-----
The data format is::

    key1=value1_1[^value1_2[^value1_3...] key2=value2_1[^value2_2[^value2_3...]...

The values (e.g. ``value1_1``) may either be a string, or of the form ``"int..int"``
(e.g. ``"1..3"``) which is interpreted as ``"1^2^3"`` (inclusive, unlike a python range).
So ``"0^2..4^7..9"`` is equivalent to ``"0^2^3^4^7^8^9"``.  You may also specify a stride:
``"1..5:2"`` is ``"1^3^5"``.

The cross product is computed for keys with multiple values. For example::

    --id visit 1^2 ccd 1,1^2,2

results in the following data ID dicts being appended to ``namespace.<argument>.idList``:

    {"visit":1, "ccd":"1,1"}
    {"visit":2, "ccd":"1,1"}
    {"visit":1, "ccd":"2,2"}
    {"visit":2, "ccd":"2,2"}

Definition at line 1069 of file argumentParser.py.


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