import six
from blazeutils.strings import simplify


def object_from_source(fpath, objname):
    if six.PY2:
        import imp
        module_name = 'keg_{}'.format(simplify(fpath))
        tmpmodule = imp.load_source(module_name, fpath)
        if not hasattr(tmpmodule, objname):
            return None
        return getattr(tmpmodule, objname)

@@ -1,16 +1,96 @@
+from __future__ import absolute_import%0Afrom __future__ import unicode_literals%0A%0A
 import six%0Afrom 
@@ -84,16 +84,17 @@
 ort six%0A
+%0A
 from bla
@@ -381,16 +381,16 @@
 rn None%0A
-
         
@@ -424,8 +424,939 @@
 bjname)%0A
+%0A%0Adef with_metaclass(meta, *bases):%0A    # This requires a bit of explanation: the basic idea is to make a%0A    # dummy metaclass for one level of class instantiation that replaces%0A    # itself with the actual metaclass.  Because of internal type checks%0A    # we also need to make sure that we downgrade the custom metaclass%0A    # for one level to something closer to type (that's why __call__ and%0A    # __init__ comes back from type etc.).%0A    #%0A    # This has the advantage over six.with_metaclass in that it does not%0A    # introduce dummy classes into the final MRO.%0A    #%0A    # copied from Flask._compat%0A    class metaclass(meta):%0A        __call__ = type.__call__%0A        __init__ = type.__init__%0A%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(str('temporary_class'), None, %7B%7D)%0A

add with_metaclass() from Flask, PY3