sys.modules.setdefault

Here are the examples of the python api sys.modules.setdefault taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

44 Examples 7

Example 1

Project: pymo
Source File: test_importhooks.py
View license
    def load_module(self, fullname):
        ispkg, code = self.modules[fullname]
        mod = sys.modules.setdefault(fullname,imp.new_module(fullname))
        mod.__file__ = "<%s>" % self.__class__.__name__
        mod.__loader__ = self
        if ispkg:
            mod.__path__ = self._get__path__()
        exec code in mod.__dict__
        return mod

Example 2

Project: pymo
Source File: test_pkgutil.py
View license
        def load_module(self, fullname):
            # Create an empty module
            mod = sys.modules.setdefault(fullname, imp.new_module(fullname))
            mod.__file__ = "<%s>" % self.__class__.__name__
            mod.__loader__ = self
            # Make it a package
            mod.__path__ = []
            # Count how many times the module is reloaded
            mod.__dict__['loads'] = mod.__dict__.get('loads',0) + 1
            return mod

Example 3

Project: blohg
Source File: ext.py
View license
    def load_module(self, fullname):
        mod = sys.modules.setdefault(fullname, new_module(fullname))
        mod.__file__ = self.get_filename(fullname)
        mod.__loader__ = self
        if self.is_package(fullname):
            mod.__path__ = [mod.__file__.rsplit(posixpath.sep, 1)[0]]
            mod.__package__ = fullname
        else:
            mod.__package__ = fullname.rpartition('.')[0]
        exec(self.get_code(fullname), mod.__dict__)
        return mod

Example 4

Project: imagrium
Source File: test_pkgutil.py
View license
        def load_module(self, fullname):
            # Create an empty module
            mod = sys.modules.setdefault(fullname, imp.new_module(fullname))
            mod.__file__ = "<%s>" % self.__class__.__name__
            mod.__loader__ = self
            # Make it a package
            mod.__path__ = []
            # Count how many times the module is reloaded
            mod.__dict__['loads'] = mod.__dict__.get('loads',0) + 1
            return mod

Example 5

Project: codegenloader
Source File: base.py
View license
    def load_module(self, fullname):
        """Returns the module named ``fullname``.

        Implements the "loader" portion of the PEP 302 interface.
        """
        relname = self.get_relname(fullname)
        # This should never fail since python always calls find_module first
        is_pkg, contents = self.get_contents(relname)
        mod = sys.modules.setdefault(fullname, imp.new_module(fullname))
        mod.__file__ = '<codegenloader %s>' % fullname
        mod.__loader__ = self
        if is_pkg:
            mod.__path__ = [self.hook_key]
        exec_in(contents, mod.__dict__)
        return mod

Example 6

Project: TrustRouter
Source File: test_importhooks.py
View license
    def load_module(self, fullname):
        ispkg, code = self.modules[fullname]
        mod = sys.modules.setdefault(fullname,imp.new_module(fullname))
        mod.__file__ = "<%s>" % self.__class__.__name__
        mod.__loader__ = self
        if ispkg:
            mod.__path__ = self._get__path__()
        exec(code, mod.__dict__)
        return mod

Example 7

Project: TrustRouter
Source File: test_pkgutil.py
View license
        def load_module(self, fullname):
            # Create an empty module
            mod = sys.modules.setdefault(fullname, imp.new_module(fullname))
            mod.__file__ = "<%s>" % self.__class__.__name__
            mod.__loader__ = self
            # Make it a package
            mod.__path__ = []
            # Count how many times the module is reloaded
            mod.__dict__['loads'] = mod.__dict__.get('loads',0) + 1
            return mod

Example 8

Project: brython
Source File: test_importhooks.py
View license
    def load_module(self, fullname):
        ispkg, code = self.modules[fullname]
        mod = sys.modules.setdefault(fullname,imp.new_module(fullname))
        mod.__file__ = "<%s>" % self.__class__.__name__
        mod.__loader__ = self
        if ispkg:
            mod.__path__ = self._get__path__()
        exec(code, mod.__dict__)
        return mod

Example 9

Project: brython
Source File: test_pkgutil.py
View license
        def load_module(self, fullname):
            # Create an empty module
            mod = sys.modules.setdefault(fullname, imp.new_module(fullname))
            mod.__file__ = "<%s>" % self.__class__.__name__
            mod.__loader__ = self
            # Make it a package
            mod.__path__ = []
            # Count how many times the module is reloaded
            mod.__dict__['loads'] = mod.__dict__.get('loads',0) + 1
            return mod

