annotate piecrust/decorators.py @ 2:40fa08b261b9
Added unit tests (using `py.test`) for `Configuration`.
Fixed some configuration module bugs.
author |
Ludovic Chabant <ludovic@chabant.com> |
date |
Wed, 25 Dec 2013 22:16:46 -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
|