MCPcopy Create free account
hub / github.com/LabPy/lantz / rebuild

Method rebuild

lantz/action.py:142–196  ·  view source on GitHub ↗
(self, instance=MISSING, build_doc=False, modifiers=None, store=False)

Source from the content-addressed store, hash-verified

140 return value
141
142 def rebuild(self, instance=MISSING, build_doc=False, modifiers=None, store=False):
143 if not modifiers:
144 modifiers = _dget(self.modifiers, instance)
145
146 procs = []
147 largs = len(self.args) - 1
148 name = self.name
149
150 values = modifiers['values']
151 units = modifiers['units']
152 limits = modifiers['limits']
153 processors = modifiers['processors']
154
155 if values:
156 proc = MapProcessor(values)
157 lproc = len(proc) if isinstance(proc, Processor) else 1
158 if lproc != largs:
159 raise ValueError("In {}: the number of elements in 'values' ({}) "
160 "must match the number of arguments ({})".format(name, lproc, largs))
161 procs.append(proc)
162
163 if units:
164 proc = FromQuantityProcessor(units)
165 lproc = len(proc) if isinstance(proc, Processor) else 1
166 if lproc != largs:
167 raise ValueError("In {}: the number of elements in 'units' ({}) "
168 "must match the number of arguments ({})".format(name, lproc, largs))
169 procs.append(proc)
170
171 if limits:
172 if isinstance(limits[0], (list, tuple)):
173 proc = RangeProcessor(limits)
174 else:
175 proc = RangeProcessor((limits, ))
176
177 lproc = len(proc) if isinstance(proc, Processor) else 1
178 if lproc != largs:
179 raise ValueError("In {}: the number of elements in 'limits' ({}) "
180 "must match the number of arguments ({})".format(name, lproc, largs))
181
182 procs.append(proc)
183
184 if processors:
185 for processor in processors:
186 proc = Processor(processor)
187 lproc = len(proc) if isinstance(proc, Processor) else 1
188 if lproc != largs:
189 raise ValueError("In {}: the number of elements in 'processor' ({}) "
190 "must match the number of arguments ({})".format(name, len(proc), largs))
191 procs.append(proc)
192
193 if store:
194 _dset(self.action_processors, procs, instance)
195
196 return procs
197
198
199class ActionProxy(object):

Callers 2

__call__Method · 0.95
__setattr__Method · 0.45

Calls 6

MapProcessorClass · 0.85
RangeProcessorClass · 0.85
ProcessorClass · 0.85
_dgetFunction · 0.70
_dsetFunction · 0.70

Tested by

no test coverage detected