Example 10

Project: subscription-manager
Source File: ga_loader.py
View license
    def _new_module(self, fullname):
        """Create a an empty module, we can populate with impl specific."""
        ret = sys.modules.setdefault(fullname, imp.new_module(fullname))
        ret.__name__ = fullname
        ret.__loader__ = self
        ret.__filename__ = fullname
        ret.__path__ = [fullname]
        ret.__package__ = '.'.join(fullname.split('.')[:-1])
        return ret

Example 11

Project: django-sellmo
Source File: base.py
View license
    @classmethod
    def load_module(cls, fullname):
        module = cls._modules[fullname]
        module.__loader__ = cls
        module.__file__ = "<%s>" % cls.__name__
        module.__package__ = fullname.rpartition('.')[0]
        module._import()
        sys.modules.setdefault(fullname, module)
        return module

Example 12

Project: chipsec
Source File: test_importhooks.py
View license
    def load_module(self, fullname):
        ispkg, code = self.modules[fullname]
        mod = sys.modules.setdefault(fullname,imp.new_module(fullname))
        mod.__file__ = "<%s>" % self.__class__.__name__
        mod.__loader__ = self
        if ispkg:
            mod.__path__ = self._get__path__()
        exec code in mod.__dict__
        return mod

Example 13

Project: chipsec
Source File: test_pkgutil.py
View license
        def load_module(self, fullname):
            # Create an empty module
            mod = sys.modules.setdefault(fullname, imp.new_module(fullname))
            mod.__file__ = "<%s>" % self.__class__.__name__
            mod.__loader__ = self
            # Make it a package
            mod.__path__ = []
            # Count how many times the module is reloaded
            mod.__dict__['loads'] = mod.__dict__.get('loads',0) + 1
            return mod

Example 14

Project: Pythonista-Tweaks
Source File: __init__.py
View license
	def load_module(self, fullname):
		assert fullname == "pythonista.classes"
		mod = sys.modules.setdefault(fullname, ObjCClassModuleProxy(fullname))
		mod.__file__ = "<dynamically created by {cls.__module__}.{cls.__name__}>".format(cls=type(self))
		mod.__loader__ = self
		mod.__package__ = "pythonista"
		mod.__all__ = ["NSDontEvenTryToStarImportThisModuleYouCrazyPerson"]
		return mod

Example 15

Project: backslant
Source File: __init__.py
View license
    def load_module(self, fullname):
        mod = sys.modules.setdefault(fullname, imp.new_module(fullname))
        mod.__loader__ = self
        mod.__package__ = fullname
        mod.__file__ = self.path
        mod.__path__ = []
        return mod

Example 16

Project: backslant
Source File: __init__.py
View license
    def load_module(self, fullname):
        # print(self.filename, fullname)
        mod = sys.modules.setdefault(fullname, imp.new_module(fullname))
        mod.__loader__ = self
        mod.__package__ = '.'.join(fullname.split('.')[:-1])
        mod.__file__ = self.filename
        mod.__dict__['_tag_start'] = start_tag
        mod.__dict__['_tag_stop'] = stop_tag
        code = func_compile(self.filename)
        exec(code, mod.__dict__)
        return mod

Example 17

Project: pyp2rpm
Source File: standalonetemplate.py
View license
    def load_module(self, fullname):
        # print "load_module:",  fullname
        from types import ModuleType
        try:
            s = self.sources[fullname]
            is_pkg = False
        except KeyError:
            s = self.sources[fullname + '.__init__']
            is_pkg = True

        co = compile(s, fullname, 'exec')
        module = sys.modules.setdefault(fullname, ModuleType(fullname))
        module.__file__ = "%s/%s" % (__file__, fullname)
        module.__loader__ = self
        if is_pkg:
            module.__path__ = [fullname]

        do_exec(co, module.__dict__)
        return sys.modules[fullname]

Example 18

Project: datafari
Source File: test_importhooks.py
View license
    def load_module(self, fullname):
        ispkg, code = self.modules[fullname]
        mod = sys.modules.setdefault(fullname,imp.new_module(fullname))
        mod.__file__ = "<%s>" % self.__class__.__name__
        mod.__loader__ = self
        if ispkg:
            mod.__path__ = self._get__path__()
        exec code in mod.__dict__
        return mod

