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 | Properties | Private Member Functions | List of all members
lsst.pex.config.configurableField.ConfigurableInstance Class Reference
Inheritance diagram for lsst.pex.config.configurableField.ConfigurableInstance:

Public Member Functions

def __init__
 
def apply
 
def retarget
 
def __getattr__
 
def __setattr__
 
def __delattr__
 

Properties

 target = property(lambda x: x._target)
 
 ConfigClass = property(lambda x: x._ConfigClass)
 
 value = property(lambda x: x._value)
 

Private Member Functions

def __initValue
 

Detailed Description

Definition at line 27 of file configurableField.py.

Constructor & Destructor Documentation

def lsst.pex.config.configurableField.ConfigurableInstance.__init__ (   self,
  config,
  field,
  at = None,
  label = "default" 
)

Definition at line 42 of file configurableField.py.

42 
43  def __init__(self, config, field, at=None, label="default"):
44  object.__setattr__(self, "_config", config)
45  object.__setattr__(self, "_field", field)
46  object.__setattr__(self, "__doc__", config)
47  object.__setattr__(self, "_target", field.target)
48  object.__setattr__(self, "_ConfigClass",field.ConfigClass)
49  object.__setattr__(self, "_value", None)
50 
51  if at is None:
52  at = traceback.extract_stack()[:-1]
53  at += [self._field.source]
54  self.__initValue(at, label)
55 
56  history = config._history.setdefault(field.name, [])
57  history.append(("Targeted and initialized from defaults", at, label))

Member Function Documentation

def lsst.pex.config.configurableField.ConfigurableInstance.__delattr__ (   self,
  name,
  at = None,
  label = "delete" 
)
Pretend to be an isntance of  ConfigClass. 
Attributes defiend by ConfigurableInstance will shadow those defined in ConfigClass

Definition at line 122 of file configurableField.py.

123  def __delattr__(self, name, at=None, label="delete"):
124  """
125  Pretend to be an isntance of ConfigClass.
126  Attributes defiend by ConfigurableInstance will shadow those defined in ConfigClass
127  """
128  if self._config._frozen:
129  raise FieldValidationError(self._field, self._config, "Cannot modify a frozen Config")
130 
131  try:
132  #attribute exists in the ConfigurableInstance wrapper
133  object.__delattr__(self, name)
134  except AttributeError:
135  if at is None:
136  at = traceback.extract_stack()[:-1]
137  self._value.__delattr__(name, at=at, label=label)
138 
def lsst.pex.config.configurableField.ConfigurableInstance.__getattr__ (   self,
  name 
)

Definition at line 102 of file configurableField.py.

103  def __getattr__(self, name):
104  return getattr(self._value, name)
105 
def lsst.pex.config.configurableField.ConfigurableInstance.__initValue (   self,
  at,
  label 
)
private
if field.default is an instance of ConfigClass, custom construct
_value with the correct values from default.
otherwise call ConfigClass constructor

Definition at line 28 of file configurableField.py.

28 
29  def __initValue(self, at, label):
30  """
31  if field.default is an instance of ConfigClass, custom construct
32  _value with the correct values from default.
33  otherwise call ConfigClass constructor
34  """
35  name=_joinNamePath(self._config._name, self._field.name)
36  if type(self._field.default)==self.ConfigClass:
37  storage = self._field.default._storage
38  else:
39  storage = {}
40  value = self._ConfigClass(__name=name, __at=at, __label=label, **storage)
41  object.__setattr__(self, "_value", value)
def lsst.pex.config.configurableField.ConfigurableInstance.__setattr__ (   self,
  name,
  value,
  at = None,
  label = "assignment" 
)
Pretend to be an isntance of  ConfigClass. 
Attributes defined by ConfigurableInstance will shadow those defined in ConfigClass

Definition at line 106 of file configurableField.py.

107  def __setattr__(self, name, value, at=None, label="assignment"):
108  """
109  Pretend to be an isntance of ConfigClass.
110  Attributes defined by ConfigurableInstance will shadow those defined in ConfigClass
111  """
112  if self._config._frozen:
113  raise FieldValidationError(self._field, self._config, "Cannot modify a frozen Config")
114 
115  if name in self.__dict__:
116  #attribute exists in the ConfigurableInstance wrapper
117  object.__setattr__(self, name, value)
118  else:
119  if at is None:
120  at = traceback.extract_stack()[:-1]
121  self._value.__setattr__(name, value, at=at, label=label)
def lsst.pex.config.configurableField.ConfigurableInstance.apply (   self,
  args,
  kw 
)
Call the confirurable.
With argument config=self.value along with any positional and kw args

Definition at line 72 of file configurableField.py.

72 
73  def apply(self, *args, **kw):
74  """
75  Call the confirurable.
76  With argument config=self.value along with any positional and kw args
77  """
78  return self.target(*args, config=self.value, **kw)
def lsst.pex.config.configurableField.ConfigurableInstance.retarget (   self,
  target,
  ConfigClass = None,
  at = None,
  label = "retarget" 
)

Definition at line 82 of file configurableField.py.

82 
83  def retarget(self, target, ConfigClass=None, at=None, label="retarget"):
84  if self._config._frozen:
85  raise FieldValidationError(self._field, self._config, "Cannot modify a frozen Config")
86 
87  try:
88  ConfigClass = self._field.validateTarget(target,ConfigClass)
89  except BaseException, e:
90  raise FieldValidationError(self._field, self._config, e.message)
91 
92  if at is None:
93  at = traceback.extract_stack()[:-1]
94  object.__setattr__(self, "_target", target)
95  if ConfigClass != self.ConfigClass:
96  object.__setattr__(self, "_ConfigClass",ConfigClass)
97  self.__initValue(at, label)
98 
99  history = self._config._history.setdefault(self._field.name, [])
100  msg = "retarget(target=%s, ConfigClass=%s)"%(_typeStr(target), _typeStr(ConfigClass))
101  history.append((msg, at, label))

Property Documentation

lsst.pex.config.configurableField.ConfigurableInstance.ConfigClass = property(lambda x: x._ConfigClass)
static

Definition at line 65 of file configurableField.py.

lsst.pex.config.configurableField.ConfigurableInstance.target = property(lambda x: x._target)
static

Definition at line 61 of file configurableField.py.

lsst.pex.config.configurableField.ConfigurableInstance.value = property(lambda x: x._value)
static

Definition at line 70 of file configurableField.py.


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