Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/wirerope/_util.py: 100%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
2_missing = object()
5class cached_property(property): # pragma: no cover
6 """
8 Import from:
9 https://github.com/pallets/werkzeug/blob/master/werkzeug/utils.py
10 """
12 # implementation detail: A subclass of python's builtin property
13 # decorator, we override __get__ to check for a cached value. If one
14 # choses to invoke __get__ by hand the property will still work as
15 # expected because the lookup logic is replicated in __get__ for
16 # manual invocation.
18 def __init__(self, func, name=None, doc=None):
19 self.__name__ = name or func.__name__
20 self.__module__ = func.__module__
21 self.__doc__ = doc or func.__doc__
22 self.__func__ = func
24 def __set__(self, obj, value):
25 obj.__dict__[self.__name__] = value
27 def __get__(self, obj, type=None):
28 if obj is None:
29 return self
30 value = obj.__dict__.get(self.__name__, _missing)
31 if value is _missing:
32 value = self.__func__(obj)
33 obj.__dict__[self.__name__] = value
34 return value