Example 19

Project: datafari
Source File: test_pkgutil.py
View license
        def load_module(self, fullname):
            # Create an empty module
            mod = sys.modules.setdefault(fullname, imp.new_module(fullname))
            mod.__file__ = "<%s>" % self.__class__.__name__
            mod.__loader__ = self
            # Make it a package
            mod.__path__ = []
            # Count how many times the module is reloaded
            mod.__dict__['loads'] = mod.__dict__.get('loads',0) + 1
            return mod

Example 20

Project: Thespian
Source File: sourceLoader.py
View license
    def create_module(self, spec):
        # spec.name is what the module is registered under in sys.modules
        mod = sys.modules.setdefault(spec.name, imp.new_module(spec.name))
        mod.__file__ = spec.name
        mod.__loader__ = self
        if self.isModuleDir:
            mod.__path__ = []
            mod.__package__ = (spec.name if spec.name.startswith(spec.origin) else spec.origin + '.' + spec.name)
        else:
            pkgname = spec.name.rpartition('.')[0]
            if not pkgname.startswith(spec.origin):
                if not pkgname:
                    pkgname = spec.origin
                else:
                    pkgname = spec.origin + pkgname
            mod.__package__ = pkgname
        return mod

Example 21

Project: Thespian
Source File: sourceLoader.py
View license
    def load_module(self, moduleName):
        if moduleName != self.finder.hashRoot(): return None
        mod             = sys.modules.setdefault(moduleName, imp.new_module(moduleName))
        mod.__file__    = moduleName
        mod.__loader__  = self
        mod.__path__    = moduleName
        mod.__package__ = '{{RPKG}}' + moduleName
        code = compile('', mod.__file__, "exec")
        do_exec(code, mod.__dict__)
        return mod

Example 22

Project: openwrt-mt7620
Source File: test_importhooks.py
View license
    def load_module(self, fullname):
        ispkg, code = self.modules[fullname]
        mod = sys.modules.setdefault(fullname,imp.new_module(fullname))
        mod.__file__ = "<%s>" % self.__class__.__name__
        mod.__loader__ = self
        if ispkg:
            mod.__path__ = self._get__path__()
        exec code in mod.__dict__
        return mod

Example 23

Project: openwrt-mt7620
Source File: test_pkgutil.py
View license
        def load_module(self, fullname):
            # Create an empty module
            mod = sys.modules.setdefault(fullname, imp.new_module(fullname))
            mod.__file__ = "<%s>" % self.__class__.__name__
            mod.__loader__ = self
            # Make it a package
            mod.__path__ = []
            # Count how many times the module is reloaded
            mod.__dict__['loads'] = mod.__dict__.get('loads',0) + 1
            return mod

Example 24

Project: openwrt-mt7620
Source File: test_importhooks.py
View license
    def load_module(self, fullname):
        ispkg, code = self.modules[fullname]
        mod = sys.modules.setdefault(fullname,imp.new_module(fullname))
        mod.__file__ = "<%s>" % self.__class__.__name__
        mod.__loader__ = self
        if ispkg:
            mod.__path__ = self._get__path__()
        exec code in mod.__dict__
        return mod

Example 25

Project: openwrt-mt7620
Source File: test_pkgutil.py
View license
        def load_module(self, fullname):
            # Create an empty module
            mod = sys.modules.setdefault(fullname, imp.new_module(fullname))
            mod.__file__ = "<%s>" % self.__class__.__name__
            mod.__loader__ = self
            # Make it a package
            mod.__path__ = []
            # Count how many times the module is reloaded
            mod.__dict__['loads'] = mod.__dict__.get('loads',0) + 1
            return mod

Example 26

Project: neuroConstruct
Source File: test_pkgutil.py
View license
        def load_module(self, fullname):
            # Create an empty module
            mod = sys.modules.setdefault(fullname, imp.new_module(fullname))
            mod.__file__ = "<%s>" % self.__class__.__name__
            mod.__loader__ = self
            # Make it a package
            mod.__path__ = []
            # Count how many times the module is reloaded
            mod.__dict__['loads'] = mod.__dict__.get('loads',0) + 1
            return mod

Example 27

Project: neuroConstruct
Source File: test_pkgutil.py
View license
        def load_module(self, fullname):
            # Create an empty module
            mod = sys.modules.setdefault(fullname, imp.new_module(fullname))
            mod.__file__ = "<%s>" % self.__class__.__name__
            mod.__loader__ = self
            # Make it a package
            mod.__path__ = []
            # Count how many times the module is reloaded
            mod.__dict__['loads'] = mod.__dict__.get('loads',0) + 1
            return mod

Example 28

Project: PyAutoC
Source File: test_importhooks.py
View license
    def load_module(self, fullname):
        ispkg, code = self.modules[fullname]
        mod = sys.modules.setdefault(fullname,imp.new_module(fullname))
        mod.__file__ = "<%s>" % self.__class__.__name__
        mod.__loader__ = self
        if ispkg:
            mod.__path__ = self._get__path__()
        exec code in mod.__dict__
        return mod

Example 29

Project: PyAutoC
Source File: test_pkgutil.py
View license
        def load_module(self, fullname):
            # Create an empty module
            mod = sys.modules.setdefault(fullname, imp.new_module(fullname))
            mod.__file__ = "<%s>" % self.__class__.__name__
            mod.__loader__ = self
            # Make it a package
            mod.__path__ = []
            # Count how many times the module is reloaded
            mod.__dict__['loads'] = mod.__dict__.get('loads',0) + 1
            return mod

Example 30

View license
    def make_module(self, name, **args):
        mod = sys.modules.setdefault(name, imp.new_module(name))
        mod.__file__ = '<virtual %s>' % name
        mod.__dict__.update(**args)
        return mod

Example 31

View license
    def make_module(self, name, **args):
        mod = sys.modules.setdefault(name, imp.new_module(name))
        mod.__file__ = '<virtual %s>' % name
        mod.__dict__.update(**args)
        return mod

Example 32

Project: YCM_WIN_X86
Source File: test_importhook.py
View license
    def make_module(self, name, **args):
        mod = sys.modules.setdefault(name, imp.new_module(name))
        mod.__file__ = '<virtual %s>' % name
        mod.__dict__.update(**args)
        return mod

Example 33

Project: bottle
Source File: test_importhook.py
View license
    def make_module(self, name, **args):
        mod = sys.modules.setdefault(name, imp.new_module(name))
        mod.__file__ = '<virtual %s>' % name
        mod.__dict__.update(**args)
        return mod

Example 34

Project: dpa-pipe
Source File: dpa_import_hook.py
View license
    def load_module(self, module_fullname):
        """Loader.

        Called by python if the find_module was successful.

        :args str module_fullname: The fullname of the module to import
        :returns: The loaded module object.
        :raises ImportError: Failed to load module.

        """

        try:
            # attempt to load the module given the information from find_module
            module = sys.modules.setdefault(
                module_fullname,
                imp.load_module(
                    module_fullname,
                    self._file,
                    self._filename,
                    self._description
                )
            )
        except ImportError as e:
            raise
        finally:
            # as noted in the imp.load_module, must close the file
            if self._file:
                self._file.close()

        # the module needs to know the loader so that reload() works
        module.__loader__ = self

        return module

Example 35

Project: vogon
Source File: test_importhook.py
View license
    def make_module(self, name, **args):
        mod = sys.modules.setdefault(name, imp.new_module(name))
        mod.__file__ = '<virtual %s>' % name
        mod.__dict__.update(**args)
        return mod

Example 36

Project: pyjulia
Source File: core.py
View license
    def load_module(self, fullname):
        juliapath = fullname.lstrip("julia.")
        if isamodule(self.julia, juliapath):
            mod = sys.modules.setdefault(fullname, JuliaModule(fullname))
            mod.__loader__ = self
            names = self.julia.eval("names({}, true, false)".format(juliapath))
            for name in names:
                if (ismacro(name) or
                    isoperator(name) or
                    isprotected(name) or
                    notascii(name)):
                    continue
                attrname = name
                if name.endswith("!"):
                    attrname = name.replace("!", "_b")
                if keyword.iskeyword(name):
                    attrname = "jl".join(name)
                try:
                    module_path = ".".join((juliapath, name))
                    module_obj = self.julia.eval(module_path)
                    is_module = self.julia.eval("isa({}, Module)"
                                                .format(module_path))
                    if is_module:
                        split_path = module_path.split(".")
                        is_base = split_path[-1] == "Base"
                        recur_module = split_path[-1] == split_path[-2]
                        if is_module and not is_base and not recur_module:
                            newpath = ".".join((fullname, name))
                            module_obj = self.load_module(newpath)
                    setattr(mod, attrname, module_obj)
                except Exception:
                    if isafunction(self.julia, name, mod_name=juliapath):
                        func = "{}.{}".format(juliapath, name)
                        setattr(mod, name, self.julia.eval(func))
            return mod
        elif isafunction(self.julia, juliapath):
            return getattr(self.julia, juliapath)
        else:
            raise ImportError("{} not found".format(juliapath))

