pgreco / rpms / ipa

Forked from forks/areguera/rpms/ipa 4 years ago
Clone

Blame SOURCES/0114-Remove-the-cachedproperty-class.patch

483b06
From 4fe9684ccd97f0c6cd32d858f681f98fb97162dc Mon Sep 17 00:00:00 2001
483b06
From: Stanislav Laznicka <slaznick@redhat.com>
483b06
Date: Fri, 28 Apr 2017 09:31:45 +0200
483b06
Subject: [PATCH] Remove the cachedproperty class
483b06
483b06
The cachedproperty class was used in one special use-case where it only
483b06
caused issues. Let's get rid of it.
483b06
483b06
https://pagure.io/freeipa/issue/6878
483b06
483b06
Reviewed-By: Martin Basti <mbasti@redhat.com>
483b06
Reviewed-By: Christian Heimes <cheimes@redhat.com>
483b06
---
483b06
 ipalib/util.py | 34 ----------------------------------
483b06
 1 file changed, 34 deletions(-)
483b06
483b06
diff --git a/ipalib/util.py b/ipalib/util.py
483b06
index e9d4105775a2c9096b1718a604d31034b44bf0bd..8973a19abf56d1d1c5ba04f6edb4228dd2329e65 100644
483b06
--- a/ipalib/util.py
483b06
+++ b/ipalib/util.py
483b06
@@ -34,7 +34,6 @@ import dns
483b06
 import encodings
483b06
 import sys
483b06
 import ssl
483b06
-from weakref import WeakKeyDictionary
483b06
 
483b06
 import netaddr
483b06
 from dns import resolver, rdatatype
483b06
@@ -492,39 +491,6 @@ def remove_sshpubkey_from_output_list_post(context, entries):
483b06
         delattr(context, 'ipasshpubkey_added')
483b06
 
483b06
 
483b06
-class cachedproperty(object):
483b06
-    """
483b06
-    A property-like attribute that caches the return value of a method call.
483b06
-
483b06
-    When the attribute is first read, the method is called and its return
483b06
-    value is saved and returned. On subsequent reads, the saved value is
483b06
-    returned.
483b06
-
483b06
-    Typical usage:
483b06
-    class C(object):
483b06
-        @cachedproperty
483b06
-        def attr(self):
483b06
-            return 'value'
483b06
-    """
483b06
-    __slots__ = ('getter', 'store')
483b06
-
483b06
-    def __init__(self, getter):
483b06
-        self.getter = getter
483b06
-        self.store = WeakKeyDictionary()
483b06
-
483b06
-    def __get__(self, obj, cls):
483b06
-        if obj is None:
483b06
-            return None
483b06
-        if obj not in self.store:
483b06
-            self.store[obj] = self.getter(obj)
483b06
-        return self.store[obj]
483b06
-
483b06
-    def __set__(self, obj, value):
483b06
-        raise AttributeError("can't set attribute")
483b06
-
483b06
-    def __delete__(self, obj):
483b06
-        raise AttributeError("can't delete attribute")
483b06
-
483b06
 # regexp matching signed floating point number (group 1) followed by
483b06
 # optional whitespace followed by time unit, e.g. day, hour (group 7)
483b06
 time_duration_re = re.compile(r'([-+]?((\d+)|(\d+\.\d+)|(\.\d+)|(\d+\.)))\s*([a-z]+)', re.IGNORECASE)
483b06
-- 
483b06
2.12.2
483b06