annotate piecrust/decorators.py @ 1:aaa8fb7c8918
Re-arranged modules to reduce dependencies to builtin stuff.
Added `init` command.
author |
Ludovic Chabant <ludovic@chabant.com> |
date |
Sun, 22 Dec 2013 08:00:24 -0800 |
parents |
a212a3f2e3ee |
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
|