Metadata-Version: 1.1
Name: black-magic
Version: 0.0.3
Summary: Decorator utility that operates on black magic
Home-page: https://github.com/coldfix/black-magic
Author: Thomas Gläßle
Author-email: t_glaessle@gmx.de
License: Public Domain
Description: black-magic
        -----------
        
        Collection of metaprogramming modules that operate on black magic!
        
        Currently the only available module is:
        
        -  ``black_magic.decorator``
        
        License
        ~~~~~~~
        
        To the extent possible under law, Thomas Gläßle has waived all copyright
        and related or neighboring rights to black-magic. This work is published
        from: Germany.
        
        To the extent possible under law, the person who associated CC0 with
        black-magic has waived all copyright and related or neighboring rights
        to black-magic.
        
        You should have received a copy of the CC0 legalcode along with this
        work. If not, see http://creativecommons.org/publicdomain/zero/1.0/.
        
        black\_magic.decorator
        ~~~~~~~~~~~~~~~~~~~~~~
        
        This is intended to become a more modern and flexible replacement for
        the the well known
        `decorator <https://pypi.python.org/pypi/decorator/3.4.0>`__ module.
        This module benefits an API for more flexible usage. The behaviour of
        the `decorator <https://pypi.python.org/pypi/decorator/3.4.0>`__ module
        can easily be duplicated.
        
        Usage
        ^^^^^
        
        You can use it just like the standard ``functools.wraps`` function:
        
        .. code:: python
        
            >>> from black_magic.decorator import wraps
        
            >>> x = []
            >>> def real(a:int, b=x) -> "Returns b":
            ...     return b
        
            >>> @wraps(real)
            ... def fake(*args, **kwargs):
            ...     print("Fake!")
            ...     return real(*args, **kwargs)
        
        This will not only update the docstring of the fake function to look
        like the original but generate a wrapper function that has *exactly* the
        same signature:
        
        .. code:: python
        
            >>> assert fake(1) is x   # check object-identity of default-parameter!
            Fake!
        
            >>> from inspect import getfullargspec
            >>> assert getfullargspec(fake) == getfullargspec(real)
        
        If you want to get real crazy you can even use `ast
        expr <http://docs.python.org/3.3/library/ast.html?highlight=ast#abstract-grammar>`__\ s:
        
        .. code:: python
        
            >>> import ast
            >>> fake = wraps(real)(ast.Num(n=1))
            >>> fake(0)
            1
        
        Under the hood
        ^^^^^^^^^^^^^^
        
        Q: This uses ugly ``eval`` code, right?
        
        A: No, it uses `abstract syntax
        trees <http://docs.python.org/3.3/library/ast.html?highlight=ast#ast>`__
        to do its dynamic code generation.
        
        Tests
        ^^^^^
        
        This module has been tested to work on python{2.6, 2.7, 3.2, 3.3} and
        PyPy1.9 using `Travis <https://travis-ci.org/>`__.
        
Platform: UNKNOWN
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Topic :: Software Development
Classifier: License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
