LSSTApplications
10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
|
Public Member Functions | |
def | __iter__ |
Iterate over fields. More... | |
def | keys |
Return the list of field names. More... | |
def | values |
Return the list of field values. More... | |
def | items |
Return the list of (field name, field value) pairs. More... | |
def | iteritems |
Iterate over (field name, field value) pairs. More... | |
def | itervalues |
Iterate over field values. More... | |
def | iterkeys |
Iterate over field names. More... | |
def | __contains__ |
Return True if the specified field exists in this config. More... | |
def | __new__ |
Allocate a new Config object. More... | |
def | __reduce__ |
def | setDefaults |
def | update |
Update values specified by the keyword arguments. More... | |
def | load |
Modify this config in place by executing the Python code in the named file. More... | |
def | loadFromStream |
Modify this config in place by executing the python code in the provided stream. More... | |
def | save |
Save a python script to the named file, which, when loaded, reproduces this Config. More... | |
def | saveToStream |
Save a python script to a stream, which, when loaded, reproduces this Config. More... | |
def | freeze |
Make this Config and all sub-configs read-only. More... | |
def | toDict |
Return a dict of field name: value. More... | |
def | validate |
Validate the Config; raise an exception if invalid. More... | |
def | formatHistory |
Format the specified config field's history to a more human-readable format. More... | |
def | __setattr__ |
Regulate which attributes can be set. More... | |
def | __delattr__ |
def | __eq__ |
def | __ne__ |
def | __str__ |
def | __repr__ |
def | compare |
Compare two Configs for equality; return True if equal. More... | |
Properties | |
history = property(lambda x: x._history) | |
Private Member Functions | |
def | _save |
Save this Config to an open stream object. More... | |
def | _rename |
Rename this Config object in its parent config. More... | |
Private Attributes | |
_frozen | |
_name | |
Static Private Attributes | |
__metaclass__ = ConfigMeta | |
Base class for control objects. A Config object will usually have several Field instances as class attributes; these are used to define most of the base class behavior. Simple derived class should be able to be defined simply by setting those attributes. Config also emulates a dict of field name: field value
def lsst.pex.config.config.Config.__contains__ | ( | self, | |
name | |||
) |
Return True if the specified field exists in this config.
[in] | name | field name to test for |
Definition at line 438 of file config.py.
def lsst.pex.config.config.Config.__delattr__ | ( | self, | |
attr, | |||
at = None , |
|||
label = "deletion" |
|||
) |
def lsst.pex.config.config.Config.__iter__ | ( | self | ) |
Iterate over fields.
def lsst.pex.config.config.Config.__ne__ | ( | self, | |
other | |||
) |
def lsst.pex.config.config.Config.__new__ | ( | cls, | |
args, | |||
kw | |||
) |
Allocate a new Config object.
In order to ensure that all Config object are always in a proper state when handed to users or to derived Config classes, some attributes are handled at allocation time rather than at initialization
This ensures that even if a derived Config class implements init, the author does not need to be concerned about when or even if he should call the base Config.__init__
Definition at line 445 of file config.py.
def lsst.pex.config.config.Config.__reduce__ | ( | self | ) |
Reduction for pickling (function with arguments to reproduce). We need to condense and reconstitute the Config, since it may contain lambdas (as the 'check' elements) that cannot be pickled.
Definition at line 477 of file config.py.
def lsst.pex.config.config.Config.__repr__ | ( | self | ) |
Definition at line 716 of file config.py.
def lsst.pex.config.config.Config.__setattr__ | ( | self, | |
attr, | |||
value, | |||
at = None , |
|||
label = "assignment" |
|||
) |
Regulate which attributes can be set.
Unlike normal python objects, Config objects are locked such that no additional attributes nor properties may be added to them dynamically.
Although this is not the standard Python behavior, it helps to protect users from accidentally mispelling a field name, or trying to set a non-existent field.
Definition at line 663 of file config.py.
def lsst.pex.config.config.Config.__str__ | ( | self | ) |
|
private |
Rename this Config object in its parent config.
[in] | name | new name for this config in its parent config |
Correct behavior is dependent on proper implementation of Field.rename. If implementing a new Field type, you may need to implement your own rename method.
Definition at line 619 of file config.py.
|
private |
Save this Config to an open stream object.
Definition at line 599 of file config.py.
def lsst.pex.config.config.Config.compare | ( | self, | |
other, | |||
shortcut = True , |
|||
rtol = 1E-8 , |
|||
atol = 1E-8 , |
|||
output = None |
|||
) |
Compare two Configs for equality; return True if equal.
If the Configs contain RegistryFields or ConfigChoiceFields, unselected Configs will not be compared.
[in] | other | Config object to compare with self. |
[in] | shortcut | If True, return as soon as an inequality is found. |
[in] | rtol | Relative tolerance for floating point comparisons. |
[in] | atol | Absolute tolerance for floating point comparisons. |
[in] | output | If not None, a callable that takes a string, used (possibly repeatedly) to report inequalities. |
Floating point comparisons are performed by numpy.allclose; refer to that for details.
Definition at line 722 of file config.py.
def lsst.pex.config.config.Config.formatHistory | ( | self, | |
name, | |||
kwargs | |||
) |
Format the specified config field's history to a more human-readable format.
[in] | name | name of field whose history is wanted |
[in] | kwargs | keyword arguments for lsst.pex.config.history.format |
Definition at line 648 of file config.py.
def lsst.pex.config.config.Config.freeze | ( | self | ) |
Make this Config and all sub-configs read-only.
Definition at line 592 of file config.py.
def lsst.pex.config.config.Config.items | ( | self | ) |
Return the list of (field name, field value) pairs.
Definition at line 418 of file config.py.
def lsst.pex.config.config.Config.iteritems | ( | self | ) |
Iterate over (field name, field value) pairs.
Definition at line 423 of file config.py.
def lsst.pex.config.config.Config.iterkeys | ( | self | ) |
Iterate over field names.
Definition at line 433 of file config.py.
def lsst.pex.config.config.Config.itervalues | ( | self | ) |
Iterate over field values.
Definition at line 428 of file config.py.
def lsst.pex.config.config.Config.keys | ( | self | ) |
Return the list of field names.
def lsst.pex.config.config.Config.load | ( | self, | |
filename, | |||
root = "config" |
|||
) |
Modify this config in place by executing the Python code in the named file.
[in] | filename | name of file containing config override code |
[in] | root | name of variable in file that refers to the config being overridden |
For example: if the value of root is "config" and the file contains this text: "config.myField = 5" then this config's field "myField" is set to 5.
Definition at line 514 of file config.py.
def lsst.pex.config.config.Config.loadFromStream | ( | self, | |
stream, | |||
root = "config" , |
|||
filename = None |
|||
) |
Modify this config in place by executing the python code in the provided stream.
[in] | stream | open file object, string or compiled string containing config override code |
[in] | root | name of variable in stream that refers to the config being overridden |
[in] | filename | name of config override file, or None if unknown or contained in the stream; used for error reporting |
For example: if the value of root is "config" and the stream contains this text: "config.myField = 5" then this config's field "myField" is set to 5.
Definition at line 531 of file config.py.
def lsst.pex.config.config.Config.save | ( | self, | |
filename, | |||
root = "config" |
|||
) |
Save a python script to the named file, which, when loaded, reproduces this Config.
[in] | filename | name of file to which to write the config |
[in] | root | name to use for the root config variable; the same value must be used when loading |
Definition at line 565 of file config.py.
def lsst.pex.config.config.Config.saveToStream | ( | self, | |
outfile, | |||
root = "config" |
|||
) |
Save a python script to a stream, which, when loaded, reproduces this Config.
outfile | [inout] open file object to which to write the config |
root | [in] name to use for the root config variable; the same value must be used when loading |
Definition at line 574 of file config.py.
def lsst.pex.config.config.Config.setDefaults | ( | self | ) |
def lsst.pex.config.config.Config.toDict | ( | self | ) |
Return a dict of field name: value.
Correct behavior is dependent on proper implementation of Field.toDict. If implementing a new Field type, you may need to implement your own toDict method.
Definition at line 608 of file config.py.
def lsst.pex.config.config.Config.update | ( | self, | |
kw | |||
) |
Update values specified by the keyword arguments.
Definition at line 496 of file config.py.
def lsst.pex.config.config.Config.validate | ( | self | ) |
Validate the Config; raise an exception if invalid.
The base class implementation performs type checks on all fields by calling Field.validate().
Complex single-field validation can be defined by deriving new Field types. As syntactic sugar, some derived Field types are defined in this module which handle recursing into sub-configs (ConfigField, ConfigChoiceField)
Inter-field relationships should only be checked in derived Config classes after calling this method, and base validation is complete
Definition at line 631 of file config.py.
def lsst.pex.config.config.Config.values | ( | self | ) |
Return the list of field values.
Definition at line 414 of file config.py.
|
staticprivate |
|
static |