lsst.pex.config  13.0-4-gbcd7061+10
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
lsst.pex.config.configChoiceField.ConfigChoiceField Class Reference
Inheritance diagram for lsst.pex.config.configChoiceField.ConfigChoiceField:
lsst.pex.config.config.Field lsst.pex.config.registry.RegistryField

Public Member Functions

def __init__ (self, doc, typemap, default=None, optional=False, multi=False)
 
def __get__ (self, instance, owner=None)
 
def __set__ (self, instance, value, at=None, label="assignment")
 
def rename (self, instance)
 
def validate (self, instance)
 
def toDict (self, instance)
 
def freeze (self, instance)
 
def save (self, outfile, instance)
 
def __deepcopy__ (self, memo)
 
def __get__ (self, instance, owner=None, at=None, label="default")
 
def __delete__ (self, instance, at=None, label='deletion')
 

Public Attributes

 typemap
 
 multi
 
 dtype
 
 doc
 
 default
 
 check
 
 optional
 
 source
 

Static Public Attributes

 instanceDictClass = ConfigInstanceDict
 
 supportedTypes = set((str, unicode, basestring, oldStringType, bool, float, int, complex))
 

Detailed Description

ConfigChoiceFields allow the config to choose from a set of possible Config types.
The set of allowable types is given by the typemap argument to the constructor

The typemap object must implement typemap[name], which must return a Config subclass.

While the typemap is shared by all instances of the field, each instance of
the field has its own instance of a particular sub-config type

For example:

  class AaaConfig(Config):
    somefield = Field(int, "...")
  TYPEMAP = {"A", AaaConfig}
  class MyConfig(Config):
      choice = ConfigChoiceField("doc for choice", TYPEMAP)

  instance = MyConfig()
  instance.choice['AAA'].somefield = 5
  instance.choice = "AAA"

Alternatively, the last line can be written:
  instance.choice.name = "AAA"

Validation of this field is performed only the "active" selection.
If active is None and the field is not optional, validation will fail.

ConfigChoiceFields can allow single selections or multiple selections.
Single selection fields set selection through property name, and
multi-selection fields use the property names.

ConfigChoiceFields also allow multiple values of the same type:
  TYPEMAP["CCC"] = AaaConfig
  TYPEMAP["BBB"] = AaaConfig

When saving a config with a ConfigChoiceField, the entire set is saved, as well as the active selection

Definition at line 281 of file configChoiceField.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.pex.config.configChoiceField.ConfigChoiceField.__init__ (   self,
  doc,
  typemap,
  default = None,
  optional = False,
  multi = False 
)

Definition at line 321 of file configChoiceField.py.

Member Function Documentation

◆ __deepcopy__()

def lsst.pex.config.configChoiceField.ConfigChoiceField.__deepcopy__ (   self,
  memo 
)
Customize deep-copying, because we always want a reference to the original typemap.

WARNING: this must be overridden by subclasses if they change the constructor signature!

Definition at line 408 of file configChoiceField.py.

◆ __delete__()

def lsst.pex.config.config.Field.__delete__ (   self,
  instance,
  at = None,
  label = 'deletion' 
)
inherited
Describe how attribute deletion should occur on the Config instance.
This is invoked by the owning config object and should not be called
directly

Definition at line 344 of file config.py.

◆ __get__() [1/2]

def lsst.pex.config.config.Field.__get__ (   self,
  instance,
  owner = None,
  at = None,
  label = "default" 
)
inherited
Define how attribute access should occur on the Config instance
This is invoked by the owning config object and should not be called
directly

When the field attribute is accessed on a Config class object, it
returns the field object itself in order to allow inspection of
Config classes.

When the field attribute is access on a config instance, the actual
value described by the field (and held by the Config instance) is
returned.

Definition at line 287 of file config.py.

◆ __get__() [2/2]

def lsst.pex.config.configChoiceField.ConfigChoiceField.__get__ (   self,
  instance,
  owner = None 
)

Definition at line 340 of file configChoiceField.py.

◆ __set__()

def lsst.pex.config.configChoiceField.ConfigChoiceField.__set__ (   self,
  instance,
  value,
  at = None,
  label = "assignment" 
)

Definition at line 346 of file configChoiceField.py.

◆ freeze()

def lsst.pex.config.configChoiceField.ConfigChoiceField.freeze (   self,
  instance 
)

Definition at line 393 of file configChoiceField.py.

◆ rename()

def lsst.pex.config.configChoiceField.ConfigChoiceField.rename (   self,
  instance 
)

Definition at line 360 of file configChoiceField.py.

◆ save()

def lsst.pex.config.configChoiceField.ConfigChoiceField.save (   self,
  outfile,
  instance 
)

Definition at line 398 of file configChoiceField.py.

◆ toDict()

def lsst.pex.config.configChoiceField.ConfigChoiceField.toDict (   self,
  instance 
)

Definition at line 377 of file configChoiceField.py.

◆ validate()

def lsst.pex.config.configChoiceField.ConfigChoiceField.validate (   self,
  instance 
)

Definition at line 365 of file configChoiceField.py.

Member Data Documentation

◆ check

lsst.pex.config.config.Field.check
inherited

Definition at line 197 of file config.py.

◆ default

lsst.pex.config.config.Field.default
inherited

Definition at line 196 of file config.py.

◆ doc

lsst.pex.config.config.Field.doc
inherited

Definition at line 194 of file config.py.

◆ dtype

lsst.pex.config.config.Field.dtype
inherited

Definition at line 193 of file config.py.

◆ instanceDictClass

lsst.pex.config.configChoiceField.ConfigChoiceField.instanceDictClass = ConfigInstanceDict
static

Definition at line 319 of file configChoiceField.py.

◆ multi

lsst.pex.config.configChoiceField.ConfigChoiceField.multi

Definition at line 326 of file configChoiceField.py.

◆ optional

lsst.pex.config.config.Field.optional
inherited

Definition at line 198 of file config.py.

◆ source

lsst.pex.config.config.Field.source
inherited

Definition at line 199 of file config.py.

◆ supportedTypes

lsst.pex.config.config.Field.supportedTypes = set((str, unicode, basestring, oldStringType, bool, float, int, complex))
staticinherited

Definition at line 164 of file config.py.

◆ typemap

lsst.pex.config.configChoiceField.ConfigChoiceField.typemap

Definition at line 325 of file configChoiceField.py.


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