Decorator for marking a function as a graft.

    Parameters:
        namespace (str): namespace of data, same format as targeting.
    Returns:
        Graft

    For example, these grafts::

        @graft
        def foo_data:
            return {'foo', True}

        @graft(namespace='bar')
        def bar_data:
            return False

    will be redered has::

        {
            'foo': True,
            'bar': False
        }

def graft(func=None, *, namespace=None):
    """Decorator for marking a function as a graft.

    Parameters:
        namespace (str): namespace of data, same format as targeting.
    Returns:
        Graft

    For example, these grafts::

        @graft
        def foo_data:
            return {'foo', True}

        @graft(namespace='bar')
        def bar_data:
            return False

    will be redered has::

        {
            'foo': True,
            'bar': False
        }
    """

    if not func:
        return functools.partial(graft, namespace=namespace)

    if isinstance(func, Graft):
        return func

    return Graft(func, namespace=namespace)