diff options
Diffstat (limited to 'libbe/storage/util/properties.py')
-rw-r--r-- | libbe/storage/util/properties.py | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/libbe/storage/util/properties.py b/libbe/storage/util/properties.py index ad9d06c..6a2b964 100644 --- a/libbe/storage/util/properties.py +++ b/libbe/storage/util/properties.py @@ -46,11 +46,6 @@ if libbe.TESTING: import unittest -# https://stackoverflow.com/a/56719588/164233 -def cmp(a, b): - return (int(a) > int(b)) - (int(a) < int(b)) - - class ValueCheckError (ValueError): def __init__(self, name, value, allowed): action = "in" # some list of allowed values @@ -72,8 +67,8 @@ def Property(funcs): args["fdel"] = funcs.get("fdel", None) args["doc"] = funcs.get("doc", None) - #print "Creating a property with" - #for key, val in args.items(): print key, value + #print("Creating a property with") + #for key, val in args.items(): print(key, value) return property(**args) def doc_property(doc=None): @@ -179,12 +174,12 @@ def _get_cached_mutable_property(self, cacher_name, property_name, default=None) if (cacher_name, property_name) not in self._mutable_property_cache_copy: return default return self._mutable_property_cache_copy[(cacher_name, property_name)] -def _cmp_cached_mutable_property(self, cacher_name, property_name, value, default=None): +def _eq_cached_mutable_property(self, cacher_name, property_name, value, default=None): _init_mutable_property_cache(self) if (cacher_name, property_name) not in self._mutable_property_cache_hash: _set_cached_mutable_property(self, cacher_name, property_name, default) old_hash = self._mutable_property_cache_hash[(cacher_name, property_name)] - return cmp(_hash_mutable_value(value), old_hash) + return _hash_mutable_value(value) == old_hash def defaulting_property(default=None, null=None, @@ -389,7 +384,7 @@ def change_hook_property(hook, mutable=False, default=None): value = new_value # compare new value with cached else: value = fget(self) # compare current value with cached - if _cmp_cached_mutable_property(self, "change hook property", name, value, default) != 0: + if _eq_cached_mutable_property(self, "change hook property", name, value, default) != 0: # there has been a change, cache new value old_value = _get_cached_mutable_property(self, "change hook property", name, default) _set_cached_mutable_property(self, "change hook property", name, value) |