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 | Private Attributes | List of all members
lsst.pex.config.configChoiceField.ConfigInstanceDict Class Reference
Inheritance diagram for lsst.pex.config.configChoiceField.ConfigInstanceDict:

Public Member Functions

def __init__
 
def __contains__
 
def __len__
 
def __iter__
 
def __getitem__
 
def __setitem__
 
def __setattr__
 

Properties

 types = property(lambda x: x._field.typemap)
 
 names = property(_getNames, _setNames, _delNames)
 
 name = property(_getName, _setName, _delName)
 
 active = property(_getActive)
 

Private Member Functions

def _setSelection
 
def _getNames
 
def _setNames
 
def _delNames
 
def _getName
 
def _setName
 
def _delName
 
def _getActive
 
def _rename
 

Private Attributes

 _dict
 
 _selection
 
 _config
 
 _field
 
 _history
 
 __doc__
 

Detailed Description

A dict of instantiated configs, used to populate a ConfigChoiceField.

typemap must support the following:
- typemap[name]: return the config class associated with the given name

Definition at line 97 of file configChoiceField.py.

Constructor & Destructor Documentation

def lsst.pex.config.configChoiceField.ConfigInstanceDict.__init__ (   self,
  config,
  field 
)

Member Function Documentation

def lsst.pex.config.configChoiceField.ConfigInstanceDict.__contains__ (   self,
  k 
)

Definition at line 114 of file configChoiceField.py.

115  def __contains__(self, k): return k in self._field.typemap
def lsst.pex.config.configChoiceField.ConfigInstanceDict.__getitem__ (   self,
  k,
  at = None,
  label = "default" 
)

Definition at line 197 of file configChoiceField.py.

198  def __getitem__(self, k, at=None, label="default"):
199  try:
200  value = self._dict[k]
201  except KeyError:
202  try:
203  dtype = self._field.typemap[k]
204  except:
205  raise FieldValidationError(self._field, self._config,
206  "Unknown key %r in Registry/ConfigChoiceField" % k)
207  name = _joinNamePath(self._config._name, self._field.name, k)
208  if at is None:
209  at = traceback.extract_stack()[:-1] + [dtype._source]
210  value = self._dict.setdefault(k, dtype(__name=name, __at=at, __label=label))
211  return value
def lsst.pex.config.configChoiceField.ConfigInstanceDict.__iter__ (   self)

Definition at line 118 of file configChoiceField.py.

119  def __iter__(self): return iter(self._field.typemap)
def lsst.pex.config.configChoiceField.ConfigInstanceDict.__len__ (   self)

Definition at line 116 of file configChoiceField.py.

117  def __len__(self): return len(self._field.typemap)
def lsst.pex.config.configChoiceField.ConfigInstanceDict.__setattr__ (   self,
  attr,
  value,
  at = None,
  label = "assignment" 
)

Definition at line 244 of file configChoiceField.py.

245  def __setattr__(self, attr, value, at=None, label="assignment"):
246  if hasattr(getattr(self.__class__, attr, None), '__set__'):
247  # This allows properties to work.
248  object.__setattr__(self, attr, value)
249  elif attr in self.__dict__ or attr in ["_history", "_field", "_config", "_dict",
250  "_selection", "__doc__"]:
251  # This allows specific private attributes to work.
252  object.__setattr__(self, attr, value)
253  else:
254  # We throw everything else.
255  msg = "%s has no attribute %s"%(_typeStr(self._field), attr)
256  raise FieldValidationError(self._field, self._config, msg)
257 
258 
259 
def lsst.pex.config.configChoiceField.ConfigInstanceDict.__setitem__ (   self,
  k,
  value,
  at = None,
  label = "assignment" 
)

Definition at line 212 of file configChoiceField.py.

213  def __setitem__(self, k, value, at=None, label="assignment"):
214  if self._config._frozen:
215  raise FieldValidationError(self._field, self._config, "Cannot modify a frozen Config")
216 
217  try:
218  dtype = self._field.typemap[k]
219  except:
220  raise FieldValidationError(self._field, self._config, "Unknown key %r"%k)
221 
222  if value != dtype and type(value) != dtype:
223  msg = "Value %s at key %k is of incorrect type %s. Expected type %s"%\
224  (value, k, _typeStr(value), _typeStr(dtype))
225  raise FieldValidationError(self._field, self._config, msg)
226 
227  if at is None:
228  at = traceback.extract_stack()[:-1]
229  name = _joinNamePath(self._config._name, self._field.name, k)
230  oldValue = self._dict.get(k, None)
231  if oldValue is None:
232  if value == dtype:
233  self._dict[k] = value(__name=name, __at=at, __label=label)
234  else:
235  self._dict[k] = dtype(__name=name, __at=at, __label=label, **value._storage)
236  else:
237  if value == dtype:
238  value = value()
239  oldValue.update(__at=at, __label=label, **value._storage)
def lsst.pex.config.configChoiceField.ConfigInstanceDict._delName (   self)
private

