Exemplo n.º 1
0
        /// <summary>
        /// Given a user defined importer object as defined in PEP 302 tries to load a module.
        ///
        /// First the find_module(fullName, path) is invoked to get a loader, then load_module(fullName) is invoked
        /// </summary>
        private static bool FindAndLoadModuleFromImporter(CodeContext /*!*/ context, object importer, string fullName, List path, out object ret)
        {
            object find_module = PythonOps.GetBoundAttr(context, importer, "find_module");

            PythonContext pycontext = context.LanguageContext;
            object        loader    = pycontext.Call(context, find_module, fullName, path);

            if (loader != null)
            {
                object findMod = PythonOps.GetBoundAttr(context, loader, "load_module");
                ret = pycontext.Call(context, findMod, fullName);
                return(ret != null);
            }

            ret = null;
            return(false);
        }