mirror of
https://github.com/chatmail/core.git
synced 2026-04-06 07:32:12 +03:00
* import python, try to adapt for rust * add missing wrapper functions * - try to write up how to build python bindings - strike some unused functions from deltachat.h * adjustments to make tox work * try to run circle-ci with python build * don't do docs * running cargo test as well * don't run cargo test anymore, that's done in other ci jobs * also build docs * don't run doxygen anymore * subst C with Rust * a try to get better wheels Closes #41
31 lines
805 B
Python
31 lines
805 B
Python
"""Helpers for properties."""
|
|
|
|
|
|
def with_doc(f):
|
|
return property(f, None, None, f.__doc__)
|
|
|
|
|
|
# copied over unmodified from
|
|
# https://github.com/devpi/devpi/blob/master/common/devpi_common/types.py
|
|
def cached(f):
|
|
"""returns a cached property that is calculated by function f"""
|
|
def get(self):
|
|
try:
|
|
return self._property_cache[f]
|
|
except AttributeError:
|
|
self._property_cache = {}
|
|
except KeyError:
|
|
pass
|
|
x = self._property_cache[f] = f(self)
|
|
return x
|
|
|
|
def set(self, val):
|
|
propcache = self.__dict__.setdefault("_property_cache", {})
|
|
propcache[f] = val
|
|
|
|
def fdel(self):
|
|
propcache = self.__dict__.setdefault("_property_cache", {})
|
|
del propcache[f]
|
|
|
|
return property(get, set, fdel)
|