forked from Mirror/pmbootstrap
meta: introduce a Cache decorator (MR 2252)
Generalise pmb.helpers.other.cache with a more python decorator. The Cache decorator takes a list of function arguments to use as cache keys, keyword args can be used to restrict caching so that it is skipped entirely unless the attribute has a specific value. For example, pmb.helpers.pmaports.get() has the decorator: @Cache("pkgname", subpackages=True) This means the return value will be cached only when subpackages is True, otherwise it will always miss. Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
This commit is contained in:
parent
79cf2e8910
commit
185d8bcef5
20 changed files with 244 additions and 165 deletions
|
@ -100,7 +100,7 @@ class Chroot:
|
|||
if not isinstance(other, Chroot):
|
||||
return NotImplemented
|
||||
|
||||
return self.type() == other.type() and self.name() == other.name()
|
||||
return self.type == other.type and self.name() == other.name()
|
||||
|
||||
|
||||
def __truediv__(self, other: object) -> Path:
|
||||
|
@ -129,6 +129,7 @@ class Chroot:
|
|||
return NotImplemented
|
||||
|
||||
|
||||
@property
|
||||
def type(self) -> ChrootType:
|
||||
return self.__type
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue