viff

changeset 1309:23b6edabac78

util: remove support for VIFF_NO_WRAP
author Martin Geisler <mg@cs.au.dk>
date Mon, 19 Oct 2009 17:03:49 +0200
parents 85fd0fbfdb5a
children 698b1359b788
files doc/util.txt viff/util.py
diffstat 2 files changed, 8 insertions(+), 27 deletions(-) [+]
line diff
     1.1 --- a/doc/util.txt	Mon Oct 19 17:02:50 2009 +0200
     1.2 +++ b/doc/util.txt	Mon Oct 19 17:03:49 2009 +0200
     1.3 @@ -21,11 +21,6 @@
     1.4        :envvar:`VIFF_SEED` is defined, but empty, then no seed is used
     1.5        and a protocol run cannot be reproduced exactly.
     1.6  
     1.7 -   .. envvar:: VIFF_NO_WRAP
     1.8 -
     1.9 -      Setting this environment variable to any value will turn
    1.10 -      :func:`wrapper` into a no-op.
    1.11 -
    1.12     .. envvar:: VIFF_PROFILE
    1.13  
    1.14        Defining this variable will change :func:`profile` from a no-op
     2.1 --- a/viff/util.py	Mon Oct 19 17:02:50 2009 +0200
     2.2 +++ b/viff/util.py	Mon Oct 19 17:03:49 2009 +0200
     2.3 @@ -64,29 +64,15 @@
     2.4      It is important to use this decorator on any wrapper functions in
     2.5      order to ensure that they end up with correct :attr:`__name__` and
     2.6      :attr:`__doc__` attributes.
     2.7 -
     2.8 -    In addition, if the environment variable :envvar:`VIFF_NO_WRAP` is
     2.9 -    defined, then the wrapper functions will be turned into functions
    2.10 -    that *do not* wrap -- instead they let their argument function
    2.11 -    through unchanged. This is done so that epydoc and Sphinx can see
    2.12 -    the true function arguments when generating documentation. Just
    2.13 -    remember that your code will break if :envvar:`VIFF_NO_WRAP` is
    2.14 -    set, so it should only be used when documentation is being
    2.15 -    generated.
    2.16      """
    2.17 -    if os.environ.get('VIFF_NO_WRAP'):
    2.18 -        # Return a decorator which ignores the functions it is asked
    2.19 -        # to decorate and instead returns func:
    2.20 -        return lambda _: func
    2.21 -    else:
    2.22 -        # Return a decorator which does nothing to the function it is
    2.23 -        # asked to decorate, except update the __name__ and __doc__
    2.24 -        # attributes to match the original wrapped function.
    2.25 -        def decorator(f):
    2.26 -            f.__name__ = func.__name__
    2.27 -            f.__doc__ = func.__doc__
    2.28 -            return f
    2.29 -        return decorator
    2.30 +    # Return a decorator which does nothing to the function it is
    2.31 +    # asked to decorate, except update the __name__ and __doc__
    2.32 +    # attributes to match the original wrapped function.
    2.33 +    def decorator(f):
    2.34 +        f.__name__ = func.__name__
    2.35 +        f.__doc__ = func.__doc__
    2.36 +        return f
    2.37 +    return decorator
    2.38  
    2.39  def fake(replacement):
    2.40      """Replace a function with a fake version.