def require(method):
def decorator(func):<EOL><INDENT>@wraps(func)<EOL>def wrapper(*args, **kwargs):<EOL><INDENT>if not hasattr(args[<NUM_LIT:0>], method):<EOL><INDENT>raise AssertionError('<STR_LIT>'.format(args[<NUM_LIT:0>].__class__.__name__, method))<EOL><DEDENT>callmethod = method + '<STR_LIT>'<EOL>if not hasattr(args[<NUM_LIT:0>], callmethod):<EOL><INDENT>setattr(args[<NUM_LIT:0>], callmethod, False)<EOL><DEDENT>if not getattr(args[<NUM_LIT:0>], callmethod):<EOL><INDENT>getattr(args[<NUM_LIT:0>], method)()<EOL>setattr(args[<NUM_LIT:0>], callmethod, True)<EOL><DEDENT>return func(*args, **kwargs)<EOL><DEDENT>return wrapper<EOL><DEDENT>return decorator<EOL>
Decorator for managing chained dependencies of different class
properties. The @require decorator allows developers to specify
that a function call must be operated on before another property
or function call is accessed, so that data and processing for an
entire class can be evaluated in a lazy way (i.e. not all upon
instantiation).

Examples:

    >>> class Foo(Bar):
    >>>
    >>>    def a(self):
    >>>        print 'a!'
    >>>        return 1
    >>>
    >>>    @require('a')
    >>>    @property
    >>>    def b(self):
    >>>        print 'b!'
    >>>        return self.a + 1
    >>>
    >>> foo = Foo()
    >>> print foo.b
    >>>
    'a!'
    'b!'
    2