Example 37

Project: pyjulia
Source File: core.py
View license
    def load_module(self, fullname):
        juliapath = fullname.lstrip("julia.")
        if isamodule(self.julia, juliapath):
            mod = sys.modules.setdefault(fullname, JuliaModule(fullname))
            mod.__loader__ = self
            names = self.julia.eval("names({}, true, false)".format(juliapath))
            for name in names:
                if (ismacro(name) or
                    isoperator(name) or
                    isprotected(name) or
                    notascii(name)):
                    continue
                attrname = name
                if name.endswith("!"):
                    attrname = name.replace("!", "_b")
                if keyword.iskeyword(name):
                    attrname = "jl".join(name)
                try:
                    module_path = ".".join((juliapath, name))
                    module_obj = self.julia.eval(module_path)
                    is_module = self.julia.eval("isa({}, Module)"
                                                .format(module_path))
                    if is_module:
                        split_path = module_path.split(".")
                        is_base = split_path[-1] == "Base"
                        recur_module = split_path[-1] == split_path[-2]
                        if is_module and not is_base and not recur_module:
                            newpath = ".".join((fullname, name))
                            module_obj = self.load_module(newpath)
                    setattr(mod, attrname, module_obj)
                except Exception:
                    if isafunction(self.julia, name, mod_name=juliapath):
                        func = "{}.{}".format(juliapath, name)
                        setattr(mod, name, self.julia.eval(func))
            return mod
        elif isafunction(self.julia, juliapath):
            return getattr(self.julia, juliapath)
        else:
            raise ImportError("{} not found".format(juliapath))

Example 38

Project: calibre
Source File: zipplugin.py
View license
    def load_module(self, fullname):
        import_name, plugin_name = self._get_actual_fullname(fullname)
        if import_name is None and plugin_name is None:
            raise ImportError('No plugin named %r is loaded'%fullname)
        mod = sys.modules.setdefault(fullname, imp.new_module(fullname))
        mod.__file__ = "<calibre Plugin Loader>"
        mod.__loader__ = self

        if import_name.endswith('.__init__') or import_name in ('__init__',
                'calibre_plugins'):
            # We have a package
            mod.__path__ = []

        if plugin_name is not None:
            # We have some actual code to load
            with self._lock:
                zfp, names = self.loaded_plugins.get(plugin_name, (None, None))
            if names is None:
                raise ImportError('No plugin named %r loaded'%plugin_name)
            zinfo = names.get(import_name, None)
            if zinfo is None:
                raise ImportError('Plugin %r has no module named %r' %
                        (plugin_name, import_name))
            with zipfile.ZipFile(zfp) as zf:
                try:
                    code = zf.read(zinfo)
                except:
                    # Maybe the zip file changed from under us
                    code = zf.read(zinfo.filename)
            compiled = compile(code, 'calibre_plugins.%s.%s'%(plugin_name,
                import_name), 'exec', dont_inherit=True)
            mod.__dict__['get_resources'] = partial(get_resources, zfp)
            mod.__dict__['get_icons'] = partial(get_icons, zfp)
            mod.__dict__['load_translations'] = partial(load_translations, mod.__dict__, zfp)
            exec compiled in mod.__dict__

        return mod

Example 39

