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

Public Member Functions

def __init__
 
def validateItem
 
def __contains__
 
def __len__
 
def __setitem__
 
def __getitem__
 
def __delitem__
 
def __iter__
 
def insert
 
def __repr__
 
def __str__
 
def __eq__
 
def __ne__
 
def __setattr__
 

Properties

 history = property(lambda x: x._history)
 

Private Attributes

 _field
 
 _config
 
 _history
 
 _list
 
 __doc__
 

Detailed Description

Definition at line 30 of file listField.py.

Constructor & Destructor Documentation

def lsst.pex.config.listField.List.__init__ (   self,
  config,
  field,
  value,
  at,
  label,
  setHistory = True 
)

Definition at line 31 of file listField.py.

31 
32  def __init__(self, config, field, value, at, label, setHistory=True):
33  self._field = field
34  self._config = config
35  self._history = self._config._history.setdefault(self._field.name, [])
36  self._list = []
37  self.__doc__ = field.doc
38  if value is not None:
39  try:
40  for i, x in enumerate(value):
41  self.insert(i, x, setHistory=False)
42  except TypeError:
43  msg = "Value %s is of incorrect type %s. Sequence type expected"%(value, _typeStr(value))
44  raise FieldValidationError(self._field, self._config, msg)
45  if setHistory:
46  self.history.append((list(self._list), at, label))

Member Function Documentation

def lsst.pex.config.listField.List.__contains__ (   self,
  x 
)

Definition at line 64 of file listField.py.

64 
65  def __contains__(self, x): return x in self._list
def lsst.pex.config.listField.List.__delitem__ (   self,
  i,
  at = None,
  label = "delitem",
  setHistory = True 
)

Definition at line 92 of file listField.py.

92 
93  def __delitem__(self, i, at =None, label="delitem", setHistory=True):
94  if self._config._frozen:
95  raise FieldValidationError(self._field, self._config, \
96  "Cannot modify a frozen Config")
97  del self._list[i]
98  if setHistory:
99  if at is None:
100  at = traceback.extract_stack()[:-1]
101  self.history.append((list(self._list), at, label))
def lsst.pex.config.listField.List.__eq__ (   self,
  other 
)

Definition at line 113 of file listField.py.

114  def __eq__(self, other):
115  try:
116  if len(self) != len(other):
117  return False
118 
119  for i,j in zip(self, other):
120  if i != j: return False
121  return True
122  except AttributeError:
123  #other is not a sequence type
124  return False
def lsst.pex.config.listField.List.__getitem__ (   self,
  i 
)

Definition at line 90 of file listField.py.

90 
91  def __getitem__(self, i): return self._list[i]
def lsst.pex.config.listField.List.__iter__ (   self)

Definition at line 102 of file listField.py.

103  def __iter__(self): return iter(self._list)
def lsst.pex.config.listField.List.__len__ (   self)

Definition at line 66 of file listField.py.

66 
67  def __len__(self): return len(self._list)
def lsst.pex.config.listField.List.__ne__ (   self,
  other 
)

Definition at line 125 of file listField.py.

126  def __ne__(self, other):
127  return not self.__eq__(other)
def lsst.pex.config.listField.List.__repr__ (   self)

Definition at line 109 of file listField.py.

110  def __repr__(self): return repr(self._list)
def lsst.pex.config.listField.List.__setattr__ (   self,
  attr,
  value,
  at = None,
  label = "assignment" 
)

Definition at line 128 of file listField.py.

129  def __setattr__(self, attr, value, at=None, label="assignment"):
130  if hasattr(getattr(self.__class__, attr, None), '__set__'):
131  # This allows properties to work.
132  object.__setattr__(self, attr, value)
133  elif attr in self.__dict__ or attr in ["_field", "_config", "_history", "_list", "__doc__"]:
134  # This allows specific private attributes to work.
135  object.__setattr__(self, attr, value)
136  else:
137  # We throw everything else.
138  msg = "%s has no attribute %s"%(_typeStr(self._field), attr)
139  raise FieldValidationError(self._field, self._config, msg)
140 
def lsst.pex.config.listField.List.__setitem__ (   self,
  i,
  x,
  at = None,
  label = "setitem",
  setHistory = True 
)

Definition at line 68 of file listField.py.

68 
69  def __setitem__(self, i, x, at=None, label="setitem", setHistory=True):
70  if self._config._frozen:
71  raise FieldValidationError(self._field, self._config, \
72  "Cannot modify a frozen Config")
73  if isinstance(i, slice):
74  k, stop, step = i.indices(len(self))
75  for j, xj in enumerate(x):
76  xj=_autocast(xj, self._field.itemtype)
77  self.validateItem(k, xj)
78  x[j]=xj
79  k += step
80  else:
81  x = _autocast(x, self._field.itemtype)
82  self.validateItem(i, x)
83 
84  self._list[i]=x
85  if setHistory:
86  if at is None:
87  at = traceback.extract_stack()[:-1]
88  self.history.append((list(self._list), at, label))
89 
def lsst.pex.config.listField.List.__str__ (   self)

Definition at line 111 of file listField.py.

112  def __str__(self): return str(self._list)
def lsst.pex.config.listField.List.insert (   self,
  i,
  x,
  at = None,
  label = "insert",
  setHistory = True 
)

Definition at line 104 of file listField.py.

105  def insert(self, i, x, at=None, label="insert", setHistory=True):
106  if at is None:
107  at = traceback.extract_stack()[:-1]
108  self.__setitem__(slice(i,i), [x], at=at, label=label, setHistory=setHistory)
def lsst.pex.config.listField.List.validateItem (   self,
  i,
  x 
)

Definition at line 47 of file listField.py.

47 
48  def validateItem(self, i, x):
49 
50  if not isinstance(x, self._field.itemtype) and x is not None:
51  msg="Item at position %d with value %s is of incorrect type %s. Expected %s"%\
52  (i, x, _typeStr(x), _typeStr(self._field.itemtype))
53  raise FieldValidationError(self._field, self._config, msg)
54 
55  if self._field.itemCheck is not None and not self._field.itemCheck(x):
56  msg="Item at position %d is not a valid value: %s"%(i, x)
57  raise FieldValidationError(self._field, self._config, msg)
58 

Member Data Documentation

lsst.pex.config.listField.List.__doc__
private

Definition at line 36 of file listField.py.

lsst.pex.config.listField.List._config
private

Definition at line 33 of file listField.py.

lsst.pex.config.listField.List._field
private

Definition at line 32 of file listField.py.

lsst.pex.config.listField.List._history
private

Definition at line 34 of file listField.py.

lsst.pex.config.listField.List._list
private

Definition at line 35 of file listField.py.

Property Documentation

lsst.pex.config.listField.List.history = property(lambda x: x._history)
static

Definition at line 62 of file listField.py.


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