|
def | __init__ (self, doc, dtype, default=None, check=None, optional=False) |
|
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') |
|
A field in a a Config.
Instances of Field should be class attributes of Config subclasses:
Field only supports basic data types (int, float, complex, bool, str)
class Example(Config):
myInt = Field(int, "an integer field!", default=0)
Definition at line 142 of file config.py.
def lsst.pex.config.config.Field.__set__ |
( |
|
self, |
|
|
|
instance, |
|
|
|
value, |
|
|
|
at = None , |
|
|
|
label = 'assignment' |
|
) |
| |
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 294 of file config.py.
def lsst.pex.config.config.Field.toDict |
( |
|
self, |
|
|
|
instance |
|
) |
| |
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 260 of file config.py.