Project: calibre
Source File: zipplugin.py
View license
    def load_module(self, fullname):
        import_name, plugin_name = self._get_actual_fullname(fullname)
        if import_name is None and plugin_name is None:
            raise ImportError('No plugin named %r is loaded'%fullname)
        mod = sys.modules.setdefault(fullname, imp.new_module(fullname))
        mod.__file__ = "<calibre Plugin Loader>"
        mod.__loader__ = self

        if import_name.endswith('.__init__') or import_name in ('__init__',
                'calibre_plugins'):
            # We have a package
            mod.__path__ = []

        if plugin_name is not None:
            # We have some actual code to load
            with self._lock:
                zfp, names = self.loaded_plugins.get(plugin_name, (None, None))
            if names is None:
                raise ImportError('No plugin named %r loaded'%plugin_name)
            zinfo = names.get(import_name, None)
            if zinfo is None:
                raise ImportError('Plugin %r has no module named %r' %
                        (plugin_name, import_name))
            with zipfile.ZipFile(zfp) as zf:
                try:
                    code = zf.read(zinfo)
                except:
                    # Maybe the zip file changed from under us
                    code = zf.read(zinfo.filename)
            compiled = compile(code, 'calibre_plugins.%s.%s'%(plugin_name,
                import_name), 'exec', dont_inherit=True)
            mod.__dict__['get_resources'] = partial(get_resources, zfp)
            mod.__dict__['get_icons'] = partial(get_icons, zfp)
            mod.__dict__['load_translations'] = partial(load_translations, mod.__dict__, zfp)
            exec compiled in mod.__dict__

        return mod

Example 40

Project: chopsticks
Source File: bubble.py
View license
    def load_module(self, fullname):
        m = self.get(fullname)
        modname = fullname
        if fullname == '__main__':
            # Special-case __main__ so as not to execute
            # if __name__ == '__main__' blocks
            modname = '__chopsticks_main__'
        mod = sys.modules.setdefault(modname, imp.new_module(modname))
        mod.__file__ = PREFIX + m.file
        mod.__loader__ = self
        if m.is_pkg:
            modpath = PREFIX + m.file.rsplit('/', 1)[0] + '/'
            mod.__path__ = [modpath]
            mod.__package__ = modname
            #mod.__loader__ = Loader(modpath)
        else:
            mod.__package__ = modname.rpartition('.')[0]
        code = compile(m.source, mod.__file__, 'exec', dont_inherit=True)
        exec(code, mod.__dict__)
        if fullname == '__main__':
            mod.__name__ == '__main__'
            sys.modules[fullname] = mod
        return mod

Example 41

Project: chopsticks
Source File: bubble.py
View license
    def load_module(self, fullname):
        m = self.get(fullname)
        modname = fullname
        if fullname == '__main__':
            # Special-case __main__ so as not to execute
            # if __name__ == '__main__' blocks
            modname = '__chopsticks_main__'
        mod = sys.modules.setdefault(modname, imp.new_module(modname))
        mod.__file__ = PREFIX + m.file
        mod.__loader__ = self
        if m.is_pkg:
            modpath = PREFIX + m.file.rsplit('/', 1)[0] + '/'
            mod.__path__ = [modpath]
            mod.__package__ = modname
            #mod.__loader__ = Loader(modpath)
        else:
            mod.__package__ = modname.rpartition('.')[0]
        code = compile(m.source, mod.__file__, 'exec', dont_inherit=True)
        exec(code, mod.__dict__)
        if fullname == '__main__':
            mod.__name__ == '__main__'
            sys.modules[fullname] = mod
        return mod

Example 42

Project: bottle-doc-zh-cn
Source File: test_importhook.py
View license
    def make_module(self, name, **args):
        mod = sys.modules.setdefault(name, imp.new_module(name))
        mod.__file__ = '<virtual %s>' % name
        mod.__dict__.update(**args)
        return mod

Example 43

Project: bottle-doc-zh-cn
Source File: test_importhook.py
View license
    def make_module(self, name, **args):
        mod = sys.modules.setdefault(name, imp.new_module(name))
        mod.__file__ = '<virtual %s>' % name
        mod.__dict__.update(**args)
        return mod

Example 44

Project: inliner
Source File: import_hook.py
View license
    def find_module(self, fullname, path):
        file, pathname, description = imp.find_module(
            fullname.split(".")[-1], path)

        src = file.read()
        tree = ast.parse(src)
        tree = ParentNodeTransformer().visit(tree)

        function_disoverer = InlineMethodLocator()
        function_disoverer.visit(tree)
        print "found funcs: %s" % function_disoverer.functions
        tree = FunctionInliner(function_disoverer.functions).visit(tree)

        module = sys.modules.setdefault(fullname,
                                        imp.new_module(fullname))
        module.__package__ = fullname.rpartition('.')[0]
        module.__file__ = file.name
        tree = ast.fix_missing_locations(tree)

        code = compile(tree, file.name, "exec")

        exec code in module.__dict__

        return InlineLoader(module)