Mercurial > piecrust2
annotate piecrust/decorators.py @ 0:a212a3f2e3ee
Initial commit.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 21 Dec 2013 14:44:02 -0800 |
parents | |
children |
rev | line source |
---|---|
0 | 1 import functools |
2 | |
3 | |
4 def lazy(f): | |
5 @functools.wraps(f) | |
6 def lazy_wrapper(*args, **kwargs): | |
7 if f.__lazyresult__ is None: | |
8 f.__lazyresult__ = f(*args, **kwargs) | |
9 return f.__lazyresult__ | |
10 | |
11 f.__lazyresult__ = None | |
12 return lazy_wrapper | |
13 | |
14 | |
15 def lazy_property(f): | |
16 return property(lazy(f)) | |
17 |