From 4fe9684ccd97f0c6cd32d858f681f98fb97162dc Mon Sep 17 00:00:00 2001 From: Stanislav Laznicka Date: Fri, 28 Apr 2017 09:31:45 +0200 Subject: [PATCH] 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 Reviewed-By: Christian Heimes --- ipalib/util.py | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/ipalib/util.py b/ipalib/util.py index e9d4105775a2c9096b1718a604d31034b44bf0bd..8973a19abf56d1d1c5ba04f6edb4228dd2329e65 100644 --- a/ipalib/util.py +++ b/ipalib/util.py @@ -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) -- 2.12.2