Definition at line 163 of file configChoiceField.py.

164  def _delName(self):
165  if self._field.multi:
166  raise FieldValidationError(self._field, self._config,
167  "Multi-selection field has no attribute 'name'")
168  self._selection=None
def lsst.pex.config.configChoiceField.ConfigInstanceDict._delNames (   self)
private

Definition at line 147 of file configChoiceField.py.

148  def _delNames(self):
149  if not self._field.multi:
150  raise FieldValidationError(self._field, self._config,
151  "Single-selection field has no attribute 'names'")
152  self._selection = None
def lsst.pex.config.configChoiceField.ConfigInstanceDict._getActive (   self)
private

Definition at line 181 of file configChoiceField.py.

182  def _getActive(self):
183  if self._selection is None:
184  return None
185 
186  if self._field.multi:
187  return [self[c] for c in self._selection]
188  else:
189  return self[self._selection]
def lsst.pex.config.configChoiceField.ConfigInstanceDict._getName (   self)
private

Definition at line 153 of file configChoiceField.py.

154  def _getName(self):
155  if self._field.multi:
156  raise FieldValidationError(self._field, self._config,
157  "Multi-selection field has no attribute 'name'")
return self._selection
def lsst.pex.config.configChoiceField.ConfigInstanceDict._getNames (   self)
private

Definition at line 137 of file configChoiceField.py.

138  def _getNames(self):
139  if not self._field.multi:
140  raise FieldValidationError(self._field, self._config,
141  "Single-selection field has no attribute 'names'")
return self._selection
def lsst.pex.config.configChoiceField.ConfigInstanceDict._rename (   self,
  fullname 
)
private

Definition at line 240 of file configChoiceField.py.

241  def _rename(self, fullname):
242  for k, v in self._dict.iteritems():
243  v._rename(_joinNamePath(name=fullname, index=k))
def lsst.pex.config.configChoiceField.ConfigInstanceDict._setName (   self,
  value 
)
private

Definition at line 158 of file configChoiceField.py.

159  def _setName(self, value):
160  if self._field.multi:
161  raise FieldValidationError(self._field, self._config,
162  "Multi-selection field has no attribute 'name'")
self._setSelection(value)
def lsst.pex.config.configChoiceField.ConfigInstanceDict._setNames (   self,
  value 
)
private

Definition at line 142 of file configChoiceField.py.

143  def _setNames(self, value):
144  if not self._field.multi:
145  raise FieldValidationError(self._field, self._config,
146  "Single-selection field has no attribute 'names'")
self._setSelection(value)
def lsst.pex.config.configChoiceField.ConfigInstanceDict._setSelection (   self,
  value,
  at = None,
  label = "assignment" 
)
private

Definition at line 120 of file configChoiceField.py.

121  def _setSelection(self,value, at=None, label="assignment"):
122  if self._config._frozen:
123  raise FieldValidationError(self._field, self._config, "Cannot modify a frozen Config")
124 
125  if at is None:
126  at = traceback.extract_stack()[:-2]
127 
128  if value is None:
129  self._selection=None
130  elif self._field.multi:
131  self._selection=SelectionSet(self, value, setHistory=False)
132  else:
133  if value not in self._dict:
134  self.__getitem__(value, at=at) # just invoke __getitem__ to make sure it's present
135  self._selection = value
136  self._history.append((value, at, label))

Member Data Documentation

lsst.pex.config.configChoiceField.ConfigInstanceDict.__doc__
private

Definition at line 110 of file configChoiceField.py.

lsst.pex.config.configChoiceField.ConfigInstanceDict._config
private

Definition at line 107 of file configChoiceField.py.

lsst.pex.config.configChoiceField.ConfigInstanceDict._dict
private

Definition at line 105 of file configChoiceField.py.

lsst.pex.config.configChoiceField.ConfigInstanceDict._field
private

Definition at line 108 of file configChoiceField.py.

lsst.pex.config.configChoiceField.ConfigInstanceDict._history
private

Definition at line 109 of file configChoiceField.py.

lsst.pex.config.configChoiceField.ConfigInstanceDict._selection
private

Definition at line 106 of file configChoiceField.py.

Property Documentation

lsst.pex.config.configChoiceField.ConfigInstanceDict.active = property(_getActive)
static

Definition at line 195 of file configChoiceField.py.

lsst.pex.config.configChoiceField.ConfigInstanceDict.name = property(_getName, _setName, _delName)
static

Definition at line 179 of file configChoiceField.py.

lsst.pex.config.configChoiceField.ConfigInstanceDict.names = property(_getNames, _setNames, _delNames)
static

Definition at line 173 of file configChoiceField.py.

lsst.pex.config.configChoiceField.ConfigInstanceDict.types = property(lambda x: x._field.typemap)
static

Definition at line 112 of file configChoiceField.py.


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