# Copyright (c) 2015 The Pycroft Authors. See the AUTHORS file.
# This file is part of the Pycroft project and licensed under the terms of
# the Apache License, Version 2.0. See the LICENSE file for details.
import sys
import operator


PY2 = sys.version_info[0] == 2

if PY2:
    chr = unichr
    text_type = unicode
    string_types = (unicode, str)
    integer_types = (int, long)
    int_to_byte = chr

    xrange = xrange
    from future_builtins import filter as ifilter, map as imap, zip as izip
    from itertools import ifilterfalse, izip_longest
    iterkeys = operator.methodcaller("iterkeys")
    itervalues = operator.methodcaller("itervalues")
    iteritems = operator.methodcaller("iteritems")
    reduce = reduce

    from StringIO import StringIO
    from cStringIO import StringIO as BytesIO
    NativeStringIO = BytesIO

else:
    chr = chr
    text_type = str
    string_types = (str, )
    integer_types = (int, )

    xrange = range
    ifilter = filter
    from itertools import filterfalse, zip_longest
    ifilterfalse = filterfalse
    izip_longest = zip_longest
    imap = map
    izip = zip
    from functools import reduce

    iterkeys = operator.methodcaller("keys")
    itervalues = operator.methodcaller("values")
    iteritems = operator.methodcaller("items")

    from io import StringIO, BytesIO
    NativeStringIO = StringIO


def with_metaclass(meta, base=object):
    return meta("NewBase", (base,), {})

@@ -1386,56 +1386,362 @@
 ta, 
+*
 base
-=object
+s):%0A    # Copied from Flask._compat%0A    class metaclass(meta
 ):%0A    
+  
-return meta(%22NewBase%22, (base,)
+  __call__ = type.__call__%0A        __init__ = type.__init__%0A        def __new__(cls, name, this_bases, d):%0A            if this_bases is None:%0A                return type.__new__(cls, name, (), d)%0A            return meta(name, bases, d)%0A    return metaclass('temporary_class', None
 , %7B%7D

Add better with_metaclass compatibility tool