MCPcopy Index your code
hub / github.com/LabPy/lantz / get

Method get

lantz/feat.py:206–246  ·  view source on GitHub ↗
(self, instance, owner=None, key=MISSING)

Source from the content-addressed store, hash-verified

204 return value
205
206 def get(self, instance, owner=None, key=MISSING):
207 if instance is None:
208 return self
209
210 name = self.name + ('' if key is MISSING else '[{!r}]'.format(key))
211 if self.fget is None or self.fget is MISSING:
212 raise AttributeError('{} is a write-only feature'.format(name))
213
214 current = self.get_cache(instance, key)
215 if self.read_once and current is not MISSING:
216 return current
217
218 # This part calls to the underlying get function wrapping
219 # and timing, caching, logging and error handling
220 with instance._lock:
221 instance.log_info('Getting {}', name)
222
223 try:
224 tic = time.time()
225 if key is MISSING:
226 value = self.fget(instance)
227 else:
228 value = self.fget(instance, key)
229 except Exception as e:
230 instance.log_error('While getting {}: {}', name, e)
231 raise e
232
233 instance.timing.add('get_' + name, time.time() - tic)
234
235 instance.log_debug('(raw) Got {} for {}', value, name)
236 try:
237 value = self.post_get(value, instance, key)
238 except Exception as e:
239 instance.log_error('While post-processing {} for {}: {}', value, name, e)
240 raise e
241
242 instance.log_info('Got {} for {}', value, name, lantz_feat=(name, str(value)))
243
244 self.set_cache(instance, value, key)
245
246 return value
247
248 def set(self, instance, value, force=False, key=MISSING):
249 name = self.name + ('' if key is MISSING else '[{!r}]'.format(key))

Callers 15

__get__Method · 0.95
getitemMethod · 0.80
get_cacheMethod · 0.80
_dochelperFunction · 0.80
__init__.pyFile · 0.80
qt.pyFile · 0.80
__new__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80
__new__Method · 0.80
list_devicesFunction · 0.80

Calls 8

get_cacheMethod · 0.95
post_getMethod · 0.95
set_cacheMethod · 0.95
log_infoMethod · 0.80
log_errorMethod · 0.80
log_debugMethod · 0.80
timeMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected