mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-01-26 16:16:31 -06:00
Remove the cachedproperty class
The cachedproperty class was used in one special use-case where it only caused issues. Let's get rid of it. https://pagure.io/freeipa/issue/6878 Reviewed-By: Martin Basti <mbasti@redhat.com> Reviewed-By: Christian Heimes <cheimes@redhat.com>
This commit is contained in:
parent
0d406fcb78
commit
92313c9e9d
@ -34,7 +34,6 @@ import dns
|
||||
import encodings
|
||||
import sys
|
||||
import ssl
|
||||
from weakref import WeakKeyDictionary
|
||||
|
||||
import netaddr
|
||||
from dns import resolver, rdatatype
|
||||
@ -492,39 +491,6 @@ def remove_sshpubkey_from_output_list_post(context, entries):
|
||||
delattr(context, 'ipasshpubkey_added')
|
||||
|
||||
|
||||
class cachedproperty(object):
|
||||
"""
|
||||
A property-like attribute that caches the return value of a method call.
|
||||
|
||||
When the attribute is first read, the method is called and its return
|
||||
value is saved and returned. On subsequent reads, the saved value is
|
||||
returned.
|
||||
|
||||
Typical usage:
|
||||
class C(object):
|
||||
@cachedproperty
|
||||
def attr(self):
|
||||
return 'value'
|
||||
"""
|
||||
__slots__ = ('getter', 'store')
|
||||
|
||||
def __init__(self, getter):
|
||||
self.getter = getter
|
||||
self.store = WeakKeyDictionary()
|
||||
|
||||
def __get__(self, obj, cls):
|
||||
if obj is None:
|
||||
return None
|
||||
if obj not in self.store:
|
||||
self.store[obj] = self.getter(obj)
|
||||
return self.store[obj]
|
||||
|
||||
def __set__(self, obj, value):
|
||||
raise AttributeError("can't set attribute")
|
||||
|
||||
def __delete__(self, obj):
|
||||
raise AttributeError("can't delete attribute")
|
||||
|
||||
# regexp matching signed floating point number (group 1) followed by
|
||||
# optional whitespace followed by time unit, e.g. day, hour (group 7)
|
||||
time_duration_re = re.compile(r'([-+]?((\d+)|(\d+\.\d+)|(\.\d+)|(\d+\.)))\s*([a-z]+)', re.IGNORECASE)
|
||||
|
Loading…
Reference in New Issue
Block a user