A Python 2/3 compatible way of declaring a metaclass.

    Taken from `Jinja 2 <https://github.com/mitsuhiko/jinja2/blob/master/jinja2
    /_compat.py>`_ via `python-future <http://python-future.org>`_. License:
    BSD.
    Use it like this::

        class MyClass(with_metaclass(MyMetaClass, BaseClass)):
                pass

def with_metaclass(meta, *bases):
    """A Python 2/3 compatible way of declaring a metaclass.

    Taken from `Jinja 2 <https://github.com/mitsuhiko/jinja2/blob/master/jinja2
    /_compat.py>`_ via `python-future <http://python-future.org>`_. License:
    BSD.
    Use it like this::

        class MyClass(with_metaclass(MyMetaClass, BaseClass)):
                pass
    """
    class _Metaclass(meta):
        """Inner class"""
        __call__ = type.__call__
        __init__ = type.__init__

        def __new__(cls, name, this_bases, attrs):
            if this_bases is None:
                return type.__new__(cls, name, (), attrs)
            return meta(name, bases, attrs)

    return _Metaclass(str('temporary_class'), None, {})