lsst.pex.config  16.0-6-g0838257+4
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
lsst.pex.config.choiceField.ChoiceField Class Reference
Inheritance diagram for lsst.pex.config.choiceField.ChoiceField:
lsst.pex.config.config.Field

Public Member Functions

def __init__ (self, doc, dtype, allowed, default=None, optional=True)
 
def rename (self, instance)
 
def validate (self, instance)
 
def freeze (self, instance)
 
def save (self, outfile, instance)
 
def toDict (self, instance)
 
def __get__ (self, instance, owner=None, at=None, label="default")
 
def __set__ (self, instance, value, at=None, label='assignment')
 
def __delete__ (self, instance, at=None, label='deletion')
 

Public Attributes

 allowed
 
 source
 
 dtype
 
 doc
 
 default
 
 check
 
 optional
 

Static Public Attributes

 supportedTypes = set((str, bool, float, int, complex))
 

Detailed Description

Defines a Config Field which allows only a set of values
All allowed must be of the same type.
Allowed values should be provided as a dict of value, doc string pairs

Definition at line 28 of file choiceField.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.pex.config.choiceField.ChoiceField.__init__ (   self,
  doc,
  dtype,
  allowed,
  default = None,
  optional = True 
)

Definition at line 35 of file choiceField.py.

Member Function Documentation

◆ __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 329 of file config.py.

◆ __get__()

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 272 of file config.py.

◆ __set__()

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

Derived Field classes may need to override the behavior. When overriding
__set__, Field authors should follow the following rules:
* Do not allow modification of frozen configs
* Validate the new value *BEFORE* modifying the field. Except if the
    new value is None. None is special and no attempt should be made to
    validate it until Config.validate is called.
* Do not modify the Config instance to contain invalid values.
* If the field is modified, update the history of the field to reflect the
    changes

In order to decrease the need to implement this method in derived Field
types, value validation is performed in the method _validateValue. If
only the validation step differs in the derived Field, it is simpler to
implement _validateValue than to re-implement __set__. More complicated
behavior, however, may require a reimplementation.

Definition at line 291 of file config.py.

◆ freeze()

def lsst.pex.config.config.Field.freeze (   self,
  instance 
)
inherited
Make this field read-only.
Only important for fields which hold sub-configs.
Fields which hold subconfigs should freeze each sub-config.

Definition at line 211 of file config.py.

◆ rename()

def lsst.pex.config.config.Field.rename (   self,
  instance 
)
inherited
Rename an instance of this field, not the field itself.
This is invoked by the owning config object and should not be called
directly

Only useful for fields which hold sub-configs.
Fields which hold subconfigs should rename each sub-config with
the full field name as generated by _joinNamePath

Definition at line 186 of file config.py.

◆ save()

def lsst.pex.config.config.Field.save (   self,
  outfile,
  instance 
)
inherited
Saves an instance of this field to file.
This is invoked by the owning config object, and should not be called
directly

outfile ---- an open output stream.

Definition at line 238 of file config.py.

◆ toDict()

def lsst.pex.config.config.Field.toDict (   self,
  instance 
)
inherited
Convert the field value so that it can be set as the value of an item
in a dict.
This is invoked by the owning config object and should not be called
directly

Simple values are passed through. Complex data structures must be
manipulated. For example, a field holding a sub-config should, instead
of the subconfig object, return a dict where the keys are the field
names in the subconfig, and the values are the field values in the
subconfig.

Definition at line 257 of file config.py.

◆ validate()

def lsst.pex.config.config.Field.validate (   self,
  instance 
)
inherited
Base validation for any field.
Ensures that non-optional fields are not None.
Ensures type correctness
Ensures that user-provided check function is valid
Most derived Field types should call Field.validate if they choose
to re-implement validate

Definition at line 198 of file config.py.

Member Data Documentation

◆ allowed

lsst.pex.config.choiceField.ChoiceField.allowed

Definition at line 36 of file choiceField.py.

◆ check

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

Definition at line 182 of file config.py.

◆ default

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

Definition at line 181 of file config.py.

◆ doc

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

Definition at line 179 of file config.py.

◆ dtype

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

Definition at line 178 of file config.py.

◆ optional

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

Definition at line 183 of file config.py.

◆ source

lsst.pex.config.choiceField.ChoiceField.source

Definition at line 53 of file choiceField.py.

◆ supportedTypes

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

Definition at line 153 of file config